Project

General

Profile

« Previous | Next » 

Revision 10173

Ensure XML run response from quality engine. Use mock http request to ensure correct save behavior of the resulting run. https://projects.ecoinformatics.org/ecoinfo/issues/7171 and https://github.com/NCEAS/mdqengine/issues/73

View differences:

src/edu/ucsb/nceas/metacat/mdq/MDQClient.java
9 9
import java.util.concurrent.ExecutorService;
10 10
import java.util.concurrent.Executors;
11 11

  
12
import javax.servlet.http.HttpServletRequest;
13

  
12 14
import org.apache.commons.io.IOUtils;
13 15
import org.apache.http.HttpEntity;
14 16
import org.apache.http.client.methods.CloseableHttpResponse;
......
16 18
import org.apache.http.impl.client.CloseableHttpClient;
17 19
import org.apache.http.impl.client.HttpClients;
18 20
import org.apache.log4j.Logger;
21
import org.apache.wicket.protocol.http.mock.MockHttpServletRequest;
19 22
import org.dataone.client.types.AccessPolicyEditor;
20 23
import org.dataone.client.v2.formats.ObjectFormatCache;
21 24
import org.dataone.configuration.Settings;
......
114 117
		entity.addFilePart("document", docStream);
115 118
		
116 119
		// add sysMeta 
120
		logMetacat.debug("marshalling sysMeta for: " + sysMeta.getIdentifier().getValue());
117 121
		ByteArrayOutputStream baos = new ByteArrayOutputStream();
118 122
		TypeMarshaller.marshalTypeToOutputStream(sysMeta, baos);
119 123
		entity.addFilePart("systemMetadata", new ByteArrayInputStream(baos.toByteArray()));
120 124
		
125
		// make sure we get XML back
126
		post.addHeader("Accept", "application/xml");
127
		
121 128
		// send to service
122 129
		post.setEntity(entity);
123 130
		CloseableHttpClient client = HttpClients.createDefault();
......
133 140
	}
134 141
	
135 142
	private static Identifier saveRun(InputStream runStream, SystemMetadata metadataSysMeta) throws Exception {
136
		MNodeService mn = MNodeService.getInstance(null);
137 143
		
144
		HttpServletRequest request = new MockHttpServletRequest(null, null, null);
145
		MNodeService mn = MNodeService.getInstance(request);
146
		
138 147
		// copy the properties from the metadata sysmeta to the run sysmeta
139 148
		byte[] bytes = IOUtils.toByteArray(runStream);
140 149
		SystemMetadata sysmeta = generateSystemMetadata(bytes, metadataSysMeta);

Also available in: Unified diff