Do HTTP post for tester UI create/updates
This commit is contained in:
parent
5bcd6a4751
commit
8072ca1bc1
|
@ -288,6 +288,8 @@ public class RestfulClientFactory implements IRestfulClientFactory {
|
|||
serverFhirVersionEnum = FhirVersionEnum.DSTU1;
|
||||
} else if (serverFhirVersionString.startsWith("0.4")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU2;
|
||||
} else if (serverFhirVersionString.startsWith("0.5")) {
|
||||
serverFhirVersionEnum = FhirVersionEnum.DSTU2;
|
||||
} else {
|
||||
// we'll be lenient and accept this
|
||||
ourLog.debug("Server conformance statement indicates unknown FHIR version: {}", serverFhirVersionString);
|
||||
|
|
|
@ -12,11 +12,12 @@
|
|||
<bean class="ca.uhn.fhir.to.TesterConfig">
|
||||
<property name="servers">
|
||||
<list>
|
||||
<value>home , DSTU1 , UHN/HAPI Server (DSTU1 FHIR) , http://fhirtest.uhn.ca/baseDstu1</value>
|
||||
<value>home_dev , DSTU2 , UHN/HAPI Server (DSTU2 FHIR) , http://fhirtest.uhn.ca/baseDstu2</value>
|
||||
<value>hi , DSTU1 , Health Intersections (DSTU1 FHIR) , http://fhir.healthintersections.com.au/open</value>
|
||||
<value>home , DSTU1 , UHN/HAPI Server (DSTU1 FHIR) , http://fhirtest.uhn.ca/baseDstu1</value>
|
||||
<value>hidev , DSTU2 , Health Intersections (DSTU2 FHIR) , http://fhir-dev.healthintersections.com.au/open</value>
|
||||
<value>furore , DSTU1 , Spark - Furore , http://spark.furore.com/fhir</value>
|
||||
<value>hi , DSTU1 , Health Intersections (DSTU1 FHIR) , http://fhir.healthintersections.com.au/open</value>
|
||||
<value>furored2 , DSTU1 , Spark - Furore (DSTU2 FHIR) , http://spark-dstu2.furore.com/fhir</value>
|
||||
<value>furore , DSTU1 , Spark - Furore (DSTU1 FHIR) , http://spark.furore.com/fhir</value>
|
||||
<value>blaze , DSTU1 , Blaze (Orion Health) , https://fhir.orionhealth.com/blaze/fhir</value>
|
||||
<value>oridashi , DSTU1 , Oridashi , http://demo.oridashi.com.au:8190</value>
|
||||
<!-- <value>fhirbase , DSTU1 , FHIRPlace (Health Samurai) , http://try-fhirplace.hospital-systems.com/ </value> -->
|
||||
|
|
|
@ -54,6 +54,7 @@ public class XmlParserDstu2Test {
|
|||
XMLUnit.setIgnoreWhitespace(true);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* see #144 and #146
|
||||
*/
|
||||
|
|
|
@ -12,6 +12,7 @@ import java.io.StringReader;
|
|||
import java.nio.charset.Charset;
|
||||
|
||||
import org.apache.commons.io.input.ReaderInputStream;
|
||||
import org.apache.http.Header;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.ProtocolVersion;
|
||||
import org.apache.http.client.HttpClient;
|
||||
|
@ -31,10 +32,11 @@ import ca.uhn.fhir.model.dstu2.resource.Conformance;
|
|||
import ca.uhn.fhir.model.dstu2.resource.Patient;
|
||||
import ca.uhn.fhir.model.primitive.UriDt;
|
||||
import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
|
||||
import ca.uhn.fhir.rest.client.interceptor.BasicAuthInterceptor;
|
||||
import ca.uhn.fhir.rest.server.Constants;
|
||||
|
||||
public class ClientServerValidationTestDstu2 {
|
||||
|
||||
|
||||
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientServerValidationTestDstu2.class);
|
||||
private FhirContext myCtx;
|
||||
private HttpClient myHttpClient;
|
||||
|
@ -65,20 +67,21 @@ public class ClientServerValidationTestDstu2 {
|
|||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
if (myFirstResponse) {
|
||||
myFirstResponse=false;
|
||||
myFirstResponse = false;
|
||||
return new ReaderInputStream(new StringReader(confResource), Charset.forName("UTF-8"));
|
||||
} else {
|
||||
return new ReaderInputStream(new StringReader(myCtx.newXmlParser().encodeResourceToString(new Patient())), Charset.forName("UTF-8"));
|
||||
}
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
|
||||
myCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.ONCE);
|
||||
IGenericClient client = myCtx.newRestfulGenericClient("http://foo");
|
||||
|
||||
// don't load the conformance until the first time the client is actually used
|
||||
assertTrue(myFirstResponse);
|
||||
|
||||
// don't load the conformance until the first time the client is actually used
|
||||
assertTrue(myFirstResponse);
|
||||
client.read(new UriDt("http://foo/Patient/123"));
|
||||
assertFalse(myFirstResponse);
|
||||
myCtx.newRestfulGenericClient("http://foo").read(new UriDt("http://foo/Patient/123"));
|
||||
|
@ -102,20 +105,21 @@ public class ClientServerValidationTestDstu2 {
|
|||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
if (myFirstResponse) {
|
||||
myFirstResponse=false;
|
||||
myFirstResponse = false;
|
||||
return new ReaderInputStream(new StringReader(confResource), Charset.forName("UTF-8"));
|
||||
} else {
|
||||
return new ReaderInputStream(new StringReader(myCtx.newXmlParser().encodeResourceToString(new Patient())), Charset.forName("UTF-8"));
|
||||
}
|
||||
}});
|
||||
}
|
||||
});
|
||||
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
|
||||
myCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.ONCE);
|
||||
IGenericClient client = myCtx.newRestfulGenericClient("http://foo");
|
||||
|
||||
// don't load the conformance until the first time the client is actually used
|
||||
assertTrue(myFirstResponse);
|
||||
|
||||
// don't load the conformance until the first time the client is actually used
|
||||
assertTrue(myFirstResponse);
|
||||
client.read(new UriDt("http://foo/Patient/123"));
|
||||
assertFalse(myFirstResponse);
|
||||
myCtx.newRestfulGenericClient("http://foo").read(new UriDt("http://foo/Patient/123"));
|
||||
|
@ -151,4 +155,39 @@ public class ClientServerValidationTestDstu2 {
|
|||
assertThat(out, containsString(want));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testClientUsesInterceptors() throws Exception {
|
||||
Conformance conf = new Conformance();
|
||||
conf.setFhirVersion("0.5.0");
|
||||
final String confResource = myCtx.newXmlParser().encodeResourceToString(conf);
|
||||
|
||||
ArgumentCaptor<HttpUriRequest> capt = ArgumentCaptor.forClass(HttpUriRequest.class);
|
||||
|
||||
when(myHttpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 200, "OK"));
|
||||
when(myHttpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
|
||||
when(myHttpResponse.getEntity().getContent()).thenAnswer(new Answer<InputStream>() {
|
||||
@Override
|
||||
public InputStream answer(InvocationOnMock theInvocation) throws Throwable {
|
||||
if (myFirstResponse) {
|
||||
myFirstResponse = false;
|
||||
return new ReaderInputStream(new StringReader(confResource), Charset.forName("UTF-8"));
|
||||
} else {
|
||||
return new ReaderInputStream(new StringReader(myCtx.newXmlParser().encodeResourceToString(new Patient())), Charset.forName("UTF-8"));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
|
||||
|
||||
myCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.ONCE);
|
||||
IGenericClient client = myCtx.newRestfulGenericClient("http://foo");
|
||||
client.registerInterceptor(new BasicAuthInterceptor("USER", "PASS"));
|
||||
client.read(new UriDt("http://foo/Patient/123"));
|
||||
|
||||
Header auth = capt.getValue().getFirstHeader("Authorization");
|
||||
assertNotNull(auth);
|
||||
assertEquals("Basic VVNFUjpQQVNT", auth.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -432,7 +432,7 @@
|
|||
if (id != null) btn.append($('<input />', { type: 'hidden', name: 'resource-create-id', value: id }));
|
||||
var body = $('#resource-create-body').val();
|
||||
btn.append($('<input />', { type: 'hidden', name: 'resource-create-body', value: body }));
|
||||
$("#outerForm").attr("action", "create").submit();
|
||||
$("#outerForm").attr("action", "create").attr("method", "POST").submit();
|
||||
});
|
||||
$( document ).ready(function() {
|
||||
if ($('#resource-create-id').val() != "") {
|
||||
|
@ -498,7 +498,7 @@
|
|||
if (id != null) btn.append($('<input />', { type: 'hidden', name: 'resource-create-id', value: id }));
|
||||
var body = $('#resource-update-body').val();
|
||||
btn.append($('<input />', { type: 'hidden', name: 'resource-create-body', value: body }));
|
||||
$("#outerForm").attr("action", "update").submit();
|
||||
$("#outerForm").attr("action", "update").attr("method", "POST").submit();
|
||||
});
|
||||
$( document ).ready(function() {
|
||||
if ($('#resource-update-id').val() != "") {
|
||||
|
@ -549,7 +549,7 @@
|
|||
btn.button('loading');
|
||||
var body = $('#resource-validate-body').val();
|
||||
btn.append($('<input />', { type: 'hidden', name: 'resource-validate-body', value: body }));
|
||||
$("#outerForm").attr("action", "validate").submit();
|
||||
$("#outerForm").attr("action", "validate").attr("method", "POST").submit();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue