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