Fix cobertura fails
This commit is contained in:
parent
072ec29f13
commit
f616c22429
|
@ -57,56 +57,69 @@ public class ETagServerTest {
|
|||
@Test
|
||||
public void testETagHeader() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2/_history/3");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
try {
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class, responseContent).getIdentifierFirstRep();
|
||||
assertEquals("2", dt.getSystemElement().getValueAsString());
|
||||
assertEquals("3", dt.getValue());
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class, responseContent).getIdentifierFirstRep();
|
||||
assertEquals("2", dt.getSystemElement().getValueAsString());
|
||||
assertEquals("3", dt.getValue());
|
||||
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_ETAG_LC);
|
||||
assertNotNull(cl);
|
||||
assertEquals("W/\"222\"", cl.getValue());
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_ETAG_LC);
|
||||
assertNotNull(cl);
|
||||
assertEquals("W/\"222\"", cl.getValue());
|
||||
} finally {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAutomaticNotModified() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2");
|
||||
httpGet.addHeader(Constants.HEADER_IF_NONE_MATCH, "\"222\"");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
assertEquals(Constants.STATUS_HTTP_304_NOT_MODIFIED, status.getStatusLine().getStatusCode());
|
||||
try {
|
||||
assertEquals(Constants.STATUS_HTTP_304_NOT_MODIFIED, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testLastModifiedHeader() throws Exception {
|
||||
ourLastModifiedDate = new InstantDt("2012-11-25T02:34:45.2222Z").getValue();
|
||||
|
||||
|
||||
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/2/_history/3");
|
||||
HttpResponse status = ourClient.execute(httpGet);
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
try {
|
||||
String responseContent = IOUtils.toString(status.getEntity().getContent());
|
||||
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class, responseContent).getIdentifierFirstRep();
|
||||
assertEquals("2", dt.getSystemElement().getValueAsString());
|
||||
assertEquals("3", dt.getValue());
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
IdentifierDt dt = ourCtx.newXmlParser().parseResource(Patient.class, responseContent).getIdentifierFirstRep();
|
||||
assertEquals("2", dt.getSystemElement().getValueAsString());
|
||||
assertEquals("3", dt.getValue());
|
||||
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_LAST_MODIFIED_LOWERCASE);
|
||||
assertNotNull(cl);
|
||||
assertEquals("Sun, 25 Nov 2012 02:34:47 GMT", cl.getValue());
|
||||
Header cl = status.getFirstHeader(Constants.HEADER_LAST_MODIFIED_LOWERCASE);
|
||||
assertNotNull(cl);
|
||||
assertEquals("Sun, 25 Nov 2012 02:34:47 GMT", cl.getValue());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Before
|
||||
public void before() throws IOException {
|
||||
ourLastId=null;
|
||||
ourLastId = null;
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -115,14 +128,19 @@ public class ETagServerTest {
|
|||
p.setId("2");
|
||||
p.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
|
||||
HttpPut http;
|
||||
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
|
||||
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
HttpResponse status = ourClient.execute(http);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
|
||||
try {
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -131,16 +149,20 @@ public class ETagServerTest {
|
|||
p.setId("2");
|
||||
p.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
|
||||
HttpPut http;
|
||||
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
|
||||
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
http.addHeader(Constants.HEADER_IF_MATCH, "\"221\"");
|
||||
CloseableHttpResponse status = ourClient.execute(http);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("Patient/2/_history/221", ourLastId.toUnqualified().getValue());
|
||||
|
||||
try {
|
||||
assertEquals(200, status.getStatusLine().getStatusCode());
|
||||
assertEquals("Patient/2/_history/221", ourLastId.toUnqualified().getValue());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -149,18 +171,22 @@ public class ETagServerTest {
|
|||
p.setId("2");
|
||||
p.addIdentifier().setSystem("urn:system").setValue("001");
|
||||
String resBody = ourCtx.newXmlParser().encodeResourceToString(p);
|
||||
|
||||
|
||||
HttpPut http;
|
||||
http = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
|
||||
http.setEntity(new StringEntity(resBody, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
|
||||
http.addHeader(Constants.HEADER_IF_MATCH, "\"222\"");
|
||||
CloseableHttpResponse status = ourClient.execute(http);
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
assertEquals(Constants.STATUS_HTTP_412_PRECONDITION_FAILED, status.getStatusLine().getStatusCode());
|
||||
assertEquals("Patient/2/_history/222", ourLastId.toUnqualified().getValue());
|
||||
try {
|
||||
assertEquals(Constants.STATUS_HTTP_412_PRECONDITION_FAILED, status.getStatusLine().getStatusCode());
|
||||
assertEquals("Patient/2/_history/222", ourLastId.toUnqualified().getValue());
|
||||
} finally {
|
||||
if (status.getEntity() != null) {
|
||||
IOUtils.closeQuietly(status.getEntity().getContent());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@AfterClass
|
||||
public static void afterClass() throws Exception {
|
||||
ourServer.stop();
|
||||
|
@ -174,7 +200,7 @@ public class ETagServerTest {
|
|||
PatientProvider patientProvider = new PatientProvider();
|
||||
|
||||
ServletHandler proxyHandler = new ServletHandler();
|
||||
RestfulServer servlet = new RestfulServer(ourCtx);
|
||||
RestfulServer servlet = new RestfulServer(FhirContext.forDstu2());
|
||||
ourCtx = servlet.getFhirContext();
|
||||
servlet.setResourceProviders(patientProvider);
|
||||
ServletHolder servletHolder = new ServletHolder(servlet);
|
||||
|
@ -190,7 +216,7 @@ public class ETagServerTest {
|
|||
}
|
||||
|
||||
private static IdDt ourLastId;
|
||||
|
||||
|
||||
public static class PatientProvider implements IResourceProvider {
|
||||
|
||||
@Read(version = true)
|
||||
|
@ -205,11 +231,11 @@ public class ETagServerTest {
|
|||
@Update
|
||||
public MethodOutcome updatePatient(@IdParam IdDt theId, @ResourceParam Patient theResource) {
|
||||
ourLastId = theId;
|
||||
|
||||
|
||||
if ("222".equals(theId.getVersionIdPart())) {
|
||||
throw new PreconditionFailedException("Bad version");
|
||||
}
|
||||
|
||||
|
||||
return new MethodOutcome(theId.withVersion(theId.getVersionIdPart() + "0"));
|
||||
}
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
ServletRequestDetails reqDetails = new ServletRequestDetails();
|
||||
reqDetails.setRequestType(RequestTypeEnum.GET);
|
||||
reqDetails.setParameters(new HashMap<String, String[]>());
|
||||
reqDetails.setServer(new RestfulServer());
|
||||
reqDetails.setServer(new RestfulServer(ourCtx));
|
||||
reqDetails.setServletRequest(req);
|
||||
|
||||
ResourceNotFoundException exception = new ResourceNotFoundException("Not found");
|
||||
|
@ -182,7 +182,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
HashMap<String, String[]> params = new HashMap<String, String[]>();
|
||||
params.put(Constants.PARAM_PRETTY, new String[] { Constants.PARAM_PRETTY_VALUE_TRUE });
|
||||
reqDetails.setParameters(params);
|
||||
reqDetails.setServer(new RestfulServer());
|
||||
reqDetails.setServer(new RestfulServer(ourCtx));
|
||||
reqDetails.setServletRequest(req);
|
||||
|
||||
assertFalse(ic.outgoingResponse(reqDetails, resource, req, resp));
|
||||
|
@ -219,7 +219,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
params.put(Constants.PARAM_FORMAT, new String[] { Constants.CT_XML });
|
||||
params.put(ResponseHighlighterInterceptor.PARAM_RAW, new String[] { ResponseHighlighterInterceptor.PARAM_RAW_TRUE });
|
||||
reqDetails.setParameters(params);
|
||||
reqDetails.setServer(new RestfulServer());
|
||||
reqDetails.setServer(new RestfulServer(ourCtx));
|
||||
reqDetails.setServletRequest(req);
|
||||
|
||||
// true means it decided to not handle the request..
|
||||
|
@ -249,7 +249,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
ServletRequestDetails reqDetails = new ServletRequestDetails();
|
||||
reqDetails.setRequestType(RequestTypeEnum.GET);
|
||||
reqDetails.setParameters(new HashMap<String, String[]>());
|
||||
reqDetails.setServer(new RestfulServer());
|
||||
reqDetails.setServer(new RestfulServer(ourCtx));
|
||||
reqDetails.setServletRequest(req);
|
||||
|
||||
assertFalse(ic.outgoingResponse(reqDetails, resource, req, resp));
|
||||
|
@ -287,7 +287,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
ServletRequestDetails reqDetails = new ServletRequestDetails();
|
||||
reqDetails.setRequestType(RequestTypeEnum.GET);
|
||||
reqDetails.setParameters(new HashMap<String, String[]>());
|
||||
RestfulServer server = new RestfulServer();
|
||||
RestfulServer server = new RestfulServer(ourCtx);
|
||||
server.setDefaultResponseEncoding(EncodingEnum.JSON);
|
||||
reqDetails.setServer(server);
|
||||
reqDetails.setServletRequest(req);
|
||||
|
@ -325,7 +325,7 @@ public class ResponseHighlightingInterceptorTest {
|
|||
ServletRequestDetails reqDetails = new ServletRequestDetails();
|
||||
reqDetails.setRequestType(RequestTypeEnum.GET);
|
||||
reqDetails.setParameters(new HashMap<String, String[]>());
|
||||
RestfulServer server = new RestfulServer();
|
||||
RestfulServer server = new RestfulServer(ourCtx);
|
||||
server.setDefaultResponseEncoding(EncodingEnum.JSON);
|
||||
reqDetails.setServer(server);
|
||||
reqDetails.setServletRequest(req);
|
||||
|
|
|
@ -611,7 +611,7 @@ public class JsonParserDstu3Test {
|
|||
ourLog.info(val);
|
||||
assertThat(val, StringContains.containsString("\"extension\":[{\"url\":\"urn:foo\",\"valueCode\":\"home\"}]"));
|
||||
|
||||
MyPatientWithOneDeclaredEnumerationExtension actual = parser.parseResource(MyPatientWithOneDeclaredEnumerationExtension.class, val);
|
||||
MyPatientWithOneDeclaredEnumerationExtensionDstu3 actual = parser.parseResource(MyPatientWithOneDeclaredEnumerationExtensionDstu3.class, val);
|
||||
assertEquals(AddressUse.HOME, patient.getAddress().get(0).getUse());
|
||||
Enumeration<AddressUse> ref = actual.getFoo();
|
||||
assertEquals("home", ref.getValue().toCode());
|
||||
|
|
|
@ -8,7 +8,7 @@ import ca.uhn.fhir.model.api.annotation.Child;
|
|||
import ca.uhn.fhir.model.api.annotation.ResourceDef;
|
||||
|
||||
@ResourceDef(name = "Patient")
|
||||
public class MyPatientWithOneDeclaredEnumerationExtension extends Patient {
|
||||
public class MyPatientWithOneDeclaredEnumerationExtensionDstu3 extends Patient {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
@ -1199,7 +1199,7 @@ public class XmlParserDstu3Test {
|
|||
ourLog.info(val);
|
||||
assertThat(val, StringContains.containsString("<extension url=\"urn:foo\"><valueCode value=\"home\"/></extension>"));
|
||||
|
||||
MyPatientWithOneDeclaredEnumerationExtension actual = parser.parseResource(MyPatientWithOneDeclaredEnumerationExtension.class, val);
|
||||
MyPatientWithOneDeclaredEnumerationExtensionDstu3 actual = parser.parseResource(MyPatientWithOneDeclaredEnumerationExtensionDstu3.class, val);
|
||||
assertEquals(AddressUse.HOME, patient.getAddress().get(0).getUse());
|
||||
Enumeration<AddressUse> ref = actual.getFoo();
|
||||
assertEquals("home", ref.getValue().toCode());
|
||||
|
|
|
@ -6,7 +6,7 @@ import org.junit.Test;
|
|||
public class TestTest {
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
// @Ignore
|
||||
public void testId() throws InterruptedException {
|
||||
Thread.sleep(1000000);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue