fixing tests

This commit is contained in:
patrick-werner 2018-06-21 11:50:58 +02:00
parent ef9f97a576
commit f470653ba4
2 changed files with 10 additions and 6 deletions

View File

@ -171,6 +171,9 @@ public enum EncodingEnum {
* @see #forContentType(String)
*/
public static EncodingEnum forContentTypeStrict(String theContentType) {
if (theContentType == null) {
return null;
}
String[] contentTypeSplitted = theContentType.split(";");
return ourContentTypeToEncodingStrict.get(contentTypeSplitted[0]);
}

View File

@ -96,9 +96,9 @@ public class BinaryDstu2Test {
assertArrayEquals(new byte[] { 1, 2, 3, 4 }, bin.getContent());
}
// posts Binary directly
@Test
public void testCreate() throws Exception {
public void testPostBinary() throws Exception {
HttpPost http = new HttpPost("http://localhost:" + ourPort + "/Binary");
http.setEntity(new ByteArrayEntity(new byte[] { 1, 2, 3, 4 }, ContentType.create("foo/bar", "UTF-8")));
@ -110,8 +110,9 @@ public class BinaryDstu2Test {
}
// posts Binary as FHIR Resource
@Test
public void testCreateWrongType() throws Exception {
public void testPostFhirBinary() throws Exception {
Binary res = new Binary();
res.setContent(new byte[] { 1, 2, 3, 4 });
res.setContentType("text/plain");
@ -123,7 +124,7 @@ public class BinaryDstu2Test {
HttpResponse status = ourClient.execute(http);
assertEquals(201, status.getStatusLine().getStatusCode());
assertEquals("application/json+fhir;charset=utf-8", ourLast.getContentType().replace(" ","").toLowerCase());
assertEquals("text/plain", ourLast.getContentType().replace(" ","").toLowerCase());
}
@ -213,11 +214,11 @@ public class BinaryDstu2Test {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
ResourceProvider patientProvider = new ResourceProvider();
ResourceProvider binaryProvider = new ResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
servlet.setResourceProviders(binaryProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);