From 083c23aa0412b120eb7c3352d10dc86fdd827738 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 10:13:39 -0400
Subject: [PATCH 01/35] Add travis
---
.travis.yml | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 .travis.yml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 00000000000..a98b7603500
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,2 @@
+language: java
+
From cadf3eaa950cea1a4cdcefd2e50fc06b1f88e92e Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 10:23:06 -0400
Subject: [PATCH 02/35] Reduce log verbosity
---
.../java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
index 501e10f3db1..350dd9d1c29 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
@@ -89,7 +89,7 @@ public abstract class BaseStructureParser {
myLocallyDefinedClassNames.put(bindingClass, "valueset");
} else {
ourLog.info("No binding found for: {}", theResource.getBinding());
- ourLog.info(" * Valid: {}", new TreeSet(theVsp.getValueSets().keySet()));
+ ourLog.debug(" * Valid: {}", new TreeSet(theVsp.getValueSets().keySet()));
}
}
for (BaseElement next : theResource.getChildren()) {
From 9f09eff53f33f605c507603cadc4395157e84745 Mon Sep 17 00:00:00 2001
From: James Agnew
Date: Sat, 20 Jun 2015 14:21:15 -0400
Subject: [PATCH 03/35] Update README.md
---
README.md | 2 ++
1 file changed, 2 insertions(+)
diff --git a/README.md b/README.md
index f191355e48f..1a8f09d2609 100644
--- a/README.md
+++ b/README.md
@@ -3,6 +3,8 @@ hapi-fhir
HAPI FHIR - Java API for HL7 FHIR Clients and Servers
+![Travis](https://travis-ci.org/jamesagnew/hapi-fhir.svg?branch=master)
+
Complete project documentation is available here:
http://jamesagnew.github.io/hapi-fhir/
From 71fbfe5214a17e1f6bc0ae53ff044cc5c1d57dd8 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 14:23:34 -0400
Subject: [PATCH 04/35] Add consolidated test package and clean up tests for
cobertura
---
.travis.yml | 5 +
.../src/main/java/example/ClientExamples.java | 14 +-
.../java/example/CompleteExampleClient.java | 2 +-
.../java/example/ExampleRestfulClient.java | 2 +-
.../src/main/java/example/Extensions.java | 3 +-
examples/src/main/java/example/HttpProxy.java | 2 +-
.../src/main/java/example/MyPatientUse.java | 6 +-
examples/src/main/java/example/Narrative.java | 2 +-
.../main/java/example/NarrativeGenerator.java | 2 +-
.../src/main/java/example/QuickUsage.java | 2 +-
.../src/main/java/example/ResourceRefs.java | 2 +-
.../RestfulPatientResourceProviderMore.java | 4 +-
.../main/java/example/ServerInterceptors.java | 2 +-
.../src/main/java/example/TagsExamples.java | 2 +-
.../main/java/example/ValidatorExamples.java | 4 +-
.../BaseThymeleafNarrativeGenerator.java | 1 +
.../uhn/fhir/rest/server/RestfulServer.java | 27 +-
.../provider/ResourceProviderDstu1Test.java | 12 +-
.../provider/ResourceProviderDstu2Test.java | 39 +-
.../ResourceProviderMultiVersionTest.java | 6 +-
.../jpa/provider/SystemProviderDstu1Test.java | 2 +-
.../jpa/provider/SystemProviderDstu2Test.java | 2 +-
.../{bundle.json => bundle-dstu2.json} | 0
.../src/test/resources/logback-test.xml | 4 +-
.../ca/uhn/fhirtest/FhirContextFactory.java | 11 +-
.../test/java/ca/uhn/fhir/Dstu1EnvTest.java | 17 -
.../fhir/context/DuplicateExtensionTest.java | 2 +-
.../ca/uhn/fhir/context/ExtensionTest.java | 8 +-
...extTest.java => FhirContextDstu1Test.java} | 8 +-
.../fhir/context/InvalidResourceTypeTest.java | 2 +-
.../uhn/fhir/context/ModelExtensionTest.java | 2 +-
.../ca/uhn/fhir/context/ModelScannerTest.java | 2 +-
.../java/ca/uhn/fhir/context/NameChanges.java | 2 +-
.../context/ProvidedResourceScannerTest.java | 2 +-
.../ca/uhn/fhir/model/api/TagListTest.java | 2 +-
.../model/primitive/BaseDateTimeDtTest.java | 2 +-
.../ca/uhn/fhir/model/primitive/IdDtTest.java | 2 +-
.../fhir/model/view/ViewGeneratorTest.java | 2 +-
...efaultThymeleafNarrativeGeneratorTest.java | 2 +-
.../ca/uhn/fhir/parser/BaseParserTest.java | 2 +-
.../parser/ContainedResourceEncodingTest.java | 2 +-
.../ca/uhn/fhir/parser/JsonParserTest.java | 40 +-
.../ca/uhn/fhir/parser/XmlParserTest.java | 5 +-
.../rest/client/BasicAuthInterceptorTest.java | 2 +-
.../BearerTokenAuthInterceptorTest.java | 2 +-
.../{ClientTest.java => ClientDstu1Test.java} | 107 +++--
.../rest/client/ClientIntegrationTest.java | 5 +-
.../rest/client/ExceptionHandlingTest.java | 2 +-
.../fhir/rest/client/GenericClientTest.java | 4 +-
.../uhn/fhir/rest/client/HttpProxyTest.java | 5 +-
.../rest/client/LoggingInterceptorTest.java | 8 +-
...chTest.java => SearchClientDstu1Test.java} | 4 +-
...BaseOutcomeReturningMethodBindingTest.java | 2 +-
.../fhir/rest/server/AcceptHeaderTest.java | 3 +-
.../ca/uhn/fhir/rest/server/BinaryTest.java | 4 +-
.../rest/server/CompositeParameterTest.java | 7 +-
.../uhn/fhir/rest/server/CompressionTest.java | 5 +-
.../ca/uhn/fhir/rest/server/CorsTest.java | 7 +-
.../ca/uhn/fhir/rest/server/CreateTest.java | 102 ++---
.../uhn/fhir/rest/server/CustomTypeTest.java | 2 +-
.../rest/server/DateRangeParamSearchTest.java | 6 +-
.../fhir/rest/server/DefaultEncodingTest.java | 6 +-
.../ca/uhn/fhir/rest/server/DestroyTest.java | 137 +++----
.../fhir/rest/server/DynamicSearchTest.java | 4 +-
.../uhn/fhir/rest/server/ExceptionTest.java | 4 +-
.../ca/uhn/fhir/rest/server/HistoryTest.java | 220 +++++------
.../ca/uhn/fhir/rest/server/IncludeTest.java | 158 ++++----
.../uhn/fhir/rest/server/InterceptorTest.java | 4 +-
.../fhir/rest/server/MethodPriorityTest.java | 5 +-
.../ca/uhn/fhir/rest/server/PagingTest.java | 5 +-
.../fhir/rest/server/PlainProviderTest.java | 15 +-
.../{ReadTest.java => ReadDstu1Test.java} | 18 +-
.../rest/server/ReferenceParameterTest.java | 7 +-
.../fhir/rest/server/ResourceMethodTest.java | 2 +-
.../ResourceProviderWithNoMethodsTest.java | 8 +-
.../rest/server/RestfulServerMethodTest.java | 18 +-
.../RestfulServerSelfReferenceTest.java | 4 +-
....java => SearchSearchServerDstu1Test.java} | 6 +-
.../uhn/fhir/rest/server/ServerBaseTest.java | 2 +-
.../server/ServerConformanceProviderTest.java | 18 +-
.../server/ServerExtraParametersTest.java | 11 +-
.../fhir/rest/server/ServerFeaturesTest.java | 6 +-
.../server/ServerInvalidDefinitionTest.java | 20 +-
.../ServerProvidedResourceScannerTest.java | 24 +-
.../ca/uhn/fhir/rest/server/SortTest.java | 16 +-
.../fhir/rest/server/StringParameterTest.java | 152 ++++----
.../uhn/fhir/rest/server/TagsServerTest.java | 2 +-
.../uhn/fhir/rest/server/TransactionTest.java | 10 +-
.../TransactionWithBundleParamTest.java | 6 +-
.../ca/uhn/fhir/rest/server/UpdateTest.java | 38 +-
.../fhir/rest/server/ValidateDstu1Test.java | 8 +-
.../interceptor/AuditingInterceptorTest.java | 4 +-
.../ExceptionHandlingInterceptorTest.java | 4 +-
.../ExceptionInterceptorMethodTest.java | 6 +-
.../java/ca/uhn/fhir/util/FhirTerserTest.java | 6 +-
.../validation/ResourceValidatorTest.java | 2 +-
...st.java => ValidationResultDstu1Test.java} | 2 +-
.../validation/ValidatorInstantiatorTest.java | 4 +-
.../src/test/resources/logback-test.xml | 4 +-
.../narrative/customnarrative.properties | 2 +-
hapi-fhir-structures-dstu2/.gitignore | 3 +
hapi-fhir-structures-dstu2/pom.xml | 2 +-
.../test/java/ca/uhn/fhir/Dstu2EnvTest.java | 17 -
...Test.java => BaseDateTimeDtDstu2Test.java} | 4 +-
...ThymeleafNarrativeGeneratorDstu2Test.java} | 4 +-
...ThymeleafNarrativeGeneratorDstu2Test.java} | 7 +-
...tThymeleafNarrativeGeneratorTestDstu2.java | 9 +-
.../uhn/fhir/parser/JsonParserDstu2Test.java | 12 +-
...TypeTest.java => BundleTypeDstu2Test.java} | 13 +-
...ientTest.java => ETagClientDstu2Test.java} | 4 +-
...est.java => OperationClientDstu2Test.java} | 4 +-
.../uhn/fhir/rest/server/BinaryTestDstu2.java | 4 +-
.../rest/server/BundleTypeInResponseTest.java | 4 +-
.../rest/server/CreateConditionalTest.java | 7 +-
.../rest/server/DeleteConditionalTest.java | 5 +-
.../uhn/fhir/rest/server/ETagServerTest.java | 2 +-
.../IncludeAndRevincludeParameterTest.java | 5 +-
.../fhir/rest/server/IncludeDstu2Test.java | 5 +-
.../fhir/rest/server/OperationServerTest.java | 2 +-
.../ca/uhn/fhir/rest/server/PreferTest.java | 6 +-
.../{ReadTest.java => ReadDstu2Test.java} | 9 +-
.../uhn/fhir/rest/server/SearchDstu2Test.java | 4 +-
.../server/SearchWithDstu2BundleTest.java | 5 +-
.../ServerConformanceProviderDstu2Test.java | 26 +-
.../ServerInvalidDefinitionDstu2Test.java | 2 +-
...ransactionWithBundleResourceParamTest.java | 6 +-
.../rest/server/UpdateConditionalTest.java | 8 +-
.../fhir/rest/server/ValidateDstu2Test.java | 14 +-
....java => LoggingInterceptorDstu2Test.java} | 8 +-
.../dstu2/Dstu2BundleFactoryTest.java | 5 +-
.../ca/uhn/fhir/util/FhirTerserDstu2Test.java | 2 +-
...st.java => ValidationResultDstu2Test.java} | 2 +-
...va => ValidatorInstantiatorDstu2Test.java} | 6 +-
.../src/test/resources/logback-test.xml | 4 +-
...actitioner.html => PractitionerDstu2.html} | 0
...rties => customnarrative_dstu2.properties} | 4 +-
hapi-fhir-structures-hl7org-dstu2/.gitignore | 1 +
.../java/ca/uhn/fhir/model/IdTypeTest.java | 2 +-
.../uhn/fhir/parser/JsonParserHl7OrgTest.java | 26 +-
...nization.java => MyOrganizationDstu2.java} | 2 +-
.../{MyPatient.java => MyPatientHl7Org.java} | 4 +-
.../fhir/parser/XmlParserHl7OrgDstu2Test.java | 6 +-
...lientServerValidationTestHl7OrgDstu2.java} | 4 +-
.../uhn/fhir/rest/client/ETagClientTest.java | 2 +-
hapi-fhir-testconsolidated/pom.xml | 366 ++++++++++++++++++
pom.xml | 20 +-
.../test/java/ca/uhn/example/ExampleTest.java | 2 +-
.../servlet/ExampleRestfulServlet.java | 9 +-
148 files changed, 1279 insertions(+), 896 deletions(-)
rename hapi-fhir-jpaserver-base/src/test/resources/{bundle.json => bundle-dstu2.json} (100%)
delete mode 100644 hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/Dstu1EnvTest.java
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/{FhirContextTest.java => FhirContextDstu1Test.java} (81%)
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/{ClientTest.java => ClientDstu1Test.java} (94%)
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/{SearchTest.java => SearchClientDstu1Test.java} (99%)
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/{ReadTest.java => ReadDstu1Test.java} (96%)
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/{SearchTest.java => SearchSearchServerDstu1Test.java} (99%)
rename hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/{ValidationResultTest.java => ValidationResultDstu1Test.java} (98%)
delete mode 100644 hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/Dstu2EnvTest.java
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/{BaseDateTimeDtTest.java => BaseDateTimeDtDstu2Test.java} (96%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/{BaseThymeleafNarrativeGeneratorTest.java => BaseThymeleafNarrativeGeneratorDstu2Test.java} (93%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/{CustomThymeleafNarrativeGeneratorTest.java => CustomThymeleafNarrativeGeneratorDstu2Test.java} (77%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/{BundleTypeTest.java => BundleTypeDstu2Test.java} (88%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/{ETagClientTest.java => ETagClientDstu2Test.java} (99%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/{OperationClientTest.java => OperationClientDstu2Test.java} (99%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/{ReadTest.java => ReadDstu2Test.java} (96%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/{LoggingInterceptorTest.java => LoggingInterceptorDstu2Test.java} (98%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/{ValidationResultTest.java => ValidationResultDstu2Test.java} (98%)
rename hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/{ValidatorInstantiatorTest.java => ValidatorInstantiatorDstu2Test.java} (71%)
rename hapi-fhir-structures-dstu2/src/test/resources/narrative/{Practitioner.html => PractitionerDstu2.html} (100%)
rename hapi-fhir-structures-dstu2/src/test/resources/narrative/{customnarrative.properties => customnarrative_dstu2.properties} (78%)
rename hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/{MyOrganization.java => MyOrganizationDstu2.java} (78%)
rename hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/{MyPatient.java => MyPatientHl7Org.java} (96%)
rename hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/{ClientServerValidationTestDstu2.java => ClientServerValidationTestHl7OrgDstu2.java} (98%)
create mode 100644 hapi-fhir-testconsolidated/pom.xml
diff --git a/.travis.yml b/.travis.yml
index a98b7603500..fbd6c31bf41 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,2 +1,7 @@
language: java
+jdk:
+ - oraclejdk6
+
+install: mvn clean install -Dcobertura.skip=true
+script: mvn -P COBERTURA clean cobertura:cobertura
diff --git a/examples/src/main/java/example/ClientExamples.java b/examples/src/main/java/example/ClientExamples.java
index 7631f07c514..5725e8b161c 100644
--- a/examples/src/main/java/example/ClientExamples.java
+++ b/examples/src/main/java/example/ClientExamples.java
@@ -19,7 +19,7 @@ public class ClientExamples {
@SuppressWarnings("unused")
public void createProxy() {
// START SNIPPET: proxy
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
// Set connections to access the network via the HTTP proxy at
// example.com : 8888
@@ -36,7 +36,7 @@ public class ClientExamples {
@SuppressWarnings("unused")
public void createTimeouts() {
// START SNIPPET: timeouts
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
// Set how long to try and establish the initial TCP connection (in ms)
ctx.getRestfulClientFactory().setConnectTimeout(20 * 1000);
@@ -53,7 +53,7 @@ public class ClientExamples {
public void createSecurity() {
// START SNIPPET: security
// Create a context and get the client factory so it can be configured
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// Create an HTTP basic auth interceptor
@@ -74,7 +74,7 @@ public class ClientExamples {
public void createCookie() {
// START SNIPPET: cookie
// Create a context and get the client factory so it can be configured
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// Create a cookie interceptor. This cookie will have the name "mycookie" and
@@ -95,7 +95,7 @@ public class ClientExamples {
public void createSecurityBearer() {
// START SNIPPET: securityBearer
// Create a context and get the client factory so it can be configured
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// In reality the token would have come from an authorization server
@@ -117,7 +117,7 @@ public class ClientExamples {
{
// START SNIPPET: logging
// Create a context and get the client factory so it can be configured
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
IRestfulClientFactory clientFactory = ctx.getRestfulClientFactory();
// Create a logging interceptor
@@ -141,7 +141,7 @@ public class ClientExamples {
{
// START SNIPPET: clientConfig
// Create a client
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
IPatientClient client = ctx.newRestfulClient(IPatientClient.class, "http://localhost:9999/");
// Request JSON encoding from the server (_format=json)
diff --git a/examples/src/main/java/example/CompleteExampleClient.java b/examples/src/main/java/example/CompleteExampleClient.java
index 9ac8526c13b..b58a0b47351 100644
--- a/examples/src/main/java/example/CompleteExampleClient.java
+++ b/examples/src/main/java/example/CompleteExampleClient.java
@@ -37,7 +37,7 @@ public class CompleteExampleClient {
public static void main(String[] args) throws IOException {
// Create a client factory
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
// Create the client
String serverBase = "http://fhir.healthintersections.com.au/open";
diff --git a/examples/src/main/java/example/ExampleRestfulClient.java b/examples/src/main/java/example/ExampleRestfulClient.java
index 3995b0e1082..16e05c2304e 100644
--- a/examples/src/main/java/example/ExampleRestfulClient.java
+++ b/examples/src/main/java/example/ExampleRestfulClient.java
@@ -11,7 +11,7 @@ public class ExampleRestfulClient {
//START SNIPPET: client
public static void main(String[] args) {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
String serverBase = "http://foo.com/fhirServerBase";
// Create the client
diff --git a/examples/src/main/java/example/Extensions.java b/examples/src/main/java/example/Extensions.java
index ea7fdde2d1c..3506f2af5a5 100644
--- a/examples/src/main/java/example/Extensions.java
+++ b/examples/src/main/java/example/Extensions.java
@@ -49,7 +49,8 @@ ExtensionDt givenExt = new ExtensionDt(false, "http://examples.com#moreext", new
given.addUndeclaredExtension(givenExt);
//END SNIPPET: resourceStringExtension
-String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
+FhirContext ctx = FhirContext.forDstu2();
+String output = ctx.newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
System.out.println(output);
diff --git a/examples/src/main/java/example/HttpProxy.java b/examples/src/main/java/example/HttpProxy.java
index 73348773488..866d0a6f882 100644
--- a/examples/src/main/java/example/HttpProxy.java
+++ b/examples/src/main/java/example/HttpProxy.java
@@ -39,7 +39,7 @@ public class HttpProxy {
.disableCookieManagement();
CloseableHttpClient httpClient = clientBuilder.build();
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
String serverBase = "http://spark.furore.com/fhir/";
ctx.getRestfulClientFactory().setHttpClient(httpClient);
IGenericClient client = ctx.newRestfulGenericClient(serverBase);
diff --git a/examples/src/main/java/example/MyPatientUse.java b/examples/src/main/java/example/MyPatientUse.java
index 3e973a3707e..548555eb4f5 100644
--- a/examples/src/main/java/example/MyPatientUse.java
+++ b/examples/src/main/java/example/MyPatientUse.java
@@ -65,19 +65,19 @@ patient.getImportantDates().add(new DateTimeDt("2014-01-26T11:11:11"));
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
-IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
+IParser p = FhirContext.forDstu2().newXmlParser().setPrettyPrint(true);
String messageString = p.encodeResourceToString(patient);
System.out.println(messageString);
//END SNIPPET: patientUse
//START SNIPPET: patientParse
-IParser parser = new FhirContext().newXmlParser();
+IParser parser = FhirContext.forDstu2().newXmlParser();
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
//END SNIPPET: patientParse
{
- FhirContext ctx2 = new FhirContext();
+ FhirContext ctx2 = FhirContext.forDstu2();
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile()));
}
diff --git a/examples/src/main/java/example/Narrative.java b/examples/src/main/java/example/Narrative.java
index 1acd6b3b06a..d43ad1c976c 100644
--- a/examples/src/main/java/example/Narrative.java
+++ b/examples/src/main/java/example/Narrative.java
@@ -18,7 +18,7 @@ patient.addIdentifier().setSystem("urn:foo").setValue("7000135");
patient.addName().addFamily("Smith").addGiven("John").addGiven("Edward");
patient.addAddress().addLine("742 Evergreen Terrace").setCity("Springfield").setState("ZZ");
-FhirContext ctx = new FhirContext();
+FhirContext ctx = FhirContext.forDstu2();
// Use the narrative generator
ctx.setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
diff --git a/examples/src/main/java/example/NarrativeGenerator.java b/examples/src/main/java/example/NarrativeGenerator.java
index 997a26b8b57..e4bbd00e4f5 100644
--- a/examples/src/main/java/example/NarrativeGenerator.java
+++ b/examples/src/main/java/example/NarrativeGenerator.java
@@ -16,7 +16,7 @@ public class NarrativeGenerator {
String propFile = "classpath:/com/foo/customnarrative.properties";
CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator(propFile);
-FhirContext ctx = new FhirContext();
+FhirContext ctx = FhirContext.forDstu2();
ctx.setNarrativeGenerator(gen);
//END SNIPPET: gen
diff --git a/examples/src/main/java/example/QuickUsage.java b/examples/src/main/java/example/QuickUsage.java
index 06b39a00ed6..fffa88ed80f 100644
--- a/examples/src/main/java/example/QuickUsage.java
+++ b/examples/src/main/java/example/QuickUsage.java
@@ -30,7 +30,7 @@ patient.addName().addFamily("Smith").addGiven("John").addGiven("Q").addSuffix("J
patient.setGender(AdministrativeGenderEnum.MALE);
-FhirContext ctx = new FhirContext();
+FhirContext ctx = FhirContext.forDstu2();
String xmlEncoded = ctx.newXmlParser().encodeResourceToString(patient);
String jsonEncoded = ctx.newJsonParser().encodeResourceToString(patient);
diff --git a/examples/src/main/java/example/ResourceRefs.java b/examples/src/main/java/example/ResourceRefs.java
index 102db3a5392..b5d81d41595 100644
--- a/examples/src/main/java/example/ResourceRefs.java
+++ b/examples/src/main/java/example/ResourceRefs.java
@@ -6,7 +6,7 @@ import ca.uhn.fhir.model.dstu2.resource.Patient;
public class ResourceRefs {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
public static void main(String[] args) {
manualContained();
diff --git a/examples/src/main/java/example/RestfulPatientResourceProviderMore.java b/examples/src/main/java/example/RestfulPatientResourceProviderMore.java
index 662ca2691d6..fceb09d8f97 100644
--- a/examples/src/main/java/example/RestfulPatientResourceProviderMore.java
+++ b/examples/src/main/java/example/RestfulPatientResourceProviderMore.java
@@ -933,7 +933,7 @@ public interface HistoryClient extends IBasicClient {
public void bbbbb() throws DataFormatException, IOException {
//START SNIPPET: metadataClientUsage
-FhirContext ctx = new FhirContext();
+FhirContext ctx = FhirContext.forDstu2();
MetadataClient client = ctx.newRestfulClient(MetadataClient.class, "http://spark.furore.com/fhir");
Conformance metadata = client.getServerMetadata();
System.out.println(ctx.newXmlParser().encodeResourceToString(metadata));
@@ -973,7 +973,7 @@ private interface IPatientClient extends IBasicClient
public void clientRead() {
//START SNIPPET: clientReadTags
-IPatientClient client = new FhirContext().newRestfulClient(IPatientClient.class, "http://foo/fhir");
+IPatientClient client = FhirContext.forDstu2().newRestfulClient(IPatientClient.class, "http://foo/fhir");
Patient patient = client.readPatient(new IdDt("1234"));
// Access the tag list
diff --git a/examples/src/main/java/example/ServerInterceptors.java b/examples/src/main/java/example/ServerInterceptors.java
index 9f72c18dab6..fdfc5311ba4 100644
--- a/examples/src/main/java/example/ServerInterceptors.java
+++ b/examples/src/main/java/example/ServerInterceptors.java
@@ -43,7 +43,7 @@ ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#moreext", new Str
given.addUndeclaredExtension(ext2);
//END SNIPPET: resourceStringExtension
-String output = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
+String output = FhirContext.forDstu2().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient);
System.out.println(output);
diff --git a/examples/src/main/java/example/TagsExamples.java b/examples/src/main/java/example/TagsExamples.java
index 57bbdce0c74..5619c9422f8 100644
--- a/examples/src/main/java/example/TagsExamples.java
+++ b/examples/src/main/java/example/TagsExamples.java
@@ -20,7 +20,7 @@ public class TagsExamples {
@SuppressWarnings("unused")
public void getResourceTags() {
// START SNIPPET: getResourceTags
- IGenericClient client = new FhirContext().newRestfulGenericClient("http://fhir.healthintersections.com.au/open");
+ IGenericClient client = FhirContext.forDstu2().newRestfulGenericClient("http://fhir.healthintersections.com.au/open");
Patient p = client.read(Patient.class, "1");
// Retrieve the list of tags from the resource metadata
diff --git a/examples/src/main/java/example/ValidatorExamples.java b/examples/src/main/java/example/ValidatorExamples.java
index 1a901ccd553..e4ff8725c6e 100644
--- a/examples/src/main/java/example/ValidatorExamples.java
+++ b/examples/src/main/java/example/ValidatorExamples.java
@@ -37,7 +37,7 @@ public class ValidatorExamples {
public void validateResource() {
// START SNIPPET: basicValidation
// As always, you need a context
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
// Create and populate a new patient object
Patient p = new Patient();
@@ -73,7 +73,7 @@ public class ValidatorExamples {
private static void validateFiles() throws Exception {
// START SNIPPET: validateFiles
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu2();
// Create a validator and configure it
FhirValidator validator = ctx.newValidator();
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java
index c6d0dd879a5..43c84b6990e 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGenerator.java
@@ -292,6 +292,7 @@ public abstract class BaseThymeleafNarrativeGenerator implements INarrativeGener
loadProperties(next);
}
} catch (IOException e) {
+ ourLog.info("Failed to load property file " + propFileName, e);
throw new ConfigurationException("Can not load property file " + propFileName, e);
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
index 702c257b55e..660406cd236 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/RestfulServer.java
@@ -103,12 +103,18 @@ public class RestfulServer extends HttpServlet {
private boolean myUseBrowserFriendlyContentTypes;
/**
- * Constructor
+ * Constructor. Note that if no {@link FhirContext} is passed in to the server (either through the constructor, or
+ * through {@link #setFhirContext(FhirContext)}) the server will determine which version of FHIR to support
+ * through classpath scanning. This is brittle, and it is highly recommended to explicitly specify
+ * a FHIR version.
*/
public RestfulServer() {
- this(new FhirContext());
+ this(null);
}
+ /**
+ * Constructor
+ */
public RestfulServer(FhirContext theCtx) {
myFhirContext = theCtx;
}
@@ -200,7 +206,7 @@ public class RestfulServer extends HttpServlet {
int count = 0;
for (Method m : ReflectionUtil.getDeclaredMethods(clazz)) {
- BaseMethodBinding> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theProvider);
+ BaseMethodBinding> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theProvider);
if (foundMethodBinding == null) {
continue;
}
@@ -220,7 +226,7 @@ public class RestfulServer extends HttpServlet {
if (resourceName == null) {
resourceBinding = myServerBinding;
} else {
- RuntimeResourceDefinition definition = myFhirContext.getResourceDefinition(resourceName);
+ RuntimeResourceDefinition definition = getFhirContext().getResourceDefinition(resourceName);
if (myResourceNameToProvider.containsKey(definition.getName())) {
resourceBinding = myResourceNameToProvider.get(definition.getName());
} else {
@@ -270,7 +276,7 @@ public class RestfulServer extends HttpServlet {
if (Modifier.isPublic(m.getModifiers())) {
ourLog.debug("Scanning public method: {}#{}", theSystemProvider.getClass(), m.getName());
- BaseMethodBinding> foundMethodBinding = BaseMethodBinding.bindMethod(m, myFhirContext, theSystemProvider);
+ BaseMethodBinding> foundMethodBinding = BaseMethodBinding.bindMethod(m, getFhirContext(), theSystemProvider);
if (foundMethodBinding != null) {
if (foundMethodBinding instanceof ConformanceMethodBinding) {
myServerConformanceMethod = foundMethodBinding;
@@ -318,6 +324,9 @@ public class RestfulServer extends HttpServlet {
* creating their own.
*/
public FhirContext getFhirContext() {
+ if (myFhirContext == null) {
+ myFhirContext = new FhirContext();
+ }
return myFhirContext;
}
@@ -419,7 +428,7 @@ public class RestfulServer extends HttpServlet {
}
public IResourceProvider getServerProfilesProvider() {
- return myFhirContext.getVersion().createServerProfilesProvider(this);
+ return getFhirContext().getVersion().createServerProfilesProvider(this);
}
/**
@@ -462,7 +471,7 @@ public class RestfulServer extends HttpServlet {
NarrativeModeEnum narrativeMode = RestfulServerUtils.determineNarrativeMode(theRequest);
boolean respondGzip = theRequest.isRespondGzip();
- IVersionSpecificBundleFactory bundleFactory = myFhirContext.newBundleFactory();
+ IVersionSpecificBundleFactory bundleFactory = getFhirContext().newBundleFactory();
Set includes = new HashSet();
String[] reqIncludes = theRequest.getServletRequest().getParameterValues(Constants.PARAM_INCLUDE);
@@ -765,7 +774,7 @@ public class RestfulServer extends HttpServlet {
throw new NullPointerException("getResourceType() on class '" + nextProvider.getClass().getCanonicalName() + "' returned null");
}
- String resourceName = myFhirContext.getResourceDefinition(resourceType).getName();
+ String resourceName = getFhirContext().getResourceDefinition(resourceType).getName();
if (typeToProvider.containsKey(resourceName)) {
throw new ServletException("Multiple resource providers return resource type[" + resourceName + "]: First[" + typeToProvider.get(resourceName).getClass().getCanonicalName()
+ "] and Second[" + nextProvider.getClass().getCanonicalName() + "]");
@@ -792,7 +801,7 @@ public class RestfulServer extends HttpServlet {
Object confProvider = getServerConformanceProvider();
if (confProvider == null) {
- confProvider = myFhirContext.getVersion().createServerConformanceProvider(this);
+ confProvider = getFhirContext().getVersion().createServerConformanceProvider(this);
}
findSystemMethods(confProvider);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
index 7fbccf64244..d705d64e0ba 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
@@ -54,7 +54,7 @@ public class ResourceProviderDstu1Test {
private static ClassPathXmlApplicationContext ourAppCtx;
private static IGenericClient ourClient;
private static DaoConfig ourDaoConfig;
- private static FhirContext ourFhirCtx;
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu1Test.class);
private static IFhirResourceDao ourOrganizationDao;
// private static IFhirResourceDao ourObservationDao;
@@ -405,14 +405,14 @@ public class ResourceProviderDstu1Test {
// Read back directly from the DAO
{
Organization returned = ourOrganizationDao.read(orgId);
- String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
+ String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
ourLog.info(val);
assertThat(val, containsString(""));
}
// Read back through the HTTP API
{
Organization returned = ourClient.read(Organization.class, orgId);
- String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
+ String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
ourLog.info(val);
assertThat(val, containsString(""));
}
@@ -492,9 +492,7 @@ public class ResourceProviderDstu1Test {
public static void beforeClass() throws Exception {
int port = RandomServerPortProvider.findFreePort();
- RestfulServer restServer = new RestfulServer();
- ourFhirCtx = FhirContext.forDstu1();
- restServer.setFhirContext(ourFhirCtx);
+ RestfulServer restServer = new RestfulServer(ourCtx);
String serverBase = "http://localhost:" + port + "/fhir/context";
@@ -526,7 +524,7 @@ public class ResourceProviderDstu1Test {
ourServer.setHandler(proxyHandler);
ourServer.start();
- ourClient = ourFhirCtx.newRestfulGenericClient(serverBase);
+ ourClient = ourCtx.newRestfulGenericClient(serverBase);
ourClient.registerInterceptor(new LoggingInterceptor(true));
}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
index 364bd91e5f4..dc66f2dafae 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
@@ -101,7 +101,7 @@ public class ResourceProviderDstu2Test {
private static ClassPathXmlApplicationContext ourAppCtx;
private static IGenericClient ourClient;
private static DaoConfig ourDaoConfig;
- private static FhirContext ourFhirCtx;
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static CloseableHttpClient ourHttpClient;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceProviderDstu2Test.class);
private static IFhirResourceDao ourOrganizationDao;
@@ -148,7 +148,7 @@ public class ResourceProviderDstu2Test {
ca.uhn.fhir.model.dstu2.resource.Bundle bundle = client.read().resource(ca.uhn.fhir.model.dstu2.resource.Bundle.class).withId(id).execute();
- ourLog.info(ourFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
+ ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(bundle));
}
@Test
@@ -194,7 +194,7 @@ public class ResourceProviderDstu2Test {
Patient pt = new Patient();
pt.addName().addFamily(methodName);
- String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
+ String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
post.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?name=" + methodName);
@@ -284,7 +284,7 @@ public class ResourceProviderDstu2Test {
Patient pt = new Patient();
pt.addName().addFamily(methodName);
- String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
+ String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
@@ -328,7 +328,7 @@ public class ResourceProviderDstu2Test {
Patient pt = new Patient();
pt.addName().addFamily(methodName);
pt.addIdentifier().setSystem("http://ghh.org/patient").setValue(methodName);
- String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
+ String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient");
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
@@ -409,8 +409,8 @@ public class ResourceProviderDstu2Test {
*/
@Test
public void testDocumentManifestResources() throws Exception {
- ourFhirCtx.getResourceDefinition(Practitioner.class);
- ourFhirCtx.getResourceDefinition(ca.uhn.fhir.model.dstu.resource.DocumentManifest.class);
+ ourCtx.getResourceDefinition(Practitioner.class);
+ ourCtx.getResourceDefinition(ca.uhn.fhir.model.dstu.resource.DocumentManifest.class);
IGenericClient client = ourClient;
@@ -449,7 +449,7 @@ public class ResourceProviderDstu2Test {
@Test
public void testEverythingDoesntRepeatPatient() throws Exception {
ca.uhn.fhir.model.dstu2.resource.Bundle b;
- b = ourFhirCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json")));
+ b = ourCtx.newJsonParser().parseResource(ca.uhn.fhir.model.dstu2.resource.Bundle.class, new InputStreamReader(ResourceProviderDstu2Test.class.getResourceAsStream("/bug147-bundle.json")));
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
List ids = new ArrayList();
@@ -518,7 +518,7 @@ public class ResourceProviderDstu2Test {
ca.uhn.fhir.model.dstu2.resource.Bundle resp = ourClient.transaction().withBundle(b).execute();
- ourLog.info(ourFhirCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
+ ourLog.info(ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(resp));
IdDt patientId = new IdDt(resp.getEntry().get(1).getTransactionResponse().getLocation());
assertEquals("Patient", patientId.getResourceType());
@@ -874,14 +874,14 @@ public class ResourceProviderDstu2Test {
// Read back directly from the DAO
{
Organization returned = ourOrganizationDao.read(orgId);
- String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
+ String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
ourLog.info(val);
assertThat(val, containsString(""));
}
// Read back through the HTTP API
{
Organization returned = ourClient.read(Organization.class, orgId);
- String val = ourFhirCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
+ String val = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(returned);
ourLog.info(val);
assertThat(val, containsString(""));
}
@@ -938,7 +938,7 @@ public class ResourceProviderDstu2Test {
Patient pt = new Patient();
pt.addName().addFamily(methodName);
- String resource = ourFhirCtx.newXmlParser().encodeResourceToString(pt);
+ String resource = ourCtx.newXmlParser().encodeResourceToString(pt);
HttpPost post = new HttpPost(ourServerBase + "/Patient?name=" + methodName);
post.setEntity(new StringEntity(resource, ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
@@ -996,7 +996,7 @@ public class ResourceProviderDstu2Test {
Parameters input = new Parameters();
input.addParameter().setName("resource").setResource(patient);
- String inputStr = ourFhirCtx.newXmlParser().encodeResourceToString(input);
+ String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
ourLog.info(inputStr);
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
@@ -1024,7 +1024,7 @@ public class ResourceProviderDstu2Test {
Parameters input = new Parameters();
input.addParameter().setName("resource").setResource(patient);
- String inputStr = ourFhirCtx.newXmlParser().encodeResourceToString(input);
+ String inputStr = ourCtx.newXmlParser().encodeResourceToString(input);
ourLog.info(inputStr);
HttpPost post = new HttpPost(ourServerBase + "/Patient/$validate");
@@ -1061,9 +1061,8 @@ public class ResourceProviderDstu2Test {
public static void beforeClass() throws Exception {
ourPort = RandomServerPortProvider.findFreePort();
- RestfulServer restServer = new RestfulServer();
- ourFhirCtx = FhirContext.forDstu2();
- restServer.setFhirContext(ourFhirCtx);
+ RestfulServer restServer = new RestfulServer(ourCtx);
+ restServer.setFhirContext(ourCtx);
ourServerBase = "http://localhost:" + ourPort + "/fhir/context";
@@ -1095,9 +1094,9 @@ public class ResourceProviderDstu2Test {
ourServer.setHandler(proxyHandler);
ourServer.start();
- ourFhirCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
- ourFhirCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
- ourClient = ourFhirCtx.newRestfulGenericClient(ourServerBase);
+ ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
+ ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
+ ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
// ourClient.registerInterceptor(new LoggingInterceptor(true));
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
index 3c8144fcd03..b5bfd1dcbc1 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
@@ -139,8 +139,7 @@ public class ResourceProviderMultiVersionTest {
* DEV resources
*/
- RestfulServer restServerDstu2 = new RestfulServer();
- restServerDstu2.setFhirContext(ourAppCtx.getBean("myFhirContextDstu2", FhirContext.class));
+ RestfulServer restServerDstu2 = new RestfulServer(ourAppCtx.getBean("myFhirContextDstu2", FhirContext.class));
List rpsDstu2 = (List) ourAppCtx.getBean("myResourceProvidersDstu2", List.class);
restServerDstu2.setResourceProviders(rpsDstu2);
@@ -155,8 +154,7 @@ public class ResourceProviderMultiVersionTest {
* DSTU resources
*/
- RestfulServer restServerDstu1 = new RestfulServer();
- restServerDstu1.setFhirContext(ourAppCtx.getBean("myFhirContextDstu1", FhirContext.class));
+ RestfulServer restServerDstu1 = new RestfulServer(ourAppCtx.getBean("myFhirContextDstu1", FhirContext.class));
List rpsDstu1 = (List) ourAppCtx.getBean("myResourceProvidersDstu1", List.class);
restServerDstu1.setResourceProviders(rpsDstu1);
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
index 1e72a5df471..58b03c85ad0 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
@@ -89,7 +89,7 @@ public class SystemProviderDstu1Test {
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
organizationRp.setDao(organizationDao);
- RestfulServer restServer = new RestfulServer();
+ RestfulServer restServer = new RestfulServer(ourCtx);
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
JpaSystemProviderDstu1 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu1.class, "mySystemProviderDstu1");
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
index 0c8cecc473c..1a6ba0c4fdf 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
@@ -122,7 +122,7 @@ public class SystemProviderDstu2Test {
OrganizationResourceProvider organizationRp = new OrganizationResourceProvider();
organizationRp.setDao(organizationDao);
- RestfulServer restServer = new RestfulServer();
+ RestfulServer restServer = new RestfulServer(ourCtx);
restServer.setResourceProviders(patientRp, questionnaireRp, observationRp, organizationRp);
JpaSystemProviderDstu2 systemProv = ourAppCtx.getBean(JpaSystemProviderDstu2.class, "mySystemProviderDstu2");
diff --git a/hapi-fhir-jpaserver-base/src/test/resources/bundle.json b/hapi-fhir-jpaserver-base/src/test/resources/bundle-dstu2.json
similarity index 100%
rename from hapi-fhir-jpaserver-base/src/test/resources/bundle.json
rename to hapi-fhir-jpaserver-base/src/test/resources/bundle-dstu2.json
diff --git a/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml b/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
index 929b7f34772..658cd6bad1c 100644
--- a/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
+++ b/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
@@ -14,7 +14,7 @@
-
+
@@ -26,4 +26,4 @@
-
\ No newline at end of file
+
diff --git a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java
index 760059631e1..b4a7da3d8e3 100644
--- a/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java
+++ b/hapi-fhir-jpaserver-uhnfhirtest/src/main/java/ca/uhn/fhirtest/FhirContextFactory.java
@@ -7,9 +7,10 @@ import ca.uhn.fhir.context.FhirContext;
public class FhirContextFactory implements FactoryBean, InitializingBean {
- private int myConnectionRequestTimeout = 5000;
- private int mySocketTimeout = 10000;
+ private int myConnectionRequestTimeout = 5000;
+ private int mySocketTimeout = 10000;
private int myConnectTimeout = 4000;
+
public int getConnectionRequestTimeout() {
return myConnectionRequestTimeout;
}
@@ -36,9 +37,9 @@ public class FhirContextFactory implements FactoryBean, Initializin
private FhirContext myCtx;
- public FhirContextFactory() {
+ public FhirContextFactory() {
}
-
+
@Override
public FhirContext getObject() throws Exception {
return myCtx;
@@ -56,7 +57,7 @@ public class FhirContextFactory implements FactoryBean, Initializin
@Override
public void afterPropertiesSet() throws Exception {
- myCtx=new FhirContext();
+ myCtx = new FhirContext();
myCtx.getRestfulClientFactory().setConnectTimeout(myConnectTimeout);
myCtx.getRestfulClientFactory().setSocketTimeout(mySocketTimeout);
myCtx.getRestfulClientFactory().setConnectionRequestTimeout(myConnectionRequestTimeout);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/Dstu1EnvTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/Dstu1EnvTest.java
deleted file mode 100644
index 594c887c060..00000000000
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/Dstu1EnvTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package ca.uhn.fhir;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.context.FhirVersionEnum;
-
-public class Dstu1EnvTest {
-
- @Test
- public void testCorrectDefault() {
- FhirContext ctx = new FhirContext();
- assertEquals("new FhirContext() is creating a context with the wrong FHIR versions. Something is probably wrong with the classpath.", FhirVersionEnum.DSTU1, ctx.getVersion().getVersion());
- }
-}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java
index 6cc134e97df..8faee32d8c6 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/DuplicateExtensionTest.java
@@ -23,7 +23,7 @@ public class DuplicateExtensionTest extends TestCase {
@Test
public void testScannerShouldAddProvidedResources() {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
RuntimeResourceDefinition patientDef = ctx.getResourceDefinition(CustomPatient.class);
Profile profile = (Profile) patientDef.toProfile("http://foo.org/fhir");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ExtensionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ExtensionTest.java
index 706c2331bc7..94c0f601ce7 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ExtensionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ExtensionTest.java
@@ -16,7 +16,7 @@ import ca.uhn.fhir.parser.MyPatient;
public class ExtensionTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExtensionTest.class);
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testExtensionType() {
@@ -66,19 +66,19 @@ public class ExtensionTest {
patient.addName().addFamily("Smith").addGiven("John").addGiven("Quincy").addSuffix("Jr");
- IParser p = new FhirContext().newXmlParser().setPrettyPrint(true);
+ IParser p = FhirContext.forDstu1().newXmlParser().setPrettyPrint(true);
String messageString = p.encodeResourceToString(patient);
System.out.println(messageString);
// END SNIPPET: patientUse
// START SNIPPET: patientParse
- IParser parser = new FhirContext().newXmlParser();
+ IParser parser = FhirContext.forDstu1().newXmlParser();
MyPatient newPatient = parser.parseResource(MyPatient.class, messageString);
// END SNIPPET: patientParse
{
- FhirContext ctx2 = new FhirContext();
+ FhirContext ctx2 = FhirContext.forDstu1();
RuntimeResourceDefinition def = ctx2.getResourceDefinition(patient);
System.out.println(ctx2.newXmlParser().setPrettyPrint(true).encodeResourceToString(def.toProfile("http://foo.org/fhir")));
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextDstu1Test.java
similarity index 81%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextDstu1Test.java
index 458e901c468..129be44e0be 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/FhirContextDstu1Test.java
@@ -9,11 +9,11 @@ import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.resource.ValueSet;
-public class FhirContextTest {
+public class FhirContextDstu1Test {
@Test
public void testIncrementalScan() {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
RuntimeResourceDefinition vsDef = ctx.getResourceDefinition(ValueSet.class);
RuntimeResourceDefinition ptDef = ctx.getResourceDefinition(Patient.class);
assertNotNull(ptDef);
@@ -24,13 +24,13 @@ public class FhirContextTest {
@Test
public void testFindBinary() {
- RuntimeResourceDefinition def = new FhirContext().getResourceDefinition("Binary");
+ RuntimeResourceDefinition def = FhirContext.forDstu1().getResourceDefinition("Binary");
assertEquals("Binary", def.getName());
}
@Test(expected = IllegalArgumentException.class)
public void testGetResourceDefinitionFails() {
- new FhirContext().getResourceDefinition(IResource.class);
+ FhirContext.forDstu1().getResourceDefinition(IResource.class);
}
@Test
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/InvalidResourceTypeTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/InvalidResourceTypeTest.java
index 8a941debd4e..ed7a1710031 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/InvalidResourceTypeTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/InvalidResourceTypeTest.java
@@ -10,7 +10,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient;
public class InvalidResourceTypeTest {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testNonInstantiableType() {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelExtensionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelExtensionTest.java
index c45d3f1d51a..fc3a444e58a 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelExtensionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelExtensionTest.java
@@ -11,7 +11,7 @@ import ca.uhn.fhir.parser.MyPatient;
public class ModelExtensionTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelExtensionTest.class);
- private FhirContext ourCtx = new FhirContext();
+ private FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testModelExtension() throws DataFormatException {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java
index a4b05e77941..ad5d7d8e14c 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ModelScannerTest.java
@@ -19,7 +19,7 @@ public class ModelScannerTest {
@Test
public void testExtendedClass() {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
ctx.getResourceDefinition(MyPatient.class);
RuntimeResourceDefinition patient = ctx.getResourceDefinition("Patient");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/NameChanges.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/NameChanges.java
index 809a83ce99b..bc02a244b0d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/NameChanges.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/NameChanges.java
@@ -19,7 +19,7 @@ public class NameChanges {
@SuppressWarnings("unchecked")
@Test
public void testNameChanges() throws IOException, ClassNotFoundException {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
ImmutableSet names = ClassPath.from(getClass().getClassLoader()).getTopLevelClasses(Patient.class.getPackage().getName());
List changes = new ArrayList();
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ProvidedResourceScannerTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ProvidedResourceScannerTest.java
index 36624a98e7a..be4b6320591 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ProvidedResourceScannerTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/context/ProvidedResourceScannerTest.java
@@ -12,7 +12,7 @@ import static org.junit.Assert.assertNull;
public class ProvidedResourceScannerTest extends TestCase {
@Test
public void testScannerShouldAddProvidedResources() {
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
assertEquals(CustomPatient.class, ctx.getElementDefinition(CustomPatient.class).getImplementingClass());
assertEquals(Patient.class, ctx.getResourceDefinition("Patient").getImplementingClass());
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/api/TagListTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/api/TagListTest.java
index bcce42d2a6e..ffc6ae60b70 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/api/TagListTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/api/TagListTest.java
@@ -13,7 +13,7 @@ import ca.uhn.fhir.model.dstu.resource.Patient;
public class TagListTest {
- private FhirContext myCtx = new FhirContext();
+ private FhirContext myCtx = FhirContext.forDstu1();
@Test
public void testEquals() {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java
index b4b8811002f..462f59b8b40 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java
@@ -27,7 +27,7 @@ public class BaseDateTimeDtTest {
private FastDateFormat myDateInstantZoneParser;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtTest.class);
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Before
public void before() {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/IdDtTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/IdDtTest.java
index 13578cf1cf3..46b982203ec 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/IdDtTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/primitive/IdDtTest.java
@@ -206,7 +206,7 @@ public class IdDtTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/view/ViewGeneratorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/view/ViewGeneratorTest.java
index 3ac118379fc..7ed6cf75178 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/view/ViewGeneratorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/model/view/ViewGeneratorTest.java
@@ -14,7 +14,7 @@ import ca.uhn.fhir.parser.IParser;
public class ViewGeneratorTest {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testView() {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTest.java
index 0e2c2c41a74..942202d052d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTest.java
@@ -46,7 +46,7 @@ public class DefaultThymeleafNarrativeGeneratorTest {
gen.setIgnoreFailures(false);
gen.setIgnoreMissingTemplates(false);
- myCtx = new FhirContext();
+ myCtx = FhirContext.forDstu1();
myCtx.setNarrativeGenerator(gen);
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/BaseParserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/BaseParserTest.java
index 8682c7e40f3..f848f9fed03 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/BaseParserTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/BaseParserTest.java
@@ -13,7 +13,7 @@ import ca.uhn.fhir.model.dstu.resource.Composition;
public class BaseParserTest {
- private static final FhirContext ourCtx = new FhirContext();
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseParserTest.class);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/ContainedResourceEncodingTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/ContainedResourceEncodingTest.java
index 254975fc04c..c9a525c2f76 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/ContainedResourceEncodingTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/ContainedResourceEncodingTest.java
@@ -58,7 +58,7 @@ public class ContainedResourceEncodingTest {
initPatient();
initAuthor();
initComposition();
- this.ctx = new FhirContext();
+ this.ctx = FhirContext.forDstu1();
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java
index a67059ccc58..314d2bd0323 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/JsonParserTest.java
@@ -28,6 +28,7 @@ import org.hamcrest.core.IsNot;
import org.hamcrest.core.StringContains;
import org.hamcrest.text.StringContainsInOrder;
import org.hl7.fhir.instance.model.api.IBaseResource;
+import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -294,13 +295,13 @@ public class JsonParserTest {
e.setResource(new Patient());
b.addCategory("scheme", "term", "label");
- String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
+ String val = ourCtx.newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
ourLog.info(val);
assertThat(val, StringContains.containsString("\"category\":[{\"term\":\"term\",\"label\":\"label\",\"scheme\":\"scheme\"}]"));
assertThat(val, not(containsString("text")));
- b = new FhirContext().newJsonParser().parseBundle(val);
+ b = ourCtx.newJsonParser().parseBundle(val);
assertEquals(1, b.getEntries().size());
assertEquals(1, b.getCategories().size());
assertEquals("term", b.getCategories().get(0).getTerm());
@@ -489,7 +490,7 @@ public class JsonParserTest {
@Test
public void testEncodeDeclaredExtensionWithAddressContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension();
patient.addAddress().setUse(AddressUseEnum.HOME);
@@ -508,7 +509,7 @@ public class JsonParserTest {
@Test
public void testEncodeDeclaredExtensionWithResourceContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
MyPatientWithOneDeclaredExtension patient = new MyPatientWithOneDeclaredExtension();
patient.addAddress().setUse(AddressUseEnum.HOME);
@@ -620,7 +621,7 @@ public class JsonParserTest {
@Test
public void testEncodeExtensionWithResourceContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
Patient patient = new Patient();
patient.addAddress().setUse(AddressUseEnum.HOME);
@@ -751,7 +752,7 @@ public class JsonParserTest {
ExtensionDt parameter = q.addParameter();
parameter.setUrl("http://hl7.org/fhir/query#_query").setValue(new StringDt("example"));
- String val = new FhirContext().newJsonParser().encodeResourceToString(q);
+ String val = ourCtx.newJsonParser().encodeResourceToString(q);
ourLog.info(val);
//@formatter:off
@@ -779,7 +780,7 @@ public class JsonParserTest {
Patient patient = new Patient();
patient.setManagingOrganization(new ResourceReferenceDt());
- IParser p = new FhirContext().newJsonParser();
+ IParser p = ourCtx.newJsonParser();
String str = p.encodeResourceToString(patient);
assertThat(str, IsNot.not(StringContains.containsString("managingOrganization")));
@@ -797,7 +798,7 @@ public class JsonParserTest {
@Test
public void testEncodeUndeclaredExtensionWithAddressContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
Patient patient = new Patient();
patient.addAddress().setUse(AddressUseEnum.HOME);
@@ -845,15 +846,15 @@ public class JsonParserTest {
HumanNameDt given = name.addGiven("Joe");
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
given.addUndeclaredExtension(ext2);
- String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
+ String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
assertEquals("{\"resourceType\":\"Patient\",\"name\":[{\"extension\":[{\"url\":\"http://examples.com#givenext\",\"valueString\":\"Hello\"}],\"family\":[\"Shmoe\"],\"given\":[\"Joe\"]}]}", enc);
- IParser newJsonParser = new FhirContext().newJsonParser();
+ IParser newJsonParser = ourCtx.newJsonParser();
StringReader reader = new StringReader(enc);
Patient parsed = newJsonParser.parseResource(Patient.class, reader);
- ourLog.info(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
+ ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
assertEquals(1, parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
ExtensionDt ext = parsed.getNameFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
@@ -872,7 +873,7 @@ public class JsonParserTest {
ExtensionDt ext2 = new ExtensionDt(false, "http://examples.com#givenext", new StringDt("Hello"));
family.addUndeclaredExtension(ext2);
- String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
+ String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
//@formatter:off
assertThat(enc, containsString(("{\n" +
@@ -897,7 +898,7 @@ public class JsonParserTest {
"}").replace("\n", "").replaceAll(" +", "")));
//@formatter:on
- Patient parsed = new FhirContext().newJsonParser().parseResource(Patient.class, new StringReader(enc));
+ Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").size());
ExtensionDt ext = parsed.getNameFirstRep().getFamilyFirstRep().getUndeclaredExtensionsByUrl("http://examples.com#givenext").get(0);
assertEquals("Hello", ext.getValueAsPrimitive().getValue());
@@ -956,7 +957,7 @@ public class JsonParserTest {
// nothing
}};
- FhirContext context = new FhirContext();
+ FhirContext context = ourCtx;
context.setNarrativeGenerator(gen);
IParser p = context.newJsonParser();
p.encodeResourceToWriter(patient, new OutputStreamWriter(System.out));
@@ -967,6 +968,11 @@ public class JsonParserTest {
assertThat(str, StringContains.containsString(",\"text\":{\"status\":\"generated\",\"div\":\"
help
\"},"));
}
+ @Before
+ public void before() {
+ ourCtx.setNarrativeGenerator(null);
+ }
+
@Test
public void testNestedContainedResources() {
@@ -1330,7 +1336,7 @@ public class JsonParserTest {
"}";
//@formatter:on
- TagList tagList = new FhirContext().newJsonParser().parseTagList(tagListStr);
+ TagList tagList = ourCtx.newJsonParser().parseTagList(tagListStr);
assertEquals(3, tagList.size());
assertEquals("term0", tagList.get(0).getTerm());
assertEquals("label0", tagList.get(0).getLabel());
@@ -1367,14 +1373,14 @@ public class JsonParserTest {
"}";
//@formatter:on
- String encoded = new FhirContext().newJsonParser().encodeTagListToString(tagList);
+ String encoded = ourCtx.newJsonParser().encodeTagListToString(tagList);
assertEquals(expected, encoded);
}
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
@ResourceDef(name = "Patient")
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
index 738facb25c4..a43221fe551 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/parser/XmlParserTest.java
@@ -1700,8 +1700,7 @@ public class XmlParserTest {
@Test
public void testParseFeedWithListResource() throws ConfigurationException, DataFormatException, IOException {
- // Use new context here to ensure List isn't already loaded
- IParser p = new FhirContext().newXmlParser();
+ IParser p = FhirContext.forDstu1().newXmlParser(); // Use new context here
String string = IOUtils.toString(XmlParserTest.class.getResourceAsStream("/feed-with-list.xml"), Charset.forName("UTF-8"));
Bundle bundle = p.parseBundle(string);
@@ -1920,7 +1919,7 @@ public class XmlParserTest {
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreWhitespace(true);
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
@BeforeClass
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BasicAuthInterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BasicAuthInterceptorTest.java
index ac3e054fd22..48171a3f3a2 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BasicAuthInterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BasicAuthInterceptorTest.java
@@ -97,7 +97,7 @@ public class BasicAuthInterceptorTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BearerTokenAuthInterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BearerTokenAuthInterceptorTest.java
index aded3d69089..b1e99b1e208 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BearerTokenAuthInterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/BearerTokenAuthInterceptorTest.java
@@ -82,7 +82,7 @@ public class BearerTokenAuthInterceptorTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientDstu1Test.java
similarity index 94%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientDstu1Test.java
index 7376a97b5b7..12ae8aae412 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientDstu1Test.java
@@ -1,12 +1,8 @@
package ca.uhn.fhir.rest.client;
-import static org.hamcrest.Matchers.containsString;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.fail;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.io.InputStream;
import java.io.StringReader;
@@ -47,7 +43,6 @@ import ca.uhn.fhir.model.api.TagList;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.model.base.resource.BaseConformance;
import ca.uhn.fhir.model.dstu.composite.CodingDt;
-import ca.uhn.fhir.model.dstu.resource.Conformance;
import ca.uhn.fhir.model.dstu.resource.Observation;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu.resource.Patient;
@@ -77,19 +72,19 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
-public class ClientTest {
+public class ClientDstu1Test {
- private FhirContext ctx;
+ private FhirContext ourCtx;
private HttpClient httpClient;
private HttpResponse httpResponse;
@Before
public void before() {
- ctx = new FhirContext(Patient.class, Conformance.class);
+ ourCtx = FhirContext.forDstu1();
httpClient = mock(HttpClient.class, new ReturnsDeepStubs());
- ctx.getRestfulClientFactory().setHttpClient(httpClient);
- ctx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
+ ourCtx.getRestfulClientFactory().setHttpClient(httpClient);
+ ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
httpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
}
@@ -136,7 +131,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
CapturingInterceptor interceptor = new CapturingInterceptor();
client.registerInterceptor(interceptor);
@@ -165,7 +160,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("foobar"), Charset.forName("UTF-8")));
try {
- ctx.newRestfulClient(ITestClient.class, "http://foo").createPatient(patient);
+ ourCtx.newRestfulClient(ITestClient.class, "http://foo").createPatient(patient);
fail();
} catch (InvalidRequestException e) {
assertThat(e.getMessage(), StringContains.containsString("foobar"));
@@ -185,10 +180,10 @@ public class ClientTest {
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), 201, "OK"));
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
- when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ctx.newXmlParser().encodeResourceToString(patient)), Charset.forName("UTF-8")));
+ when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(ourCtx.newXmlParser().encodeResourceToString(patient)), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
MethodOutcome response = client.createPatient(patient);
assertEquals(HttpPost.class, capt.getValue().getClass());
@@ -211,7 +206,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
TagList tagList = new TagList();
tagList.add(new Tag((String) null, "Dog", "DogLabel"));
tagList.add(new Tag("http://cats", "Cat", "CatLabel"));
@@ -237,7 +232,7 @@ public class ClientTest {
OperationOutcome oo = new OperationOutcome();
oo.addIssue().setDetails("Hello");
- String resp = new FhirContext().newXmlParser().encodeResourceToString(oo);
+ String resp = ourCtx.newXmlParser().encodeResourceToString(oo);
ArgumentCaptor capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
@@ -245,7 +240,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(resp), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
MethodOutcome response = client.deletePatient(new IdDt("1234"));
assertEquals(HttpDelete.class, capt.getValue().getClass());
@@ -262,7 +257,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.deleteDiagnosticReport(new IdDt("1234"));
assertEquals(HttpDelete.class, capt.getValue().getClass());
@@ -272,7 +267,7 @@ public class ClientTest {
@Test
public void testGetConformance() throws Exception {
- String msg = IOUtils.toString(ClientTest.class.getResourceAsStream("/example-metadata.xml"));
+ String msg = IOUtils.toString(ClientDstu1Test.class.getResourceAsStream("/example-metadata.xml"));
ArgumentCaptor capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
@@ -280,7 +275,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
BaseConformance response = client.getServerConformanceStatement();
assertEquals("http://foo/metadata", capt.getValue().getURI().toString());
@@ -319,7 +314,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Bundle response = client.getHistoryPatientInstance(new IdDt("111"));
assertEquals("http://foo/Patient/111/_history", capt.getValue().getURI().toString());
@@ -391,7 +386,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Bundle response = client.getHistoryPatientType();
assertEquals("http://foo/Patient/_history", capt.getValue().getURI().toString());
@@ -462,7 +457,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_ATOM_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Bundle response = client.getHistoryServer();
assertEquals("http://foo/_history", capt.getValue().getURI().toString());
@@ -521,7 +516,7 @@ public class ClientTest {
}
});
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
// ensures the local timezone
String expectedDateString = new InstantDt(new InstantDt("2012-01-02T12:01:02").getValue()).getValueAsString();
@@ -556,7 +551,7 @@ public class ClientTest {
// TODO: remove the read annotation and make sure we get a sensible
// error message to tell the user why the method isn't working
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = ourCtx;
ctx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
ClientWithoutAnnotation client = ctx.newRestfulClient(ClientWithoutAnnotation.class, "http://wildfhir.aegis.net/fhir");
@@ -596,7 +591,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
// Patient response = client.findPatientByMrn(new
// IdentifierDt("urn:foo", "123"));
Patient response = client.getPatientById(new IdDt("111"));
@@ -640,7 +635,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", "application/fhir+xml; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
// Patient response = client.findPatientByMrn(new
// IdentifierDt("urn:foo", "123"));
Patient response = client.getPatientById(new IdDt("111"));
@@ -662,7 +657,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_TEXT));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader("Internal Failure"), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
try {
client.getPatientById(new IdDt("111"));
fail();
@@ -689,7 +684,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
try {
client.getPatientById(new IdDt("111"));
fail();
@@ -723,7 +718,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
// Patient response = client.findPatientByMrn(new
// IdentifierDt("urn:foo", "123"));
Patient response = client.getPatientById(new IdDt("111"));
@@ -748,7 +743,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
DateRangeParam param = new DateRangeParam();
param.setLowerBound(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-01"));
param.setUpperBound(new DateParam(QuantityCompararatorEnum.LESSTHAN_OR_EQUALS, "2021-01-01"));
@@ -772,7 +767,7 @@ public class ClientTest {
// httpResponse = new BasicHttpResponse(statusline, catalog, locale)
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
List response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
@@ -793,7 +788,7 @@ public class ClientTest {
when(httpClient.execute(capt.capture())).thenReturn(httpResponse);
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
List response = client.getPatientByCompartmentAndDob(new IdDt("123"), new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient/123/compartmentName?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
@@ -819,7 +814,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Patient response = client.findPatientQuantity(new QuantityParam(QuantityCompararatorEnum.GREATERTHAN, 123L, "foo", "bar"));
assertEquals("http://foo/Patient?quantityParam=%3E123%7Cfoo%7Cbar", capt.getValue().getURI().toString());
@@ -838,7 +833,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Patient response = client.findPatientByMrn(new TokenParam("urn:foo", "123"));
assertEquals("http://foo/Patient?identifier=urn%3Afoo%7C123", capt.getValue().getURI().toString());
@@ -857,7 +852,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
TokenOrListParam identifiers = new TokenOrListParam();
identifiers.add(new CodingDt("foo", "bar"));
identifiers.add(new CodingDt("baz", "boz"));
@@ -878,7 +873,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.getPatientNoParams();
assertEquals("http://foo/Patient?_query=someQueryNoParams", capt.getValue().getURI().toString());
@@ -896,7 +891,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.getPatientOneParam(new StringParam("BB"));
assertEquals("http://foo/Patient?_query=someQueryOneParam¶m1=BB", capt.getValue().getURI().toString());
@@ -914,7 +909,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClientWithCustomType client = ctx.newRestfulClient(ITestClientWithCustomType.class, "http://foo");
+ ITestClientWithCustomType client = ourCtx.newRestfulClient(ITestClientWithCustomType.class, "http://foo");
CustomPatient response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
@@ -933,7 +928,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClientWithCustomTypeList client = ctx.newRestfulClient(ITestClientWithCustomTypeList.class, "http://foo");
+ ITestClientWithCustomTypeList client = ourCtx.newRestfulClient(ITestClientWithCustomTypeList.class, "http://foo");
List response = client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getValue().getURI().toString());
@@ -954,7 +949,7 @@ public class ClientTest {
// TODO: document this
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.getPatientByDob(new DateParam(QuantityCompararatorEnum.GREATERTHAN_OR_EQUALS, "2011-01-02"));
assertEquals("http://foo/Patient?birthdate=%3E%3D2011-01-02", capt.getAllValues().get(0).getURI().toString());
@@ -982,7 +977,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.getPatientWithIncludes(new StringParam("aaa"), Arrays.asList(new Include[] { new Include("inc1"), new Include("inc2") }));
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1&_include=inc2", capt.getValue().getURI().toString());
@@ -1000,7 +995,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
Bundle response = client.findPatientByName(new StringParam("AAA"), null);
assertEquals("http://foo/Patient?family=AAA", capt.getValue().getURI().toString());
@@ -1012,7 +1007,7 @@ public class ClientTest {
*/
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
response = client.findPatientByName(new StringParam("AAA"), new StringParam("BBB"));
assertEquals("http://foo/Patient?family=AAA&given=BBB", capt.getValue().getURI().toString());
@@ -1032,7 +1027,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
StringParam str = new StringParam("FOO$BAR");
DateParam date = new DateParam("2001-01-01");
client.getObservationByNameValueDate(new CompositeParam(str, date));
@@ -1052,7 +1047,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClientWithStringIncludes client = ctx.newRestfulClient(ITestClientWithStringIncludes.class, "http://foo");
+ ITestClientWithStringIncludes client = ourCtx.newRestfulClient(ITestClientWithStringIncludes.class, "http://foo");
client.getPatientWithIncludes(new StringParam("aaa"), "inc1");
assertEquals("http://foo/Patient?withIncludes=aaa&_include=inc1", capt.getValue().getURI().toString());
@@ -1072,7 +1067,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
MethodOutcome response = client.updatePatient(new IdDt("100"), patient);
assertEquals(HttpPut.class, capt.getValue().getClass());
@@ -1100,7 +1095,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Content-Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
assertEquals(HttpPut.class, capt.getValue().getClass());
@@ -1124,7 +1119,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getStatusLine()).thenReturn(new BasicStatusLine(new ProtocolVersion("HTTP", 1, 1), Constants.STATUS_HTTP_409_CONFLICT, "Conflict"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
}
@@ -1141,7 +1136,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
MethodOutcome response = client.updatePatient(new IdDt("Patient/100/_history/200"), patient);
assertEquals(HttpPut.class, capt.getValue().getClass());
@@ -1166,7 +1161,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(""), Charset.forName("UTF-8")));
when(httpResponse.getAllHeaders()).thenReturn(toHeaderArray("Location", "http://example.com/fhir/Patient/100/_history/200"));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
MethodOutcome response = client.validatePatient(patient);
assertEquals(HttpPost.class, capt.getValue().getClass());
@@ -1199,7 +1194,7 @@ public class ClientTest {
when(httpResponse.getEntity().getContentType()).thenReturn(new BasicHeader("content-type", Constants.CT_FHIR_XML + "; charset=UTF-8"));
when(httpResponse.getEntity().getContent()).thenReturn(new ReaderInputStream(new StringReader(msg), Charset.forName("UTF-8")));
- ITestClient client = ctx.newRestfulClient(ITestClient.class, "http://foo");
+ ITestClient client = ourCtx.newRestfulClient(ITestClient.class, "http://foo");
// Patient response = client.findPatientByMrn(new
// IdentifierDt("urn:foo", "123"));
Patient response = client.getPatientById(new IdDt("Patient/111/_history/999"));
@@ -1224,7 +1219,7 @@ public class ClientTest {
}
});
- ITestClientWithNarrativeParam client = ctx.newRestfulClient(ITestClientWithNarrativeParam.class, "http://foo");
+ ITestClientWithNarrativeParam client = ourCtx.newRestfulClient(ITestClientWithNarrativeParam.class, "http://foo");
int idx = 0;
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java
index a76dca1d0e2..8c920c55ac7 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ClientIntegrationTest.java
@@ -34,6 +34,7 @@ public class ClientIntegrationTest {
private int myPort;
private Server myServer;
private MyPatientResourceProvider myPatientProvider;
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Before
public void before() {
@@ -43,7 +44,7 @@ public class ClientIntegrationTest {
myPatientProvider = new MyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(myPatientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -57,7 +58,7 @@ public class ClientIntegrationTest {
myServer.start();
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = FhirContext.forDstu1();
HttpClientBuilder builder = HttpClientBuilder.create();
// PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ExceptionHandlingTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ExceptionHandlingTest.java
index d6041b69ba6..25ae3205225 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ExceptionHandlingTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/ExceptionHandlingTest.java
@@ -38,7 +38,7 @@ public class ExceptionHandlingTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
@Before
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/GenericClientTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/GenericClientTest.java
index c2db362aa9b..3a88b106426 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/GenericClientTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/GenericClientTest.java
@@ -778,7 +778,7 @@ public class GenericClientTest {
@Test
public void testSearchByNumberExact() throws Exception {
- String msg = new FhirContext().newXmlParser().encodeBundleToString(new Bundle());
+ String msg = ourCtx.newXmlParser().encodeBundleToString(new Bundle());
ArgumentCaptor capt = ArgumentCaptor.forClass(HttpUriRequest.class);
when(myHttpClient.execute(capt.capture())).thenReturn(myHttpResponse);
@@ -1360,7 +1360,7 @@ public class GenericClientTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/HttpProxyTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/HttpProxyTest.java
index 5e1a900387f..cfc5ac27922 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/HttpProxyTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/HttpProxyTest.java
@@ -49,7 +49,7 @@ public class HttpProxyTest {
myFirstRequest = true;
myAuthHeader = null;
- RestfulServer restServer = new RestfulServer() {
+ RestfulServer restServer = new RestfulServer(ourCtx) {
@Override
protected void doGet(HttpServletRequest theRequest, HttpServletResponse theResponse) throws ServletException, IOException {
@@ -69,7 +69,6 @@ public class HttpProxyTest {
}
};
- restServer.setFhirContext(ourCtx);
restServer.setResourceProviders(new PatientResourceProvider());
// ServletHandler proxyHandler = new ServletHandler();
@@ -123,7 +122,7 @@ public class HttpProxyTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu1();
}
public static class PatientResourceProvider implements IResourceProvider {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/LoggingInterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/LoggingInterceptorTest.java
index 877c871d7b0..7bb7c73a611 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/LoggingInterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/LoggingInterceptorTest.java
@@ -39,8 +39,7 @@ public class LoggingInterceptorTest {
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private Appender myMockAppender;
private Logger myLoggerRoot;
@@ -89,15 +88,14 @@ public class LoggingInterceptorTest {
DummyProvider patientProvider = new DummyProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- ourCtx = servlet.getFhirContext();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
ourServer.setHandler(proxyHandler);
ourServer.start();
- ourCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
+ ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
}
/**
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchClientDstu1Test.java
similarity index 99%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchClientDstu1Test.java
index eb8ff4c7704..aa6e3475852 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/client/SearchClientDstu1Test.java
@@ -42,9 +42,9 @@ import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
-public class SearchTest {
+public class SearchClientDstu1Test {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchTest.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchClientDstu1Test.class);
private FhirContext ourCtx;
private HttpClient ourHttpClient;
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/method/BaseOutcomeReturningMethodBindingTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/method/BaseOutcomeReturningMethodBindingTest.java
index 025886ab5c3..8a5e29e749d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/method/BaseOutcomeReturningMethodBindingTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/method/BaseOutcomeReturningMethodBindingTest.java
@@ -184,7 +184,7 @@ public class BaseOutcomeReturningMethodBindingTest {
"}";
//@formatter:on
- TagList parsedFromResource = new FhirContext().newJsonParser().parseTagList(resourceString);
+ TagList parsedFromResource = FhirContext.forDstu1().newJsonParser().parseTagList(resourceString);
assertEquals(parsedFromHeader.size(), parsedFromResource.size());
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/AcceptHeaderTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/AcceptHeaderTest.java
index c6882fd4d26..6c5fce7b54e 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/AcceptHeaderTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/AcceptHeaderTest.java
@@ -38,6 +38,7 @@ public class AcceptHeaderTest {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testReadNoHeader() throws Exception {
@@ -97,7 +98,7 @@ public class AcceptHeaderTest {
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(new PatientProvider());
servlet.setDefaultResponseEncoding(EncodingEnum.XML);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java
index b10a1ac6d69..05967398334 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/BinaryTest.java
@@ -44,7 +44,7 @@ import ca.uhn.fhir.util.PortUtil;
public class BinaryTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static Binary ourLast;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BinaryTest.class);
@@ -166,7 +166,7 @@ public class BinaryTest {
ResourceProvider patientProvider = new ResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java
index 151f9135600..a50ad187951 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompositeParameterTest.java
@@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
public class CompositeParameterTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort;
private static Server ourServer;
@@ -106,8 +106,7 @@ public class CompositeParameterTest {
DummyObservationResourceProvider patientProvider = new DummyObservationResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- ourCtx = servlet.getFhirContext();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -118,8 +117,6 @@ public class CompositeParameterTest {
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
-
- ourCtx = servlet.getFhirContext();
}
/**
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java
index c90f86cc7bd..82ccae7ceab 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CompressionTest.java
@@ -41,7 +41,7 @@ public class CompressionTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompressionTest.class);
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
public static String decompress(byte[] theResource) {
GZIPInputStream is;
@@ -107,8 +107,7 @@ public class CompressionTest {
DummyProvider patientProvider = new DummyProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- ourCtx = servlet.getFhirContext();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java
index 37c5ac7e847..9a16f2c42ac 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CorsTest.java
@@ -37,7 +37,7 @@ import ca.uhn.fhir.util.PortUtil;
*/
public class CorsTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CorsTest.class);
@Test
@@ -45,8 +45,7 @@ public class CorsTest {
int port = PortUtil.findFreePort();
Server server = new Server(port);
- RestfulServer restServer = new RestfulServer();
- restServer.setFhirContext(ourCtx);
+ RestfulServer restServer = new RestfulServer(ourCtx);
restServer.setResourceProviders(new DummyPatientResourceProvider());
// ServletHandler proxyHandler = new ServletHandler();
@@ -125,8 +124,6 @@ public class CorsTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
-
PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(5000, TimeUnit.MILLISECONDS);
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java
index f8b9afdcc4a..22483bd2be4 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CreateTest.java
@@ -51,11 +51,11 @@ import ca.uhn.fhir.util.PortUtil;
*/
public class CreateTest {
private static CloseableHttpClient ourClient;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static EncodingEnum ourLastEncoding;
private static String ourLastResourceBody;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateTest.class);
private static int ourPort;
-
private static DiagnosticReportProvider ourReportProvider;
private static Server ourServer;
@@ -65,7 +65,7 @@ public class CreateTest {
ourLastResourceBody=null;
ourLastEncoding=null;
}
-
+
@Test
public void testCreate() throws Exception {
@@ -74,7 +74,7 @@ public class CreateTest {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -91,31 +91,6 @@ public class CreateTest {
}
- @Test
- public void testCreateWithNoParsed() throws Exception {
-
- Organization org = new Organization();
- org.addIdentifier().setValue("001");
- org.addIdentifier().setValue("002");
-
- HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization");
- httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
-
- HttpResponse status = ourClient.execute(httpPost);
-
- String responseContent = IOUtils.toString(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
- ourLog.info("Response was:\n{}", responseContent);
-
- assertEquals(201, status.getStatusLine().getStatusCode());
- assertEquals("http://localhost:" + ourPort + "/Organization/001", status.getFirstHeader("location").getValue());
- assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue(), StringContains.containsString("UTF-8"));
-
- assertThat(ourLastResourceBody, stringContainsInOrder("\"resourceType\":\"Organization\"", "\"identifier\"","\"value\":\"001"));
- assertEquals(EncodingEnum.JSON, ourLastEncoding);
-
- }
-
@Test
public void testCreateById() throws Exception {
@@ -124,7 +99,7 @@ public class CreateTest {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/1234");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -144,7 +119,7 @@ public class CreateTest {
obs.getIdentifier().setValue("001");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Observation");
- httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(obs), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(obs), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -166,7 +141,7 @@ public class CreateTest {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
- httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -180,6 +155,31 @@ public class CreateTest {
}
+ @Test
+ public void testCreateWithNoParsed() throws Exception {
+
+ Organization org = new Organization();
+ org.addIdentifier().setValue("001");
+ org.addIdentifier().setValue("002");
+
+ HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization");
+ httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
+
+ HttpResponse status = ourClient.execute(httpPost);
+
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+ ourLog.info("Response was:\n{}", responseContent);
+
+ assertEquals(201, status.getStatusLine().getStatusCode());
+ assertEquals("http://localhost:" + ourPort + "/Organization/001", status.getFirstHeader("location").getValue());
+ assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue(), StringContains.containsString("UTF-8"));
+
+ assertThat(ourLastResourceBody, stringContainsInOrder("\"resourceType\":\"Organization\"", "\"identifier\"","\"value\":\"001"));
+ assertEquals(EncodingEnum.JSON, ourLastEncoding);
+
+ }
+
@Test
public void testCreateWithUnprocessableEntity() throws Exception {
@@ -187,7 +187,7 @@ public class CreateTest {
report.getIdentifier().setValue("001");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/DiagnosticReport");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(report), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(report), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -198,7 +198,7 @@ public class CreateTest {
assertEquals(422, status.getStatusLine().getStatusCode());
- OperationOutcome outcome = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, new StringReader(responseContent));
+ OperationOutcome outcome = ourCtx.newXmlParser().parseResource(OperationOutcome.class, new StringReader(responseContent));
assertEquals("FOOBAR", outcome.getIssueFirstRep().getDetails().getValue());
}
@@ -218,7 +218,7 @@ public class CreateTest {
ourReportProvider = new DiagnosticReportProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(
patientProvider, ourReportProvider, new DummyAdverseReactionResourceProvider(), new CustomObservationProvider(),
new OrganizationProvider());
@@ -329,6 +329,23 @@ public class CreateTest {
}
+ public static class OrganizationProvider implements IResourceProvider {
+
+ @Create()
+ public MethodOutcome create(@ResourceParam String theResourceBody, @ResourceParam EncodingEnum theEncoding) {
+ ourLastResourceBody=theResourceBody;
+ ourLastEncoding=theEncoding;
+
+ return new MethodOutcome(new IdDt("001"));
+ }
+
+ @Override
+ public Class extends IResource> getResourceType() {
+ return Organization.class;
+ }
+
+ }
+
public static class PatientProvider implements IResourceProvider {
@Create()
@@ -351,21 +368,4 @@ public class CreateTest {
}
- public static class OrganizationProvider implements IResourceProvider {
-
- @Create()
- public MethodOutcome create(@ResourceParam String theResourceBody, @ResourceParam EncodingEnum theEncoding) {
- ourLastResourceBody=theResourceBody;
- ourLastEncoding=theEncoding;
-
- return new MethodOutcome(new IdDt("001"));
- }
-
- @Override
- public Class extends IResource> getResourceType() {
- return Organization.class;
- }
-
- }
-
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java
index 9e7e92f4147..2b1007f994d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/CustomTypeTest.java
@@ -165,7 +165,7 @@ public class CustomTypeTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- ourServlet = new RestfulServer();
+ ourServlet = new RestfulServer(ourCtx);
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
ourServlet.setResourceProviders(patientProvider);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DateRangeParamSearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DateRangeParamSearchTest.java
index a7fa5aa0a40..f2a642aa532 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DateRangeParamSearchTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DateRangeParamSearchTest.java
@@ -20,6 +20,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.narrative.DefaultThymeleafNarrativeGenerator;
@@ -37,7 +38,8 @@ public class DateRangeParamSearchTest {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
@Test
public void testSearchForOneUnqualifiedDate() throws Exception {
String baseUrl = "http://localhost:" + ourPort + "/Patient?" + Patient.SP_BIRTHDATE + "=";
@@ -85,7 +87,7 @@ public class DateRangeParamSearchTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
servlet.setResourceProviders(patientProvider);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DefaultEncodingTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DefaultEncodingTest.java
index 02050b47933..c1fcb31038e 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DefaultEncodingTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DefaultEncodingTest.java
@@ -44,9 +44,8 @@ public class DefaultEncodingTest {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static RestfulServer ourRestfulServer;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultEncodingTest.class);
@Test
public void testReadWithDefaultJsonPretty() throws Exception {
@@ -135,8 +134,7 @@ public class DefaultEncodingTest {
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- ourRestfulServer = new RestfulServer();
- ourCtx = ourRestfulServer.getFhirContext();
+ ourRestfulServer = new RestfulServer(ourCtx);
ourRestfulServer.setResourceProviders(new PatientProvider());
ServletHolder servletHolder = new ServletHolder(ourRestfulServer);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DestroyTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DestroyTest.java
index a41085cb5d3..c3816b6f4a6 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DestroyTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DestroyTest.java
@@ -1,23 +1,22 @@
package ca.uhn.fhir.rest.server;
+import static org.mockito.Mockito.*;
+
+import java.util.Arrays;
+
+import javax.servlet.ServletException;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.runners.MockitoJUnitRunner;
+
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.DiagnosticReport;
import ca.uhn.fhir.rest.annotation.Create;
import ca.uhn.fhir.rest.annotation.Destroy;
import ca.uhn.fhir.rest.annotation.ResourceParam;
import ca.uhn.fhir.rest.api.MethodOutcome;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.Mock;
-import org.mockito.runners.MockitoJUnitRunner;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-
-import java.util.Arrays;
-
-import static org.mockito.Mockito.spy;
-import static org.mockito.Mockito.verify;
/**
* Created by Bill de Beaubien on 11/10/2014.
@@ -26,70 +25,72 @@ import static org.mockito.Mockito.verify;
@RunWith(MockitoJUnitRunner.class)
public class DestroyTest {
- @Test
- public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException {
- RestfulServer servlet = new RestfulServer();
- DiagnosticReportProvider provider = spy(new DiagnosticReportProvider());
- servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
- servlet.init();
- servlet.destroy();
- verify(provider).destroy();
- }
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
- @Test
- public void testChainsUpThroughSuperclasses() throws ServletException {
- RestfulServer servlet = new RestfulServer();
- DerivedDiagnosticReportProvider provider = spy(new DerivedDiagnosticReportProvider());
- servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
- servlet.init();
- servlet.destroy();
- verify(provider).destroy();
- }
+ @Test
+ public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException {
+ RestfulServer servlet = new RestfulServer(ourCtx);
+ DiagnosticReportProvider provider = spy(new DiagnosticReportProvider());
+ servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
+ servlet.init();
+ servlet.destroy();
+ verify(provider).destroy();
+ }
- @Test
- public void testNoDestroyDoesNotCauseInfiniteRecursion() throws ServletException {
- RestfulServer servlet = new RestfulServer();
- DiagnosticReportProviderSansDestroy provider = new DiagnosticReportProviderSansDestroy();
- servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
- servlet.init();
- servlet.destroy();
- // nothing to verify other than the test didn't hang forever
- }
+ @Test
+ public void testChainsUpThroughSuperclasses() throws ServletException {
+ RestfulServer servlet = new RestfulServer(ourCtx);
+ DerivedDiagnosticReportProvider provider = spy(new DerivedDiagnosticReportProvider());
+ servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
+ servlet.init();
+ servlet.destroy();
+ verify(provider).destroy();
+ }
- public class DiagnosticReportProvider implements IResourceProvider {
+ @Test
+ public void testNoDestroyDoesNotCauseInfiniteRecursion() throws ServletException {
+ RestfulServer servlet = new RestfulServer(ourCtx);
+ DiagnosticReportProviderSansDestroy provider = new DiagnosticReportProviderSansDestroy();
+ servlet.setResourceProviders(Arrays.asList((IResourceProvider) provider));
+ servlet.init();
+ servlet.destroy();
+ // nothing to verify other than the test didn't hang forever
+ }
- @Override
- public Class extends IResource> getResourceType() {
- return DiagnosticReport.class;
- }
+ public class DiagnosticReportProvider implements IResourceProvider {
- @Create
- public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
- // do nothing
- return new MethodOutcome();
- }
+ @Override
+ public Class extends IResource> getResourceType() {
+ return DiagnosticReport.class;
+ }
- @Destroy
- public void destroy() {
- // do nothing
- }
- }
+ @Create
+ public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
+ // do nothing
+ return new MethodOutcome();
+ }
- public class DerivedDiagnosticReportProvider extends DiagnosticReportProvider {
- // move along, nothing to see here
- }
+ @Destroy
+ public void destroy() {
+ // do nothing
+ }
+ }
- public class DiagnosticReportProviderSansDestroy implements IResourceProvider {
+ public class DerivedDiagnosticReportProvider extends DiagnosticReportProvider {
+ // move along, nothing to see here
+ }
- @Override
- public Class extends IResource> getResourceType() {
- return DiagnosticReport.class;
- }
+ public class DiagnosticReportProviderSansDestroy implements IResourceProvider {
- @Create
- public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
- // do nothing
- return new MethodOutcome();
- }
- }
+ @Override
+ public Class extends IResource> getResourceType() {
+ return DiagnosticReport.class;
+ }
+
+ @Create
+ public MethodOutcome createResource(@ResourceParam DiagnosticReport theDiagnosticReport) {
+ // do nothing
+ return new MethodOutcome();
+ }
+ }
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
index 278bdbb4855..63d06a264b1 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/DynamicSearchTest.java
@@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
public class DynamicSearchTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DynamicSearchTest.class);
private static int ourPort;
@@ -144,7 +144,7 @@ public class DynamicSearchTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
servlet.setResourceProviders(patientProvider);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java
index 7256483d443..3e9497daaa4 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ExceptionTest.java
@@ -23,6 +23,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu.resource.Patient;
@@ -52,6 +53,7 @@ public class ExceptionTest {
private static int ourPort;
private static Server ourServer;
private static RestfulServer servlet;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
@Before
public void before() {
@@ -189,7 +191,7 @@ public class ExceptionTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java
index 4f847eeb106..f26bec3c3c8 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/HistoryTest.java
@@ -37,9 +37,65 @@ import ca.uhn.fhir.util.PortUtil;
public class HistoryTest {
private static CloseableHttpClient ourClient;
+ private static FhirContext ourCtx= FhirContext.forDstu1();
private static int ourPort;
+
private static Server ourServer;
+ @Test
+ public void testInstanceHistory() throws Exception {
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
+ assertEquals(2, bundle.getEntries().size());
+ assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
+ assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
+
+ }
+ }
+
+ @Test
+ public void testServerHistory() throws Exception {
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/_history");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
+ assertEquals(2, bundle.getEntries().size());
+ assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
+ assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
+
+ }
+ }
+
+ @Test
+ public void testTypeHistory() throws Exception {
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/_history");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
+ assertEquals(2, bundle.getEntries().size());
+ assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
+ assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
+
+ }
+ }
+
/**
* We test this here because of bug 3- At one point VRead would "steal" instance history calls and handle them
*/
@@ -53,65 +109,11 @@ public class HistoryTest {
assertEquals(200, status.getStatusLine().getStatusCode());
- Patient bundle = new FhirContext().newXmlParser().parseResource(Patient.class, responseContent);
+ Patient bundle = ourCtx.newXmlParser().parseResource(Patient.class, responseContent);
assertEquals("vread", bundle.getNameFirstRep().getFamilyFirstRep().getValue());
}
}
- @Test
- public void testServerHistory() throws Exception {
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/_history");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
-
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
- assertEquals(2, bundle.getEntries().size());
- assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
- assertEquals("http://localhost:" + ourPort +"/Patient/h1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
-
- }
- }
-
- @Test
- public void testInstanceHistory() throws Exception {
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/123/_history");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
-
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
- assertEquals(2, bundle.getEntries().size());
- assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
- assertEquals("http://localhost:" + ourPort +"/Patient/ih1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
-
- }
- }
-
- @Test
- public void testTypeHistory() throws Exception {
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/_history");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
-
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
- assertEquals(2, bundle.getEntries().size());
- assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/1", bundle.getEntries().get(0).getLinkSelf().getValue());
- assertEquals("http://localhost:" + ourPort +"/Patient/th1/_history/2", bundle.getEntries().get(1).getLinkSelf().getValue());
-
- }
- }
-
@AfterClass
public static void afterClass() throws Exception {
ourServer.stop();
@@ -126,7 +128,7 @@ public class HistoryTest {
DummyResourceProvider patientProvider = new DummyResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setPlainProviders(plainProvider);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
@@ -141,59 +143,6 @@ public class HistoryTest {
}
- public static class DummyResourceProvider implements IResourceProvider {
-
- @Override
- public Class extends IResource> getResourceType() {
- return Patient.class;
- }
-
- @Read(version=true)
- public Patient vread(@IdParam IdDt theId) {
- Patient retVal = new Patient();
- retVal.addName().addFamily("vread");
- retVal.setId(theId);
- return retVal;
- }
-
- @History
- public List instanceHistory(@IdParam IdDt theId) {
- ArrayList retVal = new ArrayList();
-
- Patient patient = new Patient();
- patient.setId("Patient/ih1/_history/1");
- patient.addName().addFamily("history");
- retVal.add(patient);
-
- Patient patient2 = new Patient();
- patient2.setId("Patient/ih1/_history/2");
- patient2.addName().addFamily("history");
- retVal.add(patient2);
-
- return retVal;
- }
-
- @History
- public List typeHistory() {
- ArrayList retVal = new ArrayList();
-
- Patient patient = new Patient();
- patient.setId("Patient/th1/_history/1");
- patient.addName().addFamily("history");
- retVal.add(patient);
-
- Patient patient2 = new Patient();
- patient2.setId("Patient/th1/_history/2");
- patient2.addName().addFamily("history");
- retVal.add(patient2);
-
- return retVal;
- }
-
-
- }
-
-
/**
* Created by dsotnikov on 2/25/2014.
*/
@@ -219,6 +168,59 @@ public class HistoryTest {
+ }
+
+
+ public static class DummyResourceProvider implements IResourceProvider {
+
+ @Override
+ public Class extends IResource> getResourceType() {
+ return Patient.class;
+ }
+
+ @History
+ public List instanceHistory(@IdParam IdDt theId) {
+ ArrayList retVal = new ArrayList();
+
+ Patient patient = new Patient();
+ patient.setId("Patient/ih1/_history/1");
+ patient.addName().addFamily("history");
+ retVal.add(patient);
+
+ Patient patient2 = new Patient();
+ patient2.setId("Patient/ih1/_history/2");
+ patient2.addName().addFamily("history");
+ retVal.add(patient2);
+
+ return retVal;
+ }
+
+ @History
+ public List typeHistory() {
+ ArrayList retVal = new ArrayList();
+
+ Patient patient = new Patient();
+ patient.setId("Patient/th1/_history/1");
+ patient.addName().addFamily("history");
+ retVal.add(patient);
+
+ Patient patient2 = new Patient();
+ patient2.setId("Patient/th1/_history/2");
+ patient2.addName().addFamily("history");
+ retVal.add(patient2);
+
+ return retVal;
+ }
+
+ @Read(version=true)
+ public Patient vread(@IdParam IdDt theId) {
+ Patient retVal = new Patient();
+ retVal.addName().addFamily("vread");
+ retVal.setId(theId);
+ return retVal;
+ }
+
+
}
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java
index 8b05981ce1e..a05fa753f46 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/IncludeTest.java
@@ -88,9 +88,8 @@ public class IncludeTest {
assertEquals("Hello", p.getId().getIdPart());
assertEquals("foo", p.getName().get(0).getFamilyFirstRep().getValue());
}
-
-
-// @Test
+
+ // @Test
public void testMixedContainedAndNonContained() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/DiagnosticReport?_query=stitchedInclude&_pretty=true");
HttpResponse status = ourClient.execute(httpGet);
@@ -98,12 +97,11 @@ public class IncludeTest {
IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info(responseContent);
-
+
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(4, bundle.size());
}
-
@Test
public void testIIncludedResourcesNonContained() throws Exception {
@@ -114,23 +112,22 @@ public class IncludeTest {
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
-
+
ourLog.info(responseContent);
-
+
assertEquals(3, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
-
- Patient p1 = (Patient) bundle.toListOfResources().get(0);
- assertEquals(0,p1.getContained().getContainedResources().size());
-
- Patient p2 = (Patient) bundle.toListOfResources().get(1);
- assertEquals(0,p2.getContained().getContainedResources().size());
-
+ Patient p1 = (Patient) bundle.toListOfResources().get(0);
+ assertEquals(0, p1.getContained().getContainedResources().size());
+
+ Patient p2 = (Patient) bundle.toListOfResources().get(1);
+ assertEquals(0, p2.getContained().getContainedResources().size());
+
}
-
+
@Test
public void testIIncludedResourcesNonContainedInExtension() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true");
@@ -140,24 +137,22 @@ public class IncludeTest {
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
-
+
ourLog.info(responseContent);
-
+
assertEquals(3, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
-
- Patient p1 = (Patient) bundle.toListOfResources().get(0);
- assertEquals(0,p1.getContained().getContainedResources().size());
-
- Patient p2 = (Patient) bundle.toListOfResources().get(1);
- assertEquals(0,p2.getContained().getContainedResources().size());
-
+ Patient p1 = (Patient) bundle.toListOfResources().get(0);
+ assertEquals(0, p1.getContained().getContainedResources().size());
+
+ Patient p2 = (Patient) bundle.toListOfResources().get(1);
+ assertEquals(0, p2.getContained().getContainedResources().size());
+
}
-
-
+
@Test
public void testIIncludedResourcesNonContainedInExtensionJson() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?_query=extInclude&_pretty=true&_format=json");
@@ -167,21 +162,20 @@ public class IncludeTest {
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newJsonParser().parseBundle(responseContent);
-
+
ourLog.info(responseContent);
-
+
assertEquals(3, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
-
- Patient p1 = (Patient) bundle.toListOfResources().get(0);
- assertEquals(0,p1.getContained().getContainedResources().size());
-
- Patient p2 = (Patient) bundle.toListOfResources().get(1);
- assertEquals(0,p2.getContained().getContainedResources().size());
-
+ Patient p1 = (Patient) bundle.toListOfResources().get(0);
+ assertEquals(0, p1.getContained().getContainedResources().size());
+
+ Patient p2 = (Patient) bundle.toListOfResources().get(1);
+ assertEquals(0, p2.getContained().getContainedResources().size());
+
}
@Test
@@ -193,26 +187,23 @@ public class IncludeTest {
assertEquals(200, status.getStatusLine().getStatusCode());
Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
-
+
ourLog.info(responseContent);
-
+
assertEquals(4, bundle.size());
assertEquals(new IdDt("Patient/p1"), bundle.toListOfResources().get(0).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Patient/p2"), bundle.toListOfResources().get(1).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o1"), bundle.toListOfResources().get(2).getId().toUnqualifiedVersionless());
assertEquals(new IdDt("Organization/o2"), bundle.toListOfResources().get(3).getId().toUnqualifiedVersionless());
-
+
Patient p1 = (Patient) bundle.toListOfResources().get(0);
- assertEquals(0,p1.getContained().getContainedResources().size());
-
+ assertEquals(0, p1.getContained().getContainedResources().size());
+
Patient p2 = (Patient) bundle.toListOfResources().get(1);
- assertEquals(0,p2.getContained().getContainedResources().size());
+ assertEquals(0, p2.getContained().getContainedResources().size());
-
}
-
-
@Test
public void testTwoInclude() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello&_include=foo&_include=bar");
@@ -229,10 +220,10 @@ public class IncludeTest {
assertEquals("Hello", p.getId().getIdPart());
Set values = new HashSet();
- values.add( p.getName().get(0).getFamilyFirstRep().getValue());
- values.add( p.getName().get(1).getFamilyFirstRep().getValue());
+ values.add(p.getName().get(0).getFamilyFirstRep().getValue());
+ values.add(p.getName().get(1).getFamilyFirstRep().getValue());
assertThat(values, containsInAnyOrder("foo", "bar"));
-
+
}
@Test
@@ -242,9 +233,9 @@ public class IncludeTest {
assertEquals(400, status.getStatusLine().getStatusCode());
String responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
-
+
ourLog.info(responseContent);
- assertThat(responseContent,containsString("Invalid _include parameter value"));
+ assertThat(responseContent, containsString("Invalid _include parameter value"));
}
@AfterClass
@@ -254,17 +245,16 @@ public class IncludeTest {
@BeforeClass
public static void beforeClass() throws Exception {
-
- ourCtx = new FhirContext();
+
+ ourCtx = FhirContext.forDstu1();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- servlet.setFhirContext(ourCtx);
- servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
+ RestfulServer servlet = new RestfulServer(ourCtx);
+ servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -278,11 +268,10 @@ public class IncludeTest {
}
- @ResourceDef(name="Patient")
- public static class ExtPatient extends Patient
- {
- @Child(name="secondOrg")
- @Extension(url="http://foo#secondOrg", definedLocally = false, isModifier = false)
+ @ResourceDef(name = "Patient")
+ public static class ExtPatient extends Patient {
+ @Child(name = "secondOrg")
+ @Extension(url = "http://foo#secondOrg", definedLocally = false, isModifier = false)
private ResourceReferenceDt mySecondOrg;
@Override
@@ -291,8 +280,8 @@ public class IncludeTest {
}
public ResourceReferenceDt getSecondOrg() {
- if (mySecondOrg==null) {
- mySecondOrg= new ResourceReferenceDt();
+ if (mySecondOrg == null) {
+ mySecondOrg = new ResourceReferenceDt();
}
return mySecondOrg;
}
@@ -300,9 +289,9 @@ public class IncludeTest {
public void setSecondOrg(ResourceReferenceDt theSecondOrg) {
mySecondOrg = theSecondOrg;
}
-
+
}
-
+
/**
* Created by dsotnikov on 2/25/2014.
*/
@@ -312,7 +301,7 @@ public class IncludeTest {
public Class extends IResource> getResourceType() {
return DiagnosticReport.class;
}
-
+
@Search(queryName = "stitchedInclude")
public List stitchedInclude() {
Practitioner pr1 = new Practitioner();
@@ -330,11 +319,11 @@ public class IncludeTest {
Observation o1 = new Observation();
o1.getName().setText("Obs1");
o1.addPerformer().setResource(pr1);
-
+
Observation o2 = new Observation();
o2.getName().setText("Obs2");
o2.addPerformer().setResource(pr2);
-
+
Observation o3 = new Observation();
o3.getName().setText("Obs3");
o3.addPerformer().setResource(pr3);
@@ -345,15 +334,12 @@ public class IncludeTest {
rep.addResult().setResource(o1);
rep.addResult().setResource(o2);
rep.addResult().setResource(o3);
-
+
return Collections.singletonList(rep);
}
-
-
-
+
}
-
-
+
/**
* Created by dsotnikov on 2/25/2014.
*/
@@ -377,8 +363,7 @@ public class IncludeTest {
return Arrays.asList(p1, p2);
}
-
-
+
@Search(queryName = "extInclude")
public List extInclude() {
Organization o1 = new Organization();
@@ -408,7 +393,7 @@ public class IncludeTest {
o2.getName().setValue("o2");
o2.setId("o2");
o1.getPartOf().setResource(o2);
-
+
ExtPatient p1 = new ExtPatient();
p1.setId("p1");
p1.addIdentifier().setLabel("p1");
@@ -422,7 +407,6 @@ public class IncludeTest {
return Arrays.asList(p1, p2);
}
-
@Search(queryName = "containedInclude")
public List containedInclude() {
Organization o1 = new Organization();
@@ -440,11 +424,9 @@ public class IncludeTest {
return Arrays.asList(p1, p2);
}
-
+
@Search
- public List findPatientWithSimpleNames(
- @RequiredParam(name = Patient.SP_NAME) StringDt theName,
- @IncludeParam(allow = { "foo", "bar" }) Set theIncludes) {
+ public List findPatientWithSimpleNames(@RequiredParam(name = Patient.SP_NAME) StringDt theName, @IncludeParam(allow = { "foo", "bar" }) Set theIncludes) {
ArrayList retVal = new ArrayList();
Patient p = new Patient();
@@ -469,23 +451,21 @@ public class IncludeTest {
}
-
public static void main(String[] args) {
-
+
Organization org = new Organization();
org.setId("Organization/65546");
org.getName().setValue("Contained Test Organization");
-
+
Patient patient = new Patient();
patient.setId("Patient/1333");
patient.addIdentifier("urn:mrns", "253345");
patient.getManagingOrganization().setResource(patient);
-
-
- System.out.println(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
-
+
+ System.out.println(FhirContext.forDstu1().newXmlParser().setPrettyPrint(true).encodeResourceToString(patient));
+
patient.getManagingOrganization().getReference();
-
+
}
-
+
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java
index 98fd750b3c4..4450d67024c 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/InterceptorTest.java
@@ -27,6 +27,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.InOrder;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
@@ -53,6 +54,7 @@ public class InterceptorTest {
private static RestfulServer servlet;
private IServerInterceptor myInterceptor1;
private IServerInterceptor myInterceptor2;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testInterceptorFires() throws Exception {
@@ -101,7 +103,7 @@ public class InterceptorTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java
index 92b5b180f51..a2ef5162b9a 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/MethodPriorityTest.java
@@ -36,7 +36,7 @@ import ca.uhn.fhir.util.PortUtil;
public class MethodPriorityTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort;
private static Server ourServer;
private static RestfulServer ourServlet;
@@ -72,8 +72,7 @@ public class MethodPriorityTest {
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- ourServlet = new RestfulServer();
- ourServlet.setFhirContext(ourCtx);
+ ourServlet = new RestfulServer(ourCtx);
ourServlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
ServletHolder servletHolder = new ServletHolder(ourServlet);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java
index 77feec9e662..5ed0f3391a1 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PagingTest.java
@@ -46,6 +46,7 @@ public class PagingTest {
private static CloseableHttpClient ourClient;
private static int ourPort;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static Server ourServer;
private static FhirContext ourContext;
private static RestfulServer myRestfulServer;
@@ -270,7 +271,7 @@ public class PagingTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourContext = new FhirContext();
+ ourContext = FhirContext.forDstu1();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
@@ -278,7 +279,7 @@ public class PagingTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- myRestfulServer = new RestfulServer();
+ myRestfulServer = new RestfulServer(ourCtx);
myRestfulServer.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(myRestfulServer);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java
index 325ee42d0c4..2d2c59cadd4 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/PlainProviderTest.java
@@ -51,18 +51,17 @@ public class PlainProviderTest {
private int myPort;
private Server myServer;
private CloseableHttpClient myClient;
- private FhirContext myCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private RestfulServer myRestfulServer;
@Before
public void before() throws Exception {
myPort = PortUtil.findFreePort();
myServer = new Server(myPort);
- myCtx = new FhirContext(Patient.class);
ServletHandler proxyHandler = new ServletHandler();
ServletHolder servletHolder = new ServletHolder();
- myRestfulServer = new RestfulServer();
+ myRestfulServer = new RestfulServer(ourCtx);
servletHolder.setServlet(myRestfulServer);
proxyHandler.addServletWithMapping(servletHolder, "/fhir/context/*");
myServer.setHandler(proxyHandler);
@@ -95,7 +94,7 @@ public class PlainProviderTest {
ourLog.info("Response was:\n{}", responseContent);
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = myCtx.newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.getEntries().size());
@@ -121,7 +120,7 @@ public class PlainProviderTest {
IOUtils.closeQuietly(status.getEntity().getContent());
ourLog.info("Response was:\n{}", responseContent);
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = myCtx.newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(3, bundle.getEntries().size());
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
@@ -131,7 +130,7 @@ public class PlainProviderTest {
responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- bundle = myCtx.newXmlParser().parseBundle(responseContent);
+ bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(3, bundle.getEntries().size());
assertNull(provider.myLastSince.getValueAsString());
assertThat(provider.myLastCount.getValueAsString(), IsEqual.equalTo("12"));
@@ -140,7 +139,7 @@ public class PlainProviderTest {
responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- bundle = myCtx.newXmlParser().parseBundle(responseContent);
+ bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(3, bundle.getEntries().size());
assertThat(provider.myLastSince.getValueAsString(), StringStartsWith.startsWith("2012-01-02T00:01:02"));
assertNull(provider.myLastCount.getValueAsString());
@@ -149,7 +148,7 @@ public class PlainProviderTest {
responseContent = IOUtils.toString(status.getEntity().getContent());
IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- bundle = myCtx.newXmlParser().parseBundle(responseContent);
+ bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(3, bundle.getEntries().size());
assertNull(provider.myLastSince.getValueAsString());
assertNull(provider.myLastCount.getValueAsString());
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadDstu1Test.java
similarity index 96%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadDstu1Test.java
index 70b63010e84..6392fb9265a 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReadDstu1Test.java
@@ -1,10 +1,8 @@
package ca.uhn.fhir.rest.server;
-import static org.hamcrest.Matchers.not;
-import static org.hamcrest.Matchers.stringContainsInOrder;
+import static org.hamcrest.Matchers.*;
import static org.junit.Assert.*;
-import java.io.IOException;
import java.net.URLEncoder;
import java.util.concurrent.TimeUnit;
@@ -22,8 +20,6 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import com.google.common.net.UrlEscapers;
-
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.composite.IdentifierDt;
@@ -39,13 +35,13 @@ import ca.uhn.fhir.util.PortUtil;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class ReadTest {
+public class ReadDstu1Test {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadTest.class);
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadDstu1Test.class);
@Test
public void testReadXml() throws Exception {
@@ -68,7 +64,7 @@ public class ReadTest {
assertThat(responseContent, stringContainsInOrder("1", "\""));
assertThat(responseContent, not(stringContainsInOrder("1", "\"", "1")));
}
-
+
@Test
public void testEncodeConvertsReferencesToRelative() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient/1?_format=xml");
@@ -205,8 +201,8 @@ public class ReadTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- ourCtx = servlet.getFhirContext();
+ RestfulServer servlet = new RestfulServer(ourCtx);
+
servlet.setResourceProviders(patientProvider, new BinaryProvider(), new OrganizationProviderWithAbstractReturnType());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java
index 020b33dd062..3c793c04fb9 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ReferenceParameterTest.java
@@ -53,7 +53,7 @@ import ca.uhn.fhir.util.PortUtil;
public class ReferenceParameterTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReferenceParameterTest.class);
private static int ourPort;
private static Server ourServer;
@@ -298,9 +298,8 @@ public class ReferenceParameterTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
- ourCtx = servlet.getFhirContext();
servlet.setResourceProviders(patientProvider, new DummyOrganizationResourceProvider(), new DummyLocationResourceProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -311,8 +310,6 @@ public class ReferenceParameterTest {
HttpClientBuilder builder = HttpClientBuilder.create();
builder.setConnectionManager(connectionManager);
ourClient = builder.build();
-
- ourCtx = servlet.getFhirContext();
}
public static class DummyLocationResourceProvider implements IResourceProvider {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceMethodTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceMethodTest.java
index 9376769a601..22deabb3c20 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceMethodTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceMethodTest.java
@@ -32,7 +32,7 @@ public class ResourceMethodTest {
@Before
public void before() throws NoSuchMethodException, SecurityException {
- rm = new SearchMethodBinding(Patient.class, ResourceMethodTest.class.getMethod("foo"), new FhirContext(), null);
+ rm = new SearchMethodBinding(Patient.class, ResourceMethodTest.class.getMethod("foo"), FhirContext.forDstu1(), null);
}
@Test
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java
index 18a0b82d6bf..4d6bf68c48b 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ResourceProviderWithNoMethodsTest.java
@@ -10,6 +10,7 @@ import org.eclipse.jetty.servlet.ServletHolder;
import org.junit.After;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.Binary;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -20,7 +21,8 @@ import ca.uhn.fhir.util.PortUtil;
public class ResourceProviderWithNoMethodsTest {
private Server ourServer;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
@After
public void after() throws Exception {
ourServer.stop();
@@ -34,7 +36,7 @@ public class ResourceProviderWithNoMethodsTest {
ResourceProvider patientProvider = new ResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -56,7 +58,7 @@ public class ResourceProviderWithNoMethodsTest {
NonPublicMethodProvider patientProvider = new NonPublicMethodProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerMethodTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerMethodTest.java
index 6dbd4368eea..852e897b4ed 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerMethodTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerMethodTest.java
@@ -91,7 +91,7 @@ import ca.uhn.fhir.util.PortUtil;
public class RestfulServerMethodTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestfulServerMethodTest.class);
private static int ourPort;
private static DummyDiagnosticReportResourceProvider ourReportProvider;
@@ -943,7 +943,7 @@ public class RestfulServerMethodTest {
assertEquals("BBB", patient.getName().get(0).getGiven().get(0).getValue());
}
-
+
@Test
public void testValidate() throws Exception {
@@ -951,7 +951,7 @@ public class RestfulServerMethodTest {
patient.addName().addFamily("FOO");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -962,7 +962,7 @@ public class RestfulServerMethodTest {
assertThat(responseContent, not(containsString("\n ")));
assertEquals(200, status.getStatusLine().getStatusCode());
- OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
+ OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
assertEquals("it passed", oo.getIssueFirstRep().getDetails().getValue());
// Now should fail
@@ -971,7 +971,7 @@ public class RestfulServerMethodTest {
patient.addName().addFamily("BAR");
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
status = ourClient.execute(httpPost);
@@ -981,7 +981,7 @@ public class RestfulServerMethodTest {
ourLog.info("Response was:\n{}", responseContent);
assertEquals(422, status.getStatusLine().getStatusCode());
- oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
+ oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
assertEquals("it failed", oo.getIssueFirstRep().getDetails().getValue());
// Should fail with outcome
@@ -990,7 +990,7 @@ public class RestfulServerMethodTest {
patient.addName().addFamily("BAZ");
httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
status = ourClient.execute(httpPost);
@@ -1010,7 +1010,7 @@ public class RestfulServerMethodTest {
patient.addName().addFamily("FOO");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate?_pretty=true");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -1065,7 +1065,6 @@ public class RestfulServerMethodTest {
public static void beforeClass() throws Exception {
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
- ourCtx = new FhirContext(Patient.class);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ourReportProvider = new DummyDiagnosticReportResourceProvider();
@@ -1429,6 +1428,7 @@ public class RestfulServerMethodTest {
private Collection myResourceProviders;
public DummyRestfulServer(IResourceProvider... theResourceProviders) {
+ super(ourCtx);
myResourceProviders = new ArrayList(Arrays.asList(theResourceProviders));
}
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerSelfReferenceTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerSelfReferenceTest.java
index 2ec76f3ba3d..797a894b9e4 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerSelfReferenceTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/RestfulServerSelfReferenceTest.java
@@ -62,7 +62,7 @@ public class RestfulServerSelfReferenceTest {
int port = PortUtil.findFreePort();
Server server = new Server(port);
- RestfulServer restServer = new RestfulServer();
+ RestfulServer restServer = new RestfulServer(ourCtx);
restServer.setFhirContext(ourCtx);
restServer.setResourceProviders(new DummyPatientResourceProvider());
@@ -108,7 +108,7 @@ public class RestfulServerSelfReferenceTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer server = new RestfulServer();
+ RestfulServer server = new RestfulServer(ourCtx);
ServerProfileProvider profProvider = new ServerProfileProvider(server);
server.setFhirContext(ourCtx);
server.setResourceProviders(patientProvider, profProvider);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchSearchServerDstu1Test.java
similarity index 99%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchSearchServerDstu1Test.java
index 270678b11b9..be6e5c69b4f 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SearchSearchServerDstu1Test.java
@@ -66,11 +66,11 @@ import com.google.common.net.UrlEscapers;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class SearchTest {
+public class SearchSearchServerDstu1Test {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchTest.class);
+ private static FhirContext ourCtx = FhirContext.forDstu1();
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchSearchServerDstu1Test.class);
private static int ourPort;
private static Server ourServer;
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java
index 1e98cb7b04a..cd21f730349 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerBaseTest.java
@@ -35,7 +35,7 @@ public class ServerBaseTest {
private static CloseableHttpClient ourClient;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerBaseTest.class);
private Server myServer;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testTransaction() throws Exception {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderTest.java
index 09eeaa570c9..78b46fbcd4a 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderTest.java
@@ -41,12 +41,12 @@ import javax.servlet.http.HttpServletRequest;
public class ServerConformanceProviderTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderTest.class);
- private FhirContext myCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testSearchParameterDocumentation() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new SearchProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -68,7 +68,7 @@ public class ServerConformanceProviderTest {
assertTrue(found);
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
assertThat(conf, containsString(""));
@@ -80,7 +80,7 @@ public class ServerConformanceProviderTest {
@Test
public void testValidateGeneratedStatement() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new MultiOptionalProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -90,7 +90,7 @@ public class ServerConformanceProviderTest {
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- myCtx.newValidator().validate(conformance);
+ ourCtx.newValidator().validate(conformance);
}
@@ -98,7 +98,7 @@ public class ServerConformanceProviderTest {
@Test
public void testMultiOptionalDocumentation() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new MultiOptionalProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -119,7 +119,7 @@ public class ServerConformanceProviderTest {
}
assertTrue(found);
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
assertThat(conf, containsString(""));
@@ -130,7 +130,7 @@ public class ServerConformanceProviderTest {
@Test
public void testProviderWithRequiredAndOptional() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new ProviderWithRequiredAndOptional());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -139,7 +139,7 @@ public class ServerConformanceProviderTest {
rs.init(createServletConfig());
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
Rest rest = conformance.getRestFirstRep();
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java
index ae0d9f27a97..8eba44b4a0d 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerExtraParametersTest.java
@@ -34,14 +34,17 @@ public class ServerExtraParametersTest {
private int myPort;
private Server myServer;
private RestfulServer myServlet;
-
+ private static FhirContext ourCtx = FhirContext.forDstu1();
+
@Before
public void before() {
myPort = PortUtil.findFreePort();
myServer = new Server(myPort);
ServletHandler proxyHandler = new ServletHandler();
- myServlet = new RestfulServer();
+ myServlet = new RestfulServer(ourCtx);
+ myServlet.setFhirContext(ourCtx);
+
ServletHolder servletHolder = new ServletHolder(myServlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
myServer.setHandler(proxyHandler);
@@ -55,7 +58,7 @@ public class ServerExtraParametersTest {
myServer.start();
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = ourCtx;
PatientClient client = ctx.newRestfulClient(PatientClient.class, "http://localhost:" + myPort + "/");
List actualPatients = client.searchForPatients(new StringDt("AAAABBBB"));
@@ -72,7 +75,7 @@ public class ServerExtraParametersTest {
myServer.start();
- FhirContext ctx = new FhirContext();
+ FhirContext ctx = ourCtx;
IGenericClient client = ctx.newRestfulGenericClient("http://localhost:" + myPort + "/");
client.registerInterceptor(new LoggingInterceptor(true));
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java
index 042b4e2f08c..b3c7bba2236 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerFeaturesTest.java
@@ -27,6 +27,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.composite.HumanNameDt;
@@ -51,7 +52,8 @@ public class ServerFeaturesTest {
private static int ourPort;
private static Server ourServer;
private static RestfulServer servlet;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
@Test
public void testPrettyPrint() throws Exception {
/*
@@ -295,7 +297,7 @@ public class ServerFeaturesTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionTest.java
index 934eaad4f0c..23338deccb7 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionTest.java
@@ -11,6 +11,7 @@ import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.context.FhirVersionEnum;
import ca.uhn.fhir.model.api.IElement;
import ca.uhn.fhir.model.api.IResource;
@@ -27,20 +28,21 @@ import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.param.StringParam;
public class ServerInvalidDefinitionTest {
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
/**
* Normal, should initialize properly
*/
@Test()
public void testBaseline() throws ServletException {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new InstantiableTypeForResourceProvider());
srv.init();
}
@Test
public void testInvalidSpecialNameResourceProvider() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new InvalidSpecialParameterNameResourceProvider());
try {
@@ -54,7 +56,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testMultipleResourceProviderForSameType() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new PatientResourceProvider1(), new PatientResourceProvider2());
try {
@@ -69,7 +71,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testPrivateResourceProvider() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new PrivateResourceProvider());
try {
@@ -83,7 +85,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testProviderWithNonResourceType() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new ProviderWithNonResourceType());
try {
@@ -97,7 +99,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testReadMethodWithoutIdParamProvider() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new ReadMethodWithoutIdParamProvider());
try {
@@ -110,7 +112,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testReadMethodWithSearchParameters() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new ReadMethodWithSearchParamProvider());
try {
@@ -123,7 +125,7 @@ public class ServerInvalidDefinitionTest {
@Test
public void testSearchWithId() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setResourceProviders(new SearchWithIdParamProvider());
try {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerProvidedResourceScannerTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerProvidedResourceScannerTest.java
index 53ccb30a8bc..a7911a9a2f6 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerProvidedResourceScannerTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ServerProvidedResourceScannerTest.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.api.annotation.ProvidesResources;
import ca.uhn.fhir.model.api.annotation.ResourceDef;
@@ -9,9 +10,11 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.annotation.IdParam;
import ca.uhn.fhir.rest.annotation.Read;
import junit.framework.TestCase;
+
import org.junit.Test;
import javax.servlet.ServletException;
+
import java.util.ArrayList;
import java.util.List;
@@ -19,7 +22,9 @@ import java.util.List;
* Created by Bill de Beaubien on 11/1/2014.
*/
public class ServerProvidedResourceScannerTest extends TestCase {
- @Test
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
+ @Test
public void testWhenRestfulServerInitialized_annotatedResources_shouldBeAddedToContext() throws ServletException {
// Given
MyServer server = new MyServer();
@@ -35,7 +40,7 @@ public class ServerProvidedResourceScannerTest extends TestCase {
@Test
public void testWhenUnannotatedServerInitialized_annotatedResources_shouldNotBeAddedToContext() throws ServletException {
// Given
- RestfulServer server = new RestfulServer();
+ RestfulServer server = new RestfulServer(ourCtx);
// When
server.init();
@@ -67,10 +72,23 @@ public class ServerProvidedResourceScannerTest extends TestCase {
@ProvidesResources(resources={CustomPatient.class,CustomObservation.class})
class MyServer extends RestfulServer {
+
+ private static final long serialVersionUID = 1L;
+
+ public MyServer() {
+ super(ourCtx);
+ }
+
}
class MyServerWithProvider extends RestfulServer {
- @Override
+ private static final long serialVersionUID = 1L;
+
+ public MyServerWithProvider() {
+ super(ourCtx);
+ }
+
+ @Override
protected void initialize() throws ServletException {
List providers = new ArrayList();
providers.add(new MyObservationProvider());
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SortTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SortTest.java
index fe49b53e367..e58f01353bf 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SortTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/SortTest.java
@@ -36,10 +36,10 @@ import ca.uhn.fhir.util.PortUtil;
public class SortTest {
private static CloseableHttpClient ourClient;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SortTest.class);
private static int ourPort;
private static Server ourServer;
-
+ private static FhirContext ourCtx = FhirContext.forDstu1();
+
@Test
public void testNoSort() throws Exception {
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?name=Hello");
@@ -47,7 +47,7 @@ public class SortTest {
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
@@ -63,7 +63,7 @@ public class SortTest {
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
@@ -77,7 +77,7 @@ public class SortTest {
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
@@ -91,7 +91,7 @@ public class SortTest {
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
@@ -110,7 +110,7 @@ public class SortTest {
String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(1, bundle.size());
Patient p = bundle.getResources(Patient.class).get(0);
@@ -136,7 +136,7 @@ public class SortTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java
index eeeb582c0c1..03ecdc211f6 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/StringParameterTest.java
@@ -34,69 +34,30 @@ import ca.uhn.fhir.util.PortUtil;
public class StringParameterTest {
private static CloseableHttpClient ourClient;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(StringParameterTest.class);
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort;
+
private static Server ourServer;
- @Test
- public void testSearchWithFormatAndPretty() throws Exception {
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa&_format=xml&_pretty=true");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
- }
- }
-
- @Test
- public void testSearchNormalMatch() throws Exception {
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
- }
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=AAA");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
- IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
- }
- {
- HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=BBB");
- HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
-
- assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
- }
- }
-
@Test
public void testRawString() throws Exception {
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=aaa");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?plain=BBB");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
}
@@ -105,26 +66,29 @@ public class StringParameterTest {
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=aaa");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=AAA");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str:exact=BBB");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(0, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
}
@@ -133,14 +97,60 @@ public class StringParameterTest {
{
HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?ccc:exact=aaa");
HttpResponse status = ourClient.execute(httpGet);
- String responseContent = IOUtils.toString(status.getEntity().getContent()); IOUtils.closeQuietly(status.getEntity().getContent());
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
assertEquals(200, status.getStatusLine().getStatusCode());
- assertEquals(1, new FhirContext().newXmlParser().parseBundle(responseContent).getEntries().size());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
+ }
+ }
+
+ @Test
+ public void testSearchNormalMatch() throws Exception {
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
+ }
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=AAA");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
+ }
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=BBB");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+ assertEquals(0, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
+ }
+ }
+
+ @Test
+ public void testSearchWithFormatAndPretty() throws Exception {
+ {
+ HttpGet httpGet = new HttpGet("http://localhost:" + ourPort + "/Patient?str=aaa&_format=xml&_pretty=true");
+ HttpResponse status = ourClient.execute(httpGet);
+ String responseContent = IOUtils.toString(status.getEntity().getContent());
+ IOUtils.closeQuietly(status.getEntity().getContent());
+
+ assertEquals(200, status.getStatusLine().getStatusCode());
+ assertEquals(1, ourCtx.newXmlParser().parseBundle(responseContent).getEntries().size());
}
}
-
@AfterClass
public static void afterClass() throws Exception {
ourServer.stop();
@@ -154,7 +164,8 @@ public class StringParameterTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
+ servlet.setFhirContext(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -173,6 +184,19 @@ public class StringParameterTest {
*/
public static class DummyPatientResourceProvider implements IResourceProvider {
+ @Search
+ public List findPatientByString(@RequiredParam(name = "plain") String theParam) {
+ ArrayList retVal = new ArrayList();
+
+ if (theParam.toLowerCase().equals("aaa")) {
+ Patient patient = new Patient();
+ patient.setId("1");
+ retVal.add(patient);
+ }
+
+ return retVal;
+ }
+
@Search
public List findPatientByStringParam(@RequiredParam(name = "str") StringParam theParam) {
ArrayList retVal = new ArrayList();
@@ -191,19 +215,6 @@ public class StringParameterTest {
return retVal;
}
- @Search
- public List findPatientByString(@RequiredParam(name = "plain") String theParam) {
- ArrayList retVal = new ArrayList();
-
- if (theParam.toLowerCase().equals("aaa")) {
- Patient patient = new Patient();
- patient.setId("1");
- retVal.add(patient);
- }
-
- return retVal;
- }
-
@Search
public List findPatientWithOptional(@OptionalParam(name = "ccc") StringParam theParam) {
ArrayList retVal = new ArrayList();
@@ -222,7 +233,6 @@ public class StringParameterTest {
return retVal;
}
-
@Override
public Class extends IResource> getResourceType() {
return Patient.class;
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java
index 1fa5a8f7739..5a88a4795cf 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TagsServerTest.java
@@ -240,7 +240,7 @@ public class TagsServerTest {
ourProvider = new DummyProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setPlainProviders(ourProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java
index 67e82345bdf..fe3a66721cd 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionTest.java
@@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
public class TransactionTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static boolean ourDropFirstResource;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionTest.class);
private static int ourPort;
@@ -88,7 +88,7 @@ public class TransactionTest {
ourLog.info(responseContent);
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(3, bundle.size());
BundleEntry entry0 = bundle.getEntries().get(0);
@@ -144,7 +144,7 @@ public class TransactionTest {
ourLog.info(responseContent);
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(2, bundle.size());
BundleEntry entry1 = bundle.getEntries().get(0);
@@ -195,7 +195,7 @@ public class TransactionTest {
ourLog.info(responseContent);
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(4, bundle.size());
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
@@ -228,7 +228,7 @@ public class TransactionTest {
ourServer = new Server(ourPort);
DummyProvider patientProvider = new DummyProvider();
- RestfulServer server = new RestfulServer();
+ RestfulServer server = new RestfulServer(ourCtx);
server.setProviders(patientProvider);
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java
index 0d4ec224d6a..d0153e77326 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleParamTest.java
@@ -40,7 +40,7 @@ import ca.uhn.fhir.util.PortUtil;
public class TransactionWithBundleParamTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionWithBundleParamTest.class);
private static int ourPort;
private static boolean ourReturnOperationOutcome;
@@ -144,7 +144,7 @@ public class TransactionWithBundleParamTest {
ourLog.info(responseContent);
- Bundle bundle = new FhirContext().newXmlParser().parseBundle(responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseBundle(responseContent);
assertEquals(4, bundle.size());
assertEquals(OperationOutcome.class, bundle.getEntries().get(0).getResource().getClass());
@@ -177,7 +177,7 @@ public class TransactionWithBundleParamTest {
ourServer = new Server(ourPort);
DummyProvider patientProvider = new DummyProvider();
- RestfulServer server = new RestfulServer();
+ RestfulServer server = new RestfulServer(ourCtx);
server.setProviders(patientProvider);
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java
index b4ac663f43a..4a19c53f994 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/UpdateTest.java
@@ -47,6 +47,7 @@ public class UpdateTest {
private static int ourPort;
private static DiagnosticReportProvider ourReportProvider;
private static Server ourServer;
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testUpdate() throws Exception {
@@ -55,7 +56,7 @@ public class UpdateTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -64,7 +65,7 @@ public class UpdateTest {
ourLog.info("Response was:\n{}", responseContent);
- OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
+ OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
assertEquals(200, status.getStatusLine().getStatusCode());
@@ -81,7 +82,7 @@ public class UpdateTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/001CREATE");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -90,7 +91,7 @@ public class UpdateTest {
ourLog.info("Response was:\n{}", responseContent);
- OperationOutcome oo = new FhirContext().newXmlParser().parseResource(OperationOutcome.class, responseContent);
+ OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, responseContent);
assertEquals("OODETAILS", oo.getIssueFirstRep().getDetails().getValue());
assertEquals(201, status.getStatusLine().getStatusCode());
@@ -105,7 +106,7 @@ public class UpdateTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/AAAAAA");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -125,7 +126,7 @@ public class UpdateTest {
dr.addCodedDiagnosis().addCoding().setCode("AAA");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -143,7 +144,7 @@ public class UpdateTest {
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"urn:animals\", Cat; scheme=\"urn:animals\"");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -153,7 +154,7 @@ public class UpdateTest {
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; label=\"aa\"; scheme=\"urn:animals\", Cat; label=\"bb\"; scheme=\"urn:animals\"");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -171,7 +172,7 @@ public class UpdateTest {
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"animals\"");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -188,7 +189,7 @@ public class UpdateTest {
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -197,7 +198,7 @@ public class UpdateTest {
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\";");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -214,7 +215,7 @@ public class UpdateTest {
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPost);
assertEquals(1, ourReportProvider.getLastTags().size());
assertEquals(new Tag("http://foo", "Dog", "aaaa"), ourReportProvider.getLastTags().get(0));
@@ -222,7 +223,7 @@ public class UpdateTest {
httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPost.addHeader("Category", "Dog; scheme=\"http://foo\"; label=\"aaaa\"; ");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(dr), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
status=ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -239,7 +240,7 @@ public class UpdateTest {
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPut.addHeader("Content-Location", "/DiagnosticReport/001/_history/004");
- httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPut.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPut);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -261,7 +262,7 @@ public class UpdateTest {
HttpPut httpPut = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
httpPut.addHeader("Content-Location", "/Patient/001/_history/002");
- httpPut.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPut.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPut);
String responseContent = IOUtils.toString(status.getEntity().getContent());
@@ -282,7 +283,7 @@ public class UpdateTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/DiagnosticReport/001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
ourClient.execute(httpPost);
fail();
@@ -295,7 +296,7 @@ public class UpdateTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Organization/001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
CloseableHttpResponse status = ourClient.execute(httpPost);
IOUtils.closeQuietly(status.getEntity().getContent());
@@ -320,7 +321,7 @@ public class UpdateTest {
ourReportProvider = new DiagnosticReportProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider, ourReportProvider, new ObservationProvider(), new OrganizationResourceProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
@@ -386,7 +387,6 @@ public class UpdateTest {
return Observation.class;
}
- @SuppressWarnings("unused")
@Update()
public MethodOutcome updateDiagnosticReportWithVersion(@IdParam IdDt theId, @ResourceParam DiagnosticOrder thePatient) {
/*
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu1Test.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu1Test.java
index b9a2c531362..aeed91e6264 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu1Test.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu1Test.java
@@ -39,8 +39,8 @@ public class ValidateDstu1Test {
private static CloseableHttpClient ourClient;
private static EncodingEnum ourLastEncoding;
private static String ourLastResourceBody;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateDstu1Test.class);
private static int ourPort;
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static Server ourServer;
@Before()
@@ -57,7 +57,7 @@ public class ValidateDstu1Test {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/_validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -76,7 +76,7 @@ public class ValidateDstu1Test {
org.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization/_validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(org), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
assertEquals(204, status.getStatusLine().getStatusCode());
@@ -99,7 +99,7 @@ public class ValidateDstu1Test {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider, new OrganizationProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/AuditingInterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/AuditingInterceptorTest.java
index 16b08c60e4f..67dbb70f208 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/AuditingInterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/AuditingInterceptorTest.java
@@ -29,6 +29,7 @@ import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.composite.BaseCodingDt;
import ca.uhn.fhir.model.base.resource.BaseSecurityEvent;
@@ -64,6 +65,7 @@ public class AuditingInterceptorTest {
private static Server ourServer;
private static RestfulServer servlet;
private IServerInterceptor myInterceptor;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
private class MockDataStore implements IAuditDataStore {
@@ -190,7 +192,7 @@ public class AuditingInterceptorTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionHandlingInterceptorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionHandlingInterceptorTest.java
index 1725596a958..a5fe6d0c4a0 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionHandlingInterceptorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionHandlingInterceptorTest.java
@@ -24,6 +24,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
import ca.uhn.fhir.model.dstu.resource.Patient;
@@ -52,6 +53,7 @@ public class ExceptionHandlingInterceptorTest {
private static Server ourServer;
private static RestfulServer servlet;
private static ExceptionHandlingInterceptor myInterceptor;
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
@Before
public void before() {
@@ -109,7 +111,7 @@ public class ExceptionHandlingInterceptorTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionInterceptorMethodTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionInterceptorMethodTest.java
index a03fce86c87..e403771ff93 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionInterceptorMethodTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/rest/server/interceptor/ExceptionInterceptorMethodTest.java
@@ -27,6 +27,7 @@ import org.mockito.ArgumentCaptor;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.rest.annotation.Search;
import ca.uhn.fhir.rest.method.RequestDetails;
@@ -43,7 +44,8 @@ public class ExceptionInterceptorMethodTest {
private static RestfulServer servlet;
private IServerInterceptor myInterceptor;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionInterceptorMethodTest.class);
-
+ private static final FhirContext ourCtx = FhirContext.forDstu1();
+
@Test
public void testThrowUnprocessableEntityException() throws Exception {
@@ -112,7 +114,7 @@ public class ExceptionInterceptorMethodTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/util/FhirTerserTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/util/FhirTerserTest.java
index 0ab2f4ca0c8..cc15830b3ad 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/util/FhirTerserTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/util/FhirTerserTest.java
@@ -17,7 +17,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
public class FhirTerserTest {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testGetAllPopulatedChildElementsOfType() {
@@ -29,7 +29,7 @@ public class FhirTerserTest {
p.addAddress().addLine("Line2");
p.addName().addFamily("Line3");
- FhirTerser t = new FhirContext().newTerser();
+ FhirTerser t = ourCtx.newTerser();
List strings = t.getAllPopulatedChildElementsOfType(p, StringDt.class);
assertEquals(3, strings.size());
@@ -43,7 +43,7 @@ public class FhirTerserTest {
Observation obs = new Observation();
obs.setValue(new QuantityDt(123L));
- FhirTerser t = new FhirContext().newTerser();
+ FhirTerser t = ourCtx.newTerser();
// As string
{
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ResourceValidatorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ResourceValidatorTest.java
index 456b00d214f..e098b2e6d96 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ResourceValidatorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ResourceValidatorTest.java
@@ -26,7 +26,7 @@ import static org.junit.Assert.fail;
public class ResourceValidatorTest {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu1();
private static Locale ourDefaultLocale;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceValidatorTest.class);
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu1Test.java
similarity index 98%
rename from hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java
rename to hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu1Test.java
index 051bbde3e32..d5ee0386698 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu1Test.java
@@ -13,7 +13,7 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
-public class ValidationResultTest {
+public class ValidationResultDstu1Test {
@Test
public void isSuccessful_IsTrueForNullOperationOutcome() {
diff --git a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java
index f73ae04ed7c..87a40cb679a 100644
--- a/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java
+++ b/hapi-fhir-structures-dstu/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java
@@ -8,12 +8,12 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.validation.FhirValidator;
public class ValidatorInstantiatorTest {
+ private static FhirContext ourCtx = FhirContext.forDstu1();
@Test
public void testValidator() {
- FhirContext ctx = new FhirContext();
- FhirValidator val = ctx.newValidator();
+ FhirValidator val = ourCtx.newValidator();
// We have a full classpath, so take advantage
assertTrue(val.isValidateAgainstStandardSchema());
diff --git a/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml b/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml
index 996190aeccf..e5cbbb9c22e 100644
--- a/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml
+++ b/hapi-fhir-structures-dstu/src/test/resources/logback-test.xml
@@ -23,8 +23,8 @@
-->
-
+
-
\ No newline at end of file
+
diff --git a/hapi-fhir-structures-dstu/src/test/resources/narrative/customnarrative.properties b/hapi-fhir-structures-dstu/src/test/resources/narrative/customnarrative.properties
index 4f4404c5495..ff22e4e5016 100644
--- a/hapi-fhir-structures-dstu/src/test/resources/narrative/customnarrative.properties
+++ b/hapi-fhir-structures-dstu/src/test/resources/narrative/customnarrative.properties
@@ -9,7 +9,7 @@
# Format is file:/path/foo.html or classpath:/com/classpath/foo.html
#
practitioner.class=ca.uhn.fhir.model.dstu.resource.Practitioner
-practitioner.narrative=file:src/test/resources/narrative/Practitioner.html
+practitioner.narrative=classpath:narrative/Practitioner.html
# You may also override/define behaviour for datatypes
humanname.class=ca.uhn.fhir.model.dstu.composite.HumanNameDt
diff --git a/hapi-fhir-structures-dstu2/.gitignore b/hapi-fhir-structures-dstu2/.gitignore
index be015a3d566..30eac0753b3 100644
--- a/hapi-fhir-structures-dstu2/.gitignore
+++ b/hapi-fhir-structures-dstu2/.gitignore
@@ -142,3 +142,6 @@ local.properties
/target/
/target/
/target/
+/target/
+/target/
+/target/
diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml
index 6c2cc96eddc..789bbe6c060 100644
--- a/hapi-fhir-structures-dstu2/pom.xml
+++ b/hapi-fhir-structures-dstu2/pom.xml
@@ -40,7 +40,7 @@
xmlunitxmlunit
- 1.6
+ ${xmlunit_version}test
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/Dstu2EnvTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/Dstu2EnvTest.java
deleted file mode 100644
index 77eb1431887..00000000000
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/Dstu2EnvTest.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package ca.uhn.fhir;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import ca.uhn.fhir.context.FhirContext;
-import ca.uhn.fhir.context.FhirVersionEnum;
-
-public class Dstu2EnvTest {
-
- @Test
- public void testCorrectDefault() {
- FhirContext ctx = new FhirContext();
- assertEquals("new FhirContext() is creating a context with the wrong FHIR versions. Something is probably wrong with the classpath.", FhirVersionEnum.DSTU2, ctx.getVersion().getVersion());
- }
-}
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java
similarity index 96%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java
index 100fc199630..8cad29650a8 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/model/primitive/BaseDateTimeDtDstu2Test.java
@@ -15,9 +15,9 @@ import org.junit.Test;
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
-public class BaseDateTimeDtTest {
+public class BaseDateTimeDtDstu2Test {
private static Locale ourDefaultLocale;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtTest.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseDateTimeDtDstu2Test.class);
private SimpleDateFormat myDateInstantParser;
@Before
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorDstu2Test.java
similarity index 93%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorDstu2Test.java
index 8151d7ac233..aff14d39eb0 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/BaseThymeleafNarrativeGeneratorDstu2Test.java
@@ -4,8 +4,8 @@ import static org.junit.Assert.assertEquals;
import org.junit.Test;
-public class BaseThymeleafNarrativeGeneratorTest {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseThymeleafNarrativeGeneratorTest.class);
+public class BaseThymeleafNarrativeGeneratorDstu2Test {
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseThymeleafNarrativeGeneratorDstu2Test.class);
@Test
public void testTrimWhitespace() {
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java
similarity index 77%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java
index c6b8063e6e4..fe40d0e96c3 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/CustomThymeleafNarrativeGeneratorDstu2Test.java
@@ -9,16 +9,17 @@ import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.composite.NarrativeDt;
import ca.uhn.fhir.model.dstu2.resource.Practitioner;
-public class CustomThymeleafNarrativeGeneratorTest {
+public class CustomThymeleafNarrativeGeneratorDstu2Test {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorTest.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomThymeleafNarrativeGeneratorDstu2Test.class);
private static FhirContext ourCtx = FhirContext.forDstu2();
@Test
public void testGenerator() {
- CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
+// CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("file:src/test/resources/narrative/customnarrative.properties");
+ CustomThymeleafNarrativeGenerator gen = new CustomThymeleafNarrativeGenerator("classpath:narrative/customnarrative_dstu2.properties");
ourCtx.setNarrativeGenerator(gen);
Practitioner p = new Practitioner();
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
index c85b2ef5c2e..3ac210921b1 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/narrative/DefaultThymeleafNarrativeGeneratorTestDstu2.java
@@ -33,7 +33,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
import ca.uhn.fhir.parser.DataFormatException;
public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
- private FhirContext myCtx;
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(DefaultThymeleafNarrativeGeneratorTestDstu2.class);
private DefaultThymeleafNarrativeGenerator myGen;
@@ -44,8 +44,7 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
myGen.setIgnoreFailures(false);
myGen.setIgnoreMissingTemplates(false);
- myCtx = new FhirContext();
- myCtx.setNarrativeGenerator(myGen);
+ ourCtx.setNarrativeGenerator(myGen);
}
@Test
@@ -125,7 +124,7 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
"";
//@formatter:on
- OperationOutcome oo = myCtx.newXmlParser().parseResource(OperationOutcome.class, parse);
+ OperationOutcome oo = ourCtx.newXmlParser().parseResource(OperationOutcome.class, parse);
// String output = gen.generateTitle(oo);
// ourLog.info(output);
@@ -188,7 +187,7 @@ public class DefaultThymeleafNarrativeGeneratorTestDstu2 {
// Now try it with the parser
- output = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value);
+ output = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(value);
ourLog.info(output);
assertThat(output, StringContains.containsString("
Some & Diagnostic Report
"));
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
index b591f0c7b09..5b3c0218af8 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserDstu2Test.java
@@ -232,7 +232,7 @@ public class JsonParserDstu2Test {
report.getContained().getContainedResources().add(obsv);
report.addResult().setResource(obsv);
- IParser parser = new FhirContext().newXmlParser().setPrettyPrint(true);
+ IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
String message = parser.encodeResourceToString(report);
ourLog.info(message);
Assert.assertThat(message, containsString("contained"));
@@ -247,12 +247,12 @@ public class JsonParserDstu2Test {
e.setResource(new Patient());
b.addCategory("scheme", "term", "label");
- String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
+ String val = ourCtx.newJsonParser().setPrettyPrint(false).encodeBundleToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
- b = new FhirContext().newJsonParser().parseBundle(val);
+ b = ourCtx.newJsonParser().parseBundle(val);
assertEquals(1, b.getEntries().size());
}
@@ -268,11 +268,11 @@ public class JsonParserDstu2Test {
Entry e = b.addEntry();
e.setResource(new Patient());
- String val = new FhirContext().newJsonParser().setPrettyPrint(false).encodeResourceToString(b);
+ String val = ourCtx.newJsonParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
- val = new FhirContext().newXmlParser().setPrettyPrint(false).encodeResourceToString(b);
+ val = ourCtx.newXmlParser().setPrettyPrint(false).encodeResourceToString(b);
ourLog.info(val);
assertThat(val, not(containsString("text")));
@@ -297,7 +297,7 @@ public class JsonParserDstu2Test {
obsv.setId("#123");
report.addResult().setReference("#123");
- IParser parser = new FhirContext().newXmlParser().setPrettyPrint(true);
+ IParser parser = ourCtx.newXmlParser().setPrettyPrint(true);
String message = parser.encodeResourceToString(report);
ourLog.info(message);
Assert.assertThat(message, containsString("contained"));
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeDstu2Test.java
similarity index 88%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeDstu2Test.java
index 6a5923189a8..e42757332d1 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/BundleTypeDstu2Test.java
@@ -1,9 +1,7 @@
package ca.uhn.fhir.rest.client;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
import java.io.StringReader;
import java.nio.charset.Charset;
@@ -27,14 +25,13 @@ import org.mockito.internal.stubbing.defaultanswers.ReturnsDeepStubs;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.Bundle;
-import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.valueset.BundleTypeEnum;
import ca.uhn.fhir.rest.server.Constants;
-public class BundleTypeTest {
+public class BundleTypeDstu2Test {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BundleTypeTest.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BundleTypeDstu2Test.class);
private FhirContext ourCtx;
private HttpClient ourHttpClient;
@@ -46,7 +43,7 @@ public class BundleTypeTest {
ourHttpClient = mock(HttpClient.class, new ReturnsDeepStubs());
ourCtx.getRestfulClientFactory().setHttpClient(ourHttpClient);
- ourCtx.getRestfulClientFactory().setServerValidationModeEnum(ServerValidationModeEnum.NEVER);
+ ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
ourHttpResponse = mock(HttpResponse.class, new ReturnsDeepStubs());
}
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientDstu2Test.java
similarity index 99%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientDstu2Test.java
index cbb8b3bbd5e..74b3e2e614d 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientDstu2Test.java
@@ -39,7 +39,7 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class ETagClientTest {
+public class ETagClientDstu2Test {
private static FhirContext ourCtx;
private HttpClient myHttpClient;
@@ -283,7 +283,7 @@ public class ETagClientTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2();
}
}
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientDstu2Test.java
similarity index 99%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientDstu2Test.java
index a8997359971..ca9eb53ed4b 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/client/OperationClientDstu2Test.java
@@ -38,9 +38,9 @@ import ca.uhn.fhir.rest.annotation.OperationParam;
import ca.uhn.fhir.rest.client.api.IBasicClient;
import ca.uhn.fhir.rest.server.Constants;
-public class OperationClientTest {
+public class OperationClientDstu2Test {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(OperationClientTest.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(OperationClientDstu2Test.class);
private FhirContext ourCtx;
private HttpClient ourHttpClient;
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BinaryTestDstu2.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BinaryTestDstu2.java
index def08cc63f7..08ebbc7aa49 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BinaryTestDstu2.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BinaryTestDstu2.java
@@ -46,7 +46,7 @@ import ca.uhn.fhir.util.PortUtil;
public class BinaryTestDstu2 {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static Binary ourLast;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BinaryTestDstu2.class);
@@ -186,7 +186,7 @@ public class BinaryTestDstu2 {
ResourceProvider patientProvider = new ResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BundleTypeInResponseTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BundleTypeInResponseTest.java
index 67ccabc5262..67e76ee64a3 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BundleTypeInResponseTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/BundleTypeInResponseTest.java
@@ -34,7 +34,7 @@ import ca.uhn.fhir.util.PortUtil;
public class BundleTypeInResponseTest {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BundleTypeInResponseTest.class);
private static int ourPort;
@@ -69,7 +69,7 @@ public class BundleTypeInResponseTest {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.getFhirContext().setNarrativeGenerator(new DefaultThymeleafNarrativeGenerator());
servlet.setResourceProviders(patientProvider);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/CreateConditionalTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/CreateConditionalTest.java
index 6ad36c6d173..446b33ee590 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/CreateConditionalTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/CreateConditionalTest.java
@@ -52,6 +52,7 @@ public class CreateConditionalTest {
private static IdDt ourLastId;
private static IdDt ourLastIdParam;
private static boolean ourLastRequestWasSearch;
+ private static FhirContext ourCtx = FhirContext.forDstu2();
@@ -71,7 +72,7 @@ public class CreateConditionalTest {
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
httpPost.addHeader(Constants.HEADER_IF_NONE_EXIST, "Patient?identifier=system%7C001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -97,7 +98,7 @@ public class CreateConditionalTest {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/2?_format=true&_pretty=true");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -153,7 +154,7 @@ public class CreateConditionalTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/DeleteConditionalTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/DeleteConditionalTest.java
index 280d8b3effe..6b193300dec 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/DeleteConditionalTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/DeleteConditionalTest.java
@@ -18,6 +18,7 @@ import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.primitive.IdDt;
@@ -34,7 +35,7 @@ public class DeleteConditionalTest {
private static CloseableHttpClient ourClient;
private static String ourLastConditionalUrl;
private static int ourPort;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu2();
private static Server ourServer;
private static IdDt ourLastIdParam;
@@ -91,7 +92,7 @@ public class DeleteConditionalTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ETagServerTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ETagServerTest.java
index b7f194cddb3..1318a12cfa9 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ETagServerTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ETagServerTest.java
@@ -171,7 +171,7 @@ public class ETagServerTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
ourCtx = servlet.getFhirContext();
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeAndRevincludeParameterTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeAndRevincludeParameterTest.java
index 4c9f88016af..98af0b55a13 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeAndRevincludeParameterTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeAndRevincludeParameterTest.java
@@ -85,13 +85,12 @@ public class IncludeAndRevincludeParameterTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- servlet.setFhirContext(ourCtx);
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(new DummyPatientResourceProvider());
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeDstu2Test.java
index f0d8eab9ad6..7fd65eb5238 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/IncludeDstu2Test.java
@@ -270,15 +270,14 @@ public class IncludeDstu2Test {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
- servlet.setFhirContext(ourCtx);
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider, new DummyDiagnosticReportResourceProvider());
servlet.setBundleInclusionRule(BundleInclusionRule.BASED_ON_RESOURCE_PRESENCE);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationServerTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationServerTest.java
index 74b063b7c69..48249943126 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationServerTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/OperationServerTest.java
@@ -334,7 +334,7 @@ public class OperationServerTest {
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setPagingProvider(new FifoMemoryPagingProvider(10).setDefaultPageSize(2));
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/PreferTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/PreferTest.java
index 9915ce84b78..6daf96cba5b 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/PreferTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/PreferTest.java
@@ -39,7 +39,7 @@ public class PreferTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PreferTest.class);
private static int ourPort;
private static Server ourServer;
-
+ private static FhirContext ourCtx = FhirContext.forDstu2();
@Test
@@ -49,7 +49,7 @@ public class PreferTest {
patient.addIdentifier().setValue("002");
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -81,7 +81,7 @@ public class PreferTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadDstu2Test.java
similarity index 96%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadDstu2Test.java
index a0f41c08def..159416ebb3f 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ReadDstu2Test.java
@@ -30,13 +30,13 @@ import ca.uhn.fhir.util.PortUtil;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class ReadTest {
+public class ReadDstu2Test {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
-
+ private static FhirContext ourCtx = FhirContext.forDstu2();
+
/**
* In DSTU2+ the resource ID appears in the resource body
*/
@@ -75,14 +75,13 @@ public class ReadTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setFhirContext(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java
index cf689c9ac88..830e7cd04dc 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchDstu2Test.java
@@ -35,7 +35,7 @@ import ca.uhn.fhir.util.PortUtil;
public class SearchDstu2Test {
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchDstu2Test.class);
private static int ourPort;
@@ -100,7 +100,7 @@ public class SearchDstu2Test {
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchWithDstu2BundleTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchWithDstu2BundleTest.java
index b9b963414e4..bdb22d397b7 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchWithDstu2BundleTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/SearchWithDstu2BundleTest.java
@@ -30,7 +30,7 @@ public class SearchWithDstu2BundleTest {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
- private static FhirContext ourCtx;
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SearchWithDstu2BundleTest.class);
@Test
@@ -69,14 +69,13 @@ public class SearchWithDstu2BundleTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext();
ourPort = PortUtil.findFreePort();
ourServer = new Server(ourPort);
DummyPatientResourceProvider patientProvider = new DummyPatientResourceProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setFhirContext(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderDstu2Test.java
index a4e23c221fd..e22dcbe6f8c 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerConformanceProviderDstu2Test.java
@@ -46,12 +46,12 @@ import ca.uhn.fhir.rest.server.provider.dstu2.ServerConformanceProvider;
public class ServerConformanceProviderDstu2Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ServerConformanceProviderDstu2Test.class);
- private FhirContext myCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
@Test
public void testSearchParameterDocumentation() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new SearchProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -73,7 +73,7 @@ public class ServerConformanceProviderDstu2Test {
assertTrue(found);
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
assertThat(conf, containsString(""));
@@ -84,7 +84,7 @@ public class ServerConformanceProviderDstu2Test {
@Test
public void testOperationDocumentation() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new SearchProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -106,7 +106,7 @@ public class ServerConformanceProviderDstu2Test {
assertTrue(found);
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
assertThat(conf, containsString(""));
@@ -117,7 +117,7 @@ public class ServerConformanceProviderDstu2Test {
@Test
public void testExtendedOperationReturningBundle() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new ProviderWithExtendedOperationReturningBundle());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -127,7 +127,7 @@ public class ServerConformanceProviderDstu2Test {
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = myCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
}
@@ -135,7 +135,7 @@ public class ServerConformanceProviderDstu2Test {
@Test
public void testValidateGeneratedStatement() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new MultiOptionalProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -145,7 +145,7 @@ public class ServerConformanceProviderDstu2Test {
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- assertTrue(myCtx.newValidator().validateWithResult(conformance).isSuccessful());
+ assertTrue(ourCtx.newValidator().validateWithResult(conformance).isSuccessful());
}
@@ -153,7 +153,7 @@ public class ServerConformanceProviderDstu2Test {
@Test
public void testMultiOptionalDocumentation() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new MultiOptionalProvider());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -175,7 +175,7 @@ public class ServerConformanceProviderDstu2Test {
assertTrue(found);
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
assertThat(conf, containsString(""));
@@ -186,7 +186,7 @@ public class ServerConformanceProviderDstu2Test {
@Test
public void testProviderWithRequiredAndOptional() throws Exception {
- RestfulServer rs = new RestfulServer();
+ RestfulServer rs = new RestfulServer(ourCtx);
rs.setProviders(new ProviderWithRequiredAndOptional());
ServerConformanceProvider sc = new ServerConformanceProvider(rs);
@@ -195,7 +195,7 @@ public class ServerConformanceProviderDstu2Test {
rs.init(createServletConfig());
Conformance conformance = sc.getServerConformance(createHttpServletRequest());
- String conf = new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
+ String conf = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(conformance);
ourLog.info(conf);
Rest rest = conformance.getRestFirstRep();
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionDstu2Test.java
index bfdecac3e10..04eec27dd26 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ServerInvalidDefinitionDstu2Test.java
@@ -20,7 +20,7 @@ public class ServerInvalidDefinitionDstu2Test {
@Test
public void testOperationReturningOldBundleProvider() {
- RestfulServer srv = new RestfulServer();
+ RestfulServer srv = new RestfulServer(ourCtx);
srv.setFhirContext(ourCtx);
srv.setResourceProviders(new OperationReturningOldBundleProvider());
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleResourceParamTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleResourceParamTest.java
index b8deec6db73..130bbbe46ee 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleResourceParamTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/TransactionWithBundleResourceParamTest.java
@@ -48,7 +48,7 @@ public class TransactionWithBundleResourceParamTest {
}
private static CloseableHttpClient ourClient;
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(TransactionWithBundleResourceParamTest.class);
private static int ourPort;
private static boolean ourReturnOperationOutcome;
@@ -208,7 +208,7 @@ public class TransactionWithBundleResourceParamTest {
ourLog.info(responseContent);
- Bundle bundle = new FhirContext().newXmlParser().parseResource(Bundle.class, responseContent);
+ Bundle bundle = ourCtx.newXmlParser().parseResource(Bundle.class, responseContent);
assertEquals(4, bundle.getEntry().size());
assertEquals(OperationOutcome.class, bundle.getEntry().get(0).getResource().getClass());
@@ -234,7 +234,7 @@ public class TransactionWithBundleResourceParamTest {
ourServer = new Server(ourPort);
DummyProvider patientProvider = new DummyProvider();
- RestfulServer server = new RestfulServer();
+ RestfulServer server = new RestfulServer(ourCtx);
server.setProviders(patientProvider);
org.eclipse.jetty.servlet.ServletContextHandler proxyHandler = new org.eclipse.jetty.servlet.ServletContextHandler();
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/UpdateConditionalTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/UpdateConditionalTest.java
index 31692213e12..00276a123c9 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/UpdateConditionalTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/UpdateConditionalTest.java
@@ -52,7 +52,7 @@ public class UpdateConditionalTest {
private static String ourLastConditionalUrl;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(UpdateConditionalTest.class);
private static int ourPort;
-
+ private static FhirContext ourCtx = FhirContext.forDstu2();
private static Server ourServer;
private static IdDt ourLastId;
private static IdDt ourLastIdParam;
@@ -75,7 +75,7 @@ public class UpdateConditionalTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient?identifier=system%7C001");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -101,7 +101,7 @@ public class UpdateConditionalTest {
patient.addIdentifier().setValue("002");
HttpPut httpPost = new HttpPut("http://localhost:" + ourPort + "/Patient/2");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(patient), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
@@ -157,7 +157,7 @@ public class UpdateConditionalTest {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider);
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu2Test.java
index 1b2fc6e53ae..a0e3e621e3a 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/ValidateDstu2Test.java
@@ -44,13 +44,13 @@ public class ValidateDstu2Test {
private static CloseableHttpClient ourClient;
private static EncodingEnum ourLastEncoding;
private static String ourLastResourceBody;
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ValidateDstu2Test.class);
private static int ourPort;
private static Server ourServer;
private static BaseOperationOutcome ourOutcomeToReturn;
private static ValidationModeEnum ourLastMode;
private static String ourLastProfile;
-
+ private static FhirContext ourCtx = FhirContext.forDstu2();
+
@Before()
public void before() {
ourLastResourceBody = null;
@@ -73,7 +73,7 @@ public class ValidateDstu2Test {
params.addParameter().setName("mode").setValue(new StringDt(ValidationModeEnum.CREATE.name()));
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
String resp = IOUtils.toString(status.getEntity().getContent());
@@ -97,7 +97,7 @@ public class ValidateDstu2Test {
params.addParameter().setName("resource").setResource(patient);
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
String resp = IOUtils.toString(status.getEntity().getContent());
@@ -122,7 +122,7 @@ public class ValidateDstu2Test {
params.addParameter().setName("resource").setResource(patient);
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Patient/$validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newXmlParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_XML, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
String resp = IOUtils.toString(status.getEntity().getContent());
@@ -144,7 +144,7 @@ public class ValidateDstu2Test {
params.addParameter().setName("resource").setResource(org);
HttpPost httpPost = new HttpPost("http://localhost:" + ourPort + "/Organization/$validate");
- httpPost.setEntity(new StringEntity(new FhirContext().newJsonParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
+ httpPost.setEntity(new StringEntity(ourCtx.newJsonParser().encodeResourceToString(params), ContentType.create(Constants.CT_FHIR_JSON, "UTF-8")));
HttpResponse status = ourClient.execute(httpPost);
assertEquals(200, status.getStatusLine().getStatusCode());
@@ -167,7 +167,7 @@ public class ValidateDstu2Test {
PatientProvider patientProvider = new PatientProvider();
ServletHandler proxyHandler = new ServletHandler();
- RestfulServer servlet = new RestfulServer();
+ RestfulServer servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(patientProvider, new OrganizationProvider());
ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*");
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorDstu2Test.java
similarity index 98%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorDstu2Test.java
index 3407a78a722..033987cdf77 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/interceptor/LoggingInterceptorDstu2Test.java
@@ -28,6 +28,7 @@ import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
+import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.composite.HumanNameDt;
import ca.uhn.fhir.model.dstu2.composite.IdentifierDt;
import ca.uhn.fhir.model.dstu2.resource.Bundle;
@@ -50,14 +51,15 @@ import ca.uhn.fhir.util.PortUtil;
/**
* Created by dsotnikov on 2/25/2014.
*/
-public class LoggingInterceptorTest {
+public class LoggingInterceptorDstu2Test {
private static CloseableHttpClient ourClient;
private static int ourPort;
private static Server ourServer;
private static RestfulServer servlet;
private IServerInterceptor myInterceptor;
-
+ private static final FhirContext ourCtx = FhirContext.forDstu2();
+
@Test
public void testRead() throws Exception {
@@ -187,7 +189,7 @@ public class LoggingInterceptorTest {
ourServer = new Server(ourPort);
ServletHandler proxyHandler = new ServletHandler();
- servlet = new RestfulServer();
+ servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(new DummyPatientResourceProvider());
servlet.setPlainProviders(new PlainProvider());
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactoryTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactoryTest.java
index 7c8974c711f..22e8a6b3737 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactoryTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/dstu2/Dstu2BundleFactoryTest.java
@@ -32,7 +32,7 @@ public class Dstu2BundleFactoryTest {
@BeforeClass
public static void beforeClass() throws Exception {
- ourCtx = new FhirContext(Patient.class);
+ ourCtx = FhirContext.forDstu2();
}
@Before
@@ -159,7 +159,8 @@ public class Dstu2BundleFactoryTest {
return count;
}
- private List getResourcesOfType(Bundle theBundle, Class theResourceClass) {
+ @SuppressWarnings("unchecked")
+ private List getResourcesOfType(Bundle theBundle, Class theResourceClass) {
List resources = new ArrayList();
for (Bundle.Entry entry : theBundle.getEntry()) {
if (theResourceClass.isAssignableFrom(entry.getResource().getClass())) {
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/util/FhirTerserDstu2Test.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/util/FhirTerserDstu2Test.java
index f8f900a97fa..74d36ddef51 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/util/FhirTerserDstu2Test.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/util/FhirTerserDstu2Test.java
@@ -24,7 +24,7 @@ import ca.uhn.fhir.model.primitive.StringDt;
public class FhirTerserDstu2Test {
- private static FhirContext ourCtx = new FhirContext();
+ private static FhirContext ourCtx = FhirContext.forDstu2();
@Test
public void testGetAllPopulatedChildElementsOfTypeDoesntDescendIntoEmbedded() {
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu2Test.java
similarity index 98%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu2Test.java
index d3acf3b2128..5ce8e1f737f 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidationResultDstu2Test.java
@@ -14,7 +14,7 @@ import org.junit.Test;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome.BaseIssue;
import ca.uhn.fhir.model.dstu2.resource.OperationOutcome;
-public class ValidationResultTest {
+public class ValidationResultDstu2Test {
@Test
public void isSuccessful_IsTrueForNullOperationOutcome() {
diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorDstu2Test.java
similarity index 71%
rename from hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java
rename to hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorDstu2Test.java
index 27fc3a42ea2..08e1b7329da 100644
--- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorTest.java
+++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/validation/ValidatorInstantiatorDstu2Test.java
@@ -6,13 +6,13 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
-public class ValidatorInstantiatorTest {
+public class ValidatorInstantiatorDstu2Test {
+ private static FhirContext ourCtx = FhirContext.forDstu2();
@Test
public void testValidator() {
- FhirContext ctx = new FhirContext();
- FhirValidator val = ctx.newValidator();
+ FhirValidator val = ourCtx.newValidator();
// We have a full classpath, so take advantage
assertTrue(val.isValidateAgainstStandardSchema());
diff --git a/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml b/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml
index 996190aeccf..e5cbbb9c22e 100644
--- a/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml
+++ b/hapi-fhir-structures-dstu2/src/test/resources/logback-test.xml
@@ -23,8 +23,8 @@
-->
-
+
-
\ No newline at end of file
+
diff --git a/hapi-fhir-structures-dstu2/src/test/resources/narrative/Practitioner.html b/hapi-fhir-structures-dstu2/src/test/resources/narrative/PractitionerDstu2.html
similarity index 100%
rename from hapi-fhir-structures-dstu2/src/test/resources/narrative/Practitioner.html
rename to hapi-fhir-structures-dstu2/src/test/resources/narrative/PractitionerDstu2.html
diff --git a/hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative.properties b/hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative_dstu2.properties
similarity index 78%
rename from hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative.properties
rename to hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative_dstu2.properties
index 628b77ea47b..7edb1758dda 100644
--- a/hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative.properties
+++ b/hapi-fhir-structures-dstu2/src/test/resources/narrative/customnarrative_dstu2.properties
@@ -8,8 +8,8 @@
# template file.
# Format is file:/path/foo.html or classpath:/com/classpath/foo.html
#
-practitioner.class=ca.uhn.fhir.model.dev.resource.Practitioner
-practitioner.narrative=file:src/test/resources/narrative/Practitioner.html
+practitioner.class=ca.uhn.fhir.model.dstu2.resource.Practitioner
+practitioner.narrative=classpath:narrative/PractitionerDstu2.html
# You may also override/define behaviour for datatypes
humanname.class=ca.uhn.fhir.model.dev.composite.HumanNameDt
diff --git a/hapi-fhir-structures-hl7org-dstu2/.gitignore b/hapi-fhir-structures-hl7org-dstu2/.gitignore
index 88dc6eaba34..d9b8e6daf6e 100644
--- a/hapi-fhir-structures-hl7org-dstu2/.gitignore
+++ b/hapi-fhir-structures-hl7org-dstu2/.gitignore
@@ -126,3 +126,4 @@ local.properties
# TeXlipse plugin
.texlipse
+/target/
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/IdTypeTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/IdTypeTest.java
index 7312c7bef1f..17a20de2ca8 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/IdTypeTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/model/IdTypeTest.java
@@ -220,7 +220,7 @@ public class IdTypeTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2Hl7Org();
}
}
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
index 597cb0c8b1b..a27e5b611e2 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
@@ -451,7 +451,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testEncodeDeclaredExtensionWithAddressContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
MyPatientWithOneDeclaredAddressExtension patient = new MyPatientWithOneDeclaredAddressExtension();
patient.addAddress().setUse(AddressUse.HOME);
@@ -470,7 +470,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testEncodeDeclaredExtensionWithResourceContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
MyPatientWithOneDeclaredExtension patient = new MyPatientWithOneDeclaredExtension();
patient.addAddress().setUse(AddressUse.HOME);
@@ -586,7 +586,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testEncodeExtensionWithResourceContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
Patient patient = new Patient();
patient.addAddress().setUse(AddressUse.HOME);
@@ -698,7 +698,7 @@ public class JsonParserHl7OrgTest {
Patient patient = new Patient();
patient.setManagingOrganization(new Reference());
- IParser p = new FhirContext().newJsonParser();
+ IParser p = ourCtx.newJsonParser();
String str = p.encodeResourceToString(patient);
assertThat(str, IsNot.not(StringContains.containsString("managingOrganization")));
@@ -716,7 +716,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testEncodeUndeclaredExtensionWithAddressContent() {
- IParser parser = new FhirContext().newJsonParser();
+ IParser parser = ourCtx.newJsonParser();
Patient patient = new Patient();
patient.addAddress().setUse(AddressUse.HOME);
@@ -764,15 +764,15 @@ public class JsonParserHl7OrgTest {
HumanName given = name.addGiven("Joe");
Extension ext2 = new Extension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
given.getExtension().add(ext2);
- String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
+ String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
assertEquals("{\"resourceType\":\"Patient\",\"name\":[{\"extension\":[{\"url\":\"http://examples.com#givenext\",\"valueString\":\"Hello\"}],\"family\":[\"Shmoe\"],\"given\":[\"Joe\"]}]}", enc);
- IParser newJsonParser = new FhirContext().newJsonParser();
+ IParser newJsonParser = ourCtx.newJsonParser();
StringReader reader = new StringReader(enc);
Patient parsed = newJsonParser.parseResource(Patient.class, reader);
- ourLog.info(new FhirContext().newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
+ ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(parsed));
assertEquals(1, parsed.getName().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getExtension().get(0);
@@ -790,7 +790,7 @@ public class JsonParserHl7OrgTest {
family.setValue("Shmoe");
family.addExtension().setUrl("http://examples.com#givenext").setValue( new StringType("Hello"));
- String enc = new FhirContext().newJsonParser().encodeResourceToString(patient);
+ String enc = ourCtx.newJsonParser().encodeResourceToString(patient);
ourLog.info(enc);
//@formatter:off
assertThat(enc, containsString(("{\n" +
@@ -815,7 +815,7 @@ public class JsonParserHl7OrgTest {
"}").replace("\n", "").replaceAll(" +", "")));
//@formatter:on
- Patient parsed = new FhirContext().newJsonParser().parseResource(Patient.class, new StringReader(enc));
+ Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, new StringReader(enc));
assertEquals(1, parsed.getName().get(0).getFamily().get(0).getExtension().size());
Extension ext = parsed.getName().get(0).getFamily().get(0).getExtension().get(0);
assertEquals("Hello", ((IPrimitiveType>)ext.getValue()).getValue());
@@ -962,7 +962,7 @@ public class JsonParserHl7OrgTest {
// nothing
}};
- FhirContext context = new FhirContext();
+ FhirContext context = ourCtx;
context.setNarrativeGenerator(gen);
IParser p = context.newJsonParser();
p.encodeResourceToWriter(patient, new OutputStreamWriter(System.out));
@@ -1189,7 +1189,7 @@ public class JsonParserHl7OrgTest {
"}";
//@formatter:on
- TagList tagList = new FhirContext().newJsonParser().parseTagList(tagListStr);
+ TagList tagList = ourCtx.newJsonParser().parseTagList(tagListStr);
assertEquals(3, tagList.size());
assertEquals("term0", tagList.get(0).getTerm());
assertEquals("label0", tagList.get(0).getLabel());
@@ -1226,7 +1226,7 @@ public class JsonParserHl7OrgTest {
"}";
//@formatter:on
- String encoded = new FhirContext().newJsonParser().encodeTagListToString(tagList);
+ String encoded = ourCtx.newJsonParser().encodeTagListToString(tagList);
assertEquals(expected, encoded);
}
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganization.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganizationDstu2.java
similarity index 78%
rename from hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganization.java
rename to hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganizationDstu2.java
index 32944fab387..29bfafe1349 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganization.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyOrganizationDstu2.java
@@ -4,7 +4,7 @@ import org.hl7.fhir.instance.model.Organization;
import org.hl7.fhir.instance.model.annotations.ResourceDef;
@ResourceDef()
-public class MyOrganization extends Organization {
+public class MyOrganizationDstu2 extends Organization {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatient.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatientHl7Org.java
similarity index 96%
rename from hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatient.java
rename to hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatientHl7Org.java
index 7a96d2cb3ca..4e5aa27dc5d 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatient.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/MyPatientHl7Org.java
@@ -14,7 +14,7 @@ import org.hl7.fhir.instance.model.annotations.ResourceDef;
@ResourceDef()
-public class MyPatient extends Patient {
+public class MyPatientHl7Org extends Patient {
private static final long serialVersionUID = 1L;
@@ -29,7 +29,7 @@ public class MyPatient extends Patient {
private List myImportantDates;
@Child(name="managingOrganization", order=Child.REPLACE_PARENT, min=0, max=1, type={
- MyOrganization.class })
+ MyOrganizationDstu2.class })
@Description(
shortDefinition="Organization that is the custodian of the patient record",
formalDefinition="Organization that is the custodian of the patient record"
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
index 7e76d5cd4d7..209bf39e1e6 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
@@ -1051,7 +1051,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testExtensions() throws DataFormatException {
- MyPatient patient = new MyPatient();
+ MyPatientHl7Org patient = new MyPatientHl7Org();
patient.setPetName(new StringType("Fido"));
patient.getImportantDates().add(new DateTimeType("2010-01-02"));
patient.getImportantDates().add(new DateTimeType("2014-01-26T11:11:11"));
@@ -1358,7 +1358,7 @@ public class XmlParserHl7OrgDstu2Test {
}
};
- FhirContext context = new FhirContext();
+ FhirContext context = ourCtx;
context.setNarrativeGenerator(gen);
IParser p = context.newXmlParser();
String str = p.encodeResourceToString(patient);
@@ -1540,7 +1540,7 @@ public class XmlParserHl7OrgDstu2Test {
XMLUnit.setIgnoreAttributeOrder(true);
XMLUnit.setIgnoreComments(true);
XMLUnit.setIgnoreWhitespace(true);
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2Hl7Org();
}
}
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestDstu2.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestHl7OrgDstu2.java
similarity index 98%
rename from hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestDstu2.java
rename to hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestHl7OrgDstu2.java
index ae2f82f522f..7887570cf8e 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestDstu2.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ClientServerValidationTestHl7OrgDstu2.java
@@ -37,9 +37,9 @@ import ca.uhn.fhir.rest.client.exceptions.FhirClientConnectionException;
import ca.uhn.fhir.rest.client.exceptions.FhirClientInappropriateForServerException;
import ca.uhn.fhir.rest.server.Constants;
-public class ClientServerValidationTestDstu2 {
+public class ClientServerValidationTestHl7OrgDstu2 {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientServerValidationTestDstu2.class);
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ClientServerValidationTestHl7OrgDstu2.class);
private FhirContext myCtx;
private HttpClient myHttpClient;
private HttpResponse myHttpResponse;
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java
index b4c38053f56..8e7a82b4ef8 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/rest/client/ETagClientTest.java
@@ -274,7 +274,7 @@ public class ETagClientTest {
@BeforeClass
public static void beforeClass() {
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2Hl7Org();
}
}
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
new file mode 100644
index 00000000000..c10a73d1310
--- /dev/null
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -0,0 +1,366 @@
+
+ 4.0.0
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir
+ 1.1-SNAPSHOT
+ ../pom.xml
+
+
+ hapi-fhir-testconsolidated
+ jar
+
+ HAPI FHIR - Consolidated Test Project
+
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-base
+ 1.1-SNAPSHOT
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-structures-dstu
+ 1.1-SNAPSHOT
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-structures-dstu2
+ 1.1-SNAPSHOT
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-structures-hl7org-dstu2
+ 1.1-SNAPSHOT
+
+
+ ca.uhn.hapi.fhir
+ hapi-fhir-jpaserver-base
+ 1.1-SNAPSHOT
+
+
+
+ com.phloc
+ phloc-schematron
+ ${phloc_schematron_version}
+
+
+ com.phloc
+ phloc-commons
+ ${phloc_commons_version}
+
+
+ org.thymeleaf
+ thymeleaf
+ ${thymeleaf-version}
+
+
+
+ org.slf4j
+ jcl-over-slf4j
+ ${slf4j_version}
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback_version}
+ test
+
+
+ org.hamcrest
+ java-hamcrest
+ ${hamcrest_version}
+ test
+
+
+
+
+ junit
+ junit
+ ${junit_version}
+ test
+
+
+ org.apache.derby
+ derby
+ ${derby_version}
+ test
+
+
+ commons-dbcp
+ commons-dbcp
+ 1.4
+ test
+
+
+
+ javax.servlet
+ javax.servlet-api
+ 3.1.0
+ provided
+
+
+
+ org.eclipse.jetty
+ jetty-servlets
+ ${jetty_version}
+ test
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${jetty_version}
+ test
+
+
+ org.eclipse.jetty
+ jetty-server
+ ${jetty_version}
+ test
+
+
+ org.eclipse.jetty
+ jetty-servlet
+ ${jetty_version}
+ test
+
+
+ org.eclipse.jetty
+ jetty-util
+ ${jetty_version}
+ test
+
+
+ org.mockito
+ mockito-all
+ 1.9.5
+ test
+
+
+ net.sf.json-lib
+ json-lib
+ 2.4
+ jdk15
+ test
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ net.sf.json-lib
+ json-lib
+ 2.4
+ jdk15-sources
+ test
+
+
+ directory-naming
+ naming-java
+ 0.8
+ test
+
+
+ commons-logging
+ commons-logging
+
+
+
+
+ org.hamcrest
+ java-hamcrest
+ ${hamcrest_version}
+ test
+
+
+ com.google.guava
+ guava
+ ${guava_version}
+
+
+ org.ebaysf.web
+ cors-filter
+ ${ebay_cors_filter_version}
+ test
+
+
+ xmlunit
+ xmlunit
+ ${xmlunit_version}
+ test
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-site-plugin
+
+ true
+
+
+
+
+
+
+ org.eluder.coveralls
+ coveralls-maven-plugin
+ 3.1.0
+
+
+
+
+ org.codehaus.mojo
+ build-helper-maven-plugin
+ ${maven_build_helper_plugin_version}
+
+
+ add-source
+ generate-sources
+
+ add-source
+
+
+
+
+
+
+
+
+
+ add-test-source
+ generate-test-sources
+
+ add-test-source
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+
+ alphabetical
+
+
+
+ org.apache.maven.plugins
+ maven-install-plugin
+
+ true
+
+
+
+ org.apache.maven.plugins
+ maven-deploy-plugin
+
+ true
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${maven_cobertura_plugin_version}
+
+ false
+
+
+ ca.uhn.fhir.model.dstu.valueset.*
+ ca.uhn.fhir.model.valueset.*
+ ca.uhn.fhir.rest.client.exceptions.*
+ ca.uhn.fhir.rest.server.exceptions.*
+
+
+ ca/uhn/fhir/model/dstu/valueset/*.class
+ ca/uhn/fhir/model/valueset/*.class
+ ca/uhn/fhir/rest/client.exceptions/*.class
+ ca/uhn/fhir/rest/server.exceptions/*.class
+
+
+
+
+
+ verify
+
+ check
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${maven_cobertura_plugin_version}
+
+
+
+
+
+
+
+
+ clean
+ check
+
+
+
+
+
+
+
+
+
+ ../hapi-fhir-jpaserver-base/src/test/resources
+
+
+ ../hapi-fhir-structures-dstu/src/test/resources
+
+
+ ../hapi-fhir-structures-dstu2/src/test/resources
+
+
+ ../hapi-fhir-structures-hl7org-dstu2/src/test/resources
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${maven_cobertura_plugin_version}
+
+
+
+ cobertura
+
+
+
+
+
+
+
diff --git a/pom.xml b/pom.xml
index 00b5f160f5c..d1b57c14654 100644
--- a/pom.xml
+++ b/pom.xml
@@ -195,6 +195,7 @@
1.81.9.12.5.3
+ 2.72.18.11.62.10.1
@@ -216,13 +217,21 @@
2.1.4.RELEASE1.0.14.4.1
-
+ 1.6UTF-8
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${maven_cobertura_plugin_version}
+
+
+
+ org.apache.maven.pluginsmaven-compiler-plugin
@@ -917,6 +926,15 @@
hapi-fhir-dist
+
+ COBERTURA
+
+ true
+
+
+ hapi-fhir-testconsolidated
+
+
diff --git a/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java b/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java
index 98be299b205..86d2e7200f2 100644
--- a/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java
+++ b/restful-server-example-test/src/test/java/ca/uhn/example/ExampleTest.java
@@ -88,7 +88,7 @@ public class ExampleTest {
ourServer.start();
- ourCtx = new FhirContext();
+ ourCtx = FhirContext.forDstu2();
ourClient = ourCtx.newRestfulGenericClient(base);
}
diff --git a/restful-server-example/src/main/java/ca/uhn/example/servlet/ExampleRestfulServlet.java b/restful-server-example/src/main/java/ca/uhn/example/servlet/ExampleRestfulServlet.java
index 245e70df665..02a5ff533d0 100644
--- a/restful-server-example/src/main/java/ca/uhn/example/servlet/ExampleRestfulServlet.java
+++ b/restful-server-example/src/main/java/ca/uhn/example/servlet/ExampleRestfulServlet.java
@@ -18,14 +18,19 @@ public class ExampleRestfulServlet extends RestfulServer {
private static final long serialVersionUID = 1L;
+ /**
+ * Constructor
+ */
+ public ExampleRestfulServlet() {
+ super(FhirContext.forDstu2()); // Support DSTU2
+ }
+
/**
* This method is called automatically when the
* servlet is initializing.
*/
@Override
public void initialize() {
- setFhirContext(FhirContext.forDstu2());// Support DSTU2
-
/*
* Two resource providers are defined. Each one handles a specific
* type of resource.
From 5891b74e809b99b3f318cab862d8960067c959a2 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 14:27:01 -0400
Subject: [PATCH 05/35] Travis work
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index fbd6c31bf41..0967b2b2c32 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: java
jdk:
- - oraclejdk6
+ - openjdk6
install: mvn clean install -Dcobertura.skip=true
script: mvn -P COBERTURA clean cobertura:cobertura
From 3e2ca6175cecddc8323e5793b4f22b9c0128379f Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 14:29:17 -0400
Subject: [PATCH 06/35] Travis
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 0967b2b2c32..cdca9fa8f51 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,6 +1,6 @@
language: java
jdk:
- - openjdk6
+ - oraclejdk7
install: mvn clean install -Dcobertura.skip=true
script: mvn -P COBERTURA clean cobertura:cobertura
From a27032685adf362e4da38cea0929c07981b8689a Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 14:45:07 -0400
Subject: [PATCH 07/35] Reduce log verbosity
---
.../java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
index 350dd9d1c29..c113adb4ee2 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
@@ -83,12 +83,12 @@ public abstract class BaseStructureParser {
if (isNotBlank(theResource.getBinding())) {
String bindingClass = theVsp.getClassForValueSetIdAndMarkAsNeeded(theResource.getBinding());
if (bindingClass != null) {
- ourLog.info("Adding binding ValueSet class: {}", bindingClass);
+ ourLog.debug("Adding binding ValueSet class: {}", bindingClass);
theResource.setBindingClass(bindingClass);
addImport(bindingClass);
myLocallyDefinedClassNames.put(bindingClass, "valueset");
} else {
- ourLog.info("No binding found for: {}", theResource.getBinding());
+ ourLog.debug("No binding found for: {}", theResource.getBinding());
ourLog.debug(" * Valid: {}", new TreeSet(theVsp.getValueSets().keySet()));
}
}
@@ -520,7 +520,7 @@ public abstract class BaseStructureParser {
File versionFile = new File(theResourceOutputDirectory, "fhirversion.properties");
FileWriter w = new FileWriter(versionFile, false);
- ourLog.info("Writing file: {}", versionFile.getAbsolutePath());
+ ourLog.debug("Writing file: {}", versionFile.getAbsolutePath());
VelocityContext ctx = new VelocityContext();
ctx.put("nameToResourceClass", myNameToResourceClass);
From 9ae84d17bc19ee1ab0cf971c5d6079ef852b687a Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 15:10:19 -0400
Subject: [PATCH 08/35] More cobertura
---
.travis.yml | 2 +-
hapi-fhir-testconsolidated/pom.xml | 48 ++++++++++++++++++++----------
2 files changed, 34 insertions(+), 16 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index cdca9fa8f51..59569fd5a65 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,5 +3,5 @@ jdk:
- oraclejdk7
install: mvn clean install -Dcobertura.skip=true
-script: mvn -P COBERTURA clean cobertura:cobertura
+script: mvn -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
index c10a73d1310..f31ecf13fbd 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -210,6 +210,31 @@
true
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ ${maven_cobertura_plugin_version}
+
+ false
+
+
+ ca.uhn.fhir.model.dstu.valueset.*
+
+
+ **/valueset/*.class
+ **/exceptions/*.class
+
+
+
+
+
+ verify
+
+ check
+
+
+
+
@@ -218,6 +243,14 @@
coveralls-maven-plugin3.1.0
+
+
+ ${basedir}/target/coverage.xml
+
+
+ UTF-8
+ travis-ci
+ ${env.TRAVIS_JOB_ID}
@@ -282,21 +315,6 @@
cobertura-maven-plugin${maven_cobertura_plugin_version}
- false
-
-
- ca.uhn.fhir.model.dstu.valueset.*
- ca.uhn.fhir.model.valueset.*
- ca.uhn.fhir.rest.client.exceptions.*
- ca.uhn.fhir.rest.server.exceptions.*
-
-
- ca/uhn/fhir/model/dstu/valueset/*.class
- ca/uhn/fhir/model/valueset/*.class
- ca/uhn/fhir/rest/client.exceptions/*.class
- ca/uhn/fhir/rest/server.exceptions/*.class
-
-
From c33d08524a8237e16b669471cf63d5e74bb9562b Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 15:21:13 -0400
Subject: [PATCH 09/35] Testing
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 59569fd5a65..4a355abfe2b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,5 +3,5 @@ jdk:
- oraclejdk7
install: mvn clean install -Dcobertura.skip=true
-script: mvn -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
+script: mvn -X -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
From 0bdee07ccfcd30ab0942cc3f3231009ae59d4a16 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:10:38 -0400
Subject: [PATCH 10/35] More work on travis :(
---
pom.xml | 3 ---
1 file changed, 3 deletions(-)
diff --git a/pom.xml b/pom.xml
index d1b57c14654..08412d0b72f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -928,9 +928,6 @@
COBERTURA
-
- true
- hapi-fhir-testconsolidated
From fe03527f14dce451bac30b98a112ee2bd55add1b Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:11:37 -0400
Subject: [PATCH 11/35] More travis
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 4a355abfe2b..59569fd5a65 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,5 +3,5 @@ jdk:
- oraclejdk7
install: mvn clean install -Dcobertura.skip=true
-script: mvn -X -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
+script: mvn -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
From 65e1af4c739615ef818388dc142f025d93bbdd00 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:32:00 -0400
Subject: [PATCH 12/35] More travis
---
.travis.yml | 13 ++++++++++---
hapi-fhir-testconsolidated/pom.xml | 8 ++++++--
.../java/ca/uhn/fhir/tinder/TinderClientMojo.java | 2 +-
.../ca/uhn/fhir/tinder/TinderStructuresMojo.java | 3 ++-
.../java/ca/uhn/fhir/tinder/ValueSetGenerator.java | 2 +-
.../uhn/fhir/tinder/parser/BaseStructureParser.java | 4 ++--
6 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 59569fd5a65..fac0be14f53 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,7 +1,14 @@
+# Use docker-based build environment (instead of openvz)
+sudo: false
+
language: java
jdk:
- oraclejdk7
-install: mvn clean install -Dcobertura.skip=true
-script: mvn -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check
-
+cache:
+ directories:
+ - '$HOME/.m2/repository'
+
+install: /bin/true
+script:
+ - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check && mvn -B clean install -Dcobertura.skip=true
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
index f31ecf13fbd..1ed92467251 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -216,6 +216,8 @@
${maven_cobertura_plugin_version}false
+ xml
+ 256mca.uhn.fhir.model.dstu.valueset.*
@@ -325,17 +327,18 @@
+
+ 4030
@@ -347,6 +350,7 @@
+ -->
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderClientMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderClientMojo.java
index ba6e1815570..b5cde76bd0c 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderClientMojo.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderClientMojo.java
@@ -156,7 +156,7 @@ public class TinderClientMojo extends AbstractMojo {
File file = new File(myDirectoryBase, myClientClassSimpleName + ".java");
FileWriter w = new FileWriter(file, false);
- ourLog.info("Writing file: {}", file.getAbsolutePath());
+ ourLog.debug("Writing file: {}", file.getAbsolutePath());
VelocityContext ctx = new VelocityContext();
ctx.put("packageBase", myPackageBase);
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
index ae64c8ee9c3..ea250a10797 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/TinderStructuresMojo.java
@@ -121,8 +121,9 @@ public class TinderStructuresMojo extends AbstractMojo {
rp.getLocalImports().putAll(datatypeLocalImports);
datatypeLocalImports.putAll(rp.getLocalImports());
- ourLog.info("Writing Resources...");
File resSubDirectoryBase = new File(directoryBase, "resource");
+ ourLog.info("Writing Resources to directory: {}", resSubDirectoryBase.getAbsolutePath());
+
rp.combineContentMaps(dtp);
rp.writeAll(resSubDirectoryBase, resDirectoryBase, packageName);
}
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ValueSetGenerator.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ValueSetGenerator.java
index b99e01fc6c9..836f94e76f0 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ValueSetGenerator.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/ValueSetGenerator.java
@@ -274,7 +274,7 @@ public class ValueSetGenerator {
File f = new File(theOutputDirectory, theValueSetTm.getClassName() + ".java");
FileWriter w = new FileWriter(f, false);
- ourLog.info("Writing file: {}", f.getAbsolutePath());
+ ourLog.debug("Writing file: {}", f.getAbsolutePath());
VelocityContext ctx = new VelocityContext();
ctx.put("valueSet", theValueSetTm);
diff --git a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
index c113adb4ee2..1b4913398d3 100644
--- a/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
+++ b/hapi-tinder-plugin/src/main/java/ca/uhn/fhir/tinder/parser/BaseStructureParser.java
@@ -396,7 +396,7 @@ public abstract class BaseStructureParser {
private void write(BaseRootType theResource, File theFile, String thePackageBase) throws IOException, MojoFailureException {
FileWriter w = new FileWriter(theFile, false);
- ourLog.info("Writing file: {}", theFile.getAbsolutePath());
+ ourLog.debug("Writing file: {}", theFile.getAbsolutePath());
ArrayList imports = new ArrayList();
for (String next : myImports) {
@@ -486,7 +486,7 @@ public abstract class BaseStructureParser {
}
for (BaseRootType next : myResources) {
- ourLog.info("Writing Resource {}", next.getName());
+ ourLog.debug("Writing Resource {}", next.getName());
scanForCorrections(next);
scanForTypeNameConflicts(next);
From deb920abb0dbec9a92ce9951eecbd2b7652fab01 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:33:15 -0400
Subject: [PATCH 13/35] Travis
---
.travis.yml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index fac0be14f53..97501974b86 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,7 +8,7 @@ jdk:
cache:
directories:
- '$HOME/.m2/repository'
-
+
install: /bin/true
script:
- mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check && mvn -B clean install -Dcobertura.skip=true
From 6d06b4adafb183e049fa4a07c5b917d781af624f Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:38:03 -0400
Subject: [PATCH 14/35] Travis
---
.travis.yml | 4 +++-
pom.xml | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 97501974b86..34f55c47eba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,4 +11,6 @@ cache:
install: /bin/true
script:
- - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:check && mvn -B clean install -Dcobertura.skip=true
+ - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+
+#&& mvn -B clean install -Dcobertura.skip=true
diff --git a/pom.xml b/pom.xml
index 08412d0b72f..1fb233129ab 100644
--- a/pom.xml
+++ b/pom.xml
@@ -229,7 +229,7 @@
cobertura-maven-plugin${maven_cobertura_plugin_version}
-
+ true
From 2f686e5219b802627d312fe1f3d53ec238ecb386 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 18:43:15 -0400
Subject: [PATCH 15/35] Travis
---
.travis.yml | 4 ++--
pom.xml | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 34f55c47eba..c4b81e5a19a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,6 @@ cache:
install: /bin/true
script:
- - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+ - mvn -B clean install -Dcobertura.skip=true && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+
-#&& mvn -B clean install -Dcobertura.skip=true
diff --git a/pom.xml b/pom.xml
index 1fb233129ab..8c4186e4790 100644
--- a/pom.xml
+++ b/pom.xml
@@ -232,6 +232,15 @@
true
+
+ org.eluder.coveralls
+ coveralls-maven-plugin
+ 3.1.0
+
+
+
+
+ org.apache.maven.pluginsmaven-compiler-plugin
From e498bbb952e333bd98bd041b7af67667b243b06a Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 19:09:24 -0400
Subject: [PATCH 16/35] Travis
---
.travis.yml | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index c4b81e5a19a..636ca0255d9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,6 +11,7 @@ cache:
install: /bin/true
script:
- - mvn -B clean install -Dcobertura.skip=true && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+ - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+# - mvn -B clean install -Dcobertura.skip=true && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
From 6575de95083684e60b1efaaf8e83cf1be275c92a Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 19:14:57 -0400
Subject: [PATCH 17/35] Travis
---
hapi-fhir-testconsolidated/pom.xml | 4 ++--
pom.xml | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
index 1ed92467251..bffe14b55df 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -282,9 +282,9 @@
-
+
diff --git a/pom.xml b/pom.xml
index 8c4186e4790..eb031d1dc6f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -274,7 +274,7 @@
maven-surefire-plugin${maven_surefire_plugin_version}
- true
+
random-Dfile.encoding=UTF-8
From 175ca495bb3938341a4d6ab95963e96955bb9cea Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 19:21:44 -0400
Subject: [PATCH 18/35] Travis
---
hapi-fhir-testconsolidated/pom.xml | 46 ++++++++++++------------------
1 file changed, 18 insertions(+), 28 deletions(-)
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
index bffe14b55df..b6d548aa504 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -217,7 +217,7 @@
falsexml
- 256m
+ 512mmca.uhn.fhir.model.dstu.valueset.*
@@ -253,6 +253,12 @@
UTF-8travis-ci${env.TRAVIS_JOB_ID}
+
+ ../hapi-fhir-structures-dstu/src/test/java
+ ../hapi-fhir-structures-dstu2/src/test/java
+ ../hapi-fhir-structures-hl7org-dstu2/src/test/java
+ ../hapi-fhir-jpaserver-base/src/test/java
+
@@ -282,9 +288,8 @@
-
+
@@ -327,30 +332,15 @@
-
+
From a7e7b6b061e3341473584acfdcc75ca3711ffe37 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 19:25:36 -0400
Subject: [PATCH 19/35] Travis
---
hapi-fhir-testconsolidated/pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-testconsolidated/pom.xml
index b6d548aa504..1d009cfb029 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-testconsolidated/pom.xml
@@ -217,7 +217,7 @@
falsexml
- 512mm
+ 256mca.uhn.fhir.model.dstu.valueset.*
From 319d1074b1f0a1ef6589a22726d6c8391c0803b0 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 20:22:05 -0400
Subject: [PATCH 20/35] Travis
---
{hapi-fhir-testconsolidated => hapi-fhir-cobertura}/pom.xml | 4 +++-
pom.xml | 2 +-
2 files changed, 4 insertions(+), 2 deletions(-)
rename {hapi-fhir-testconsolidated => hapi-fhir-cobertura}/pom.xml (98%)
diff --git a/hapi-fhir-testconsolidated/pom.xml b/hapi-fhir-cobertura/pom.xml
similarity index 98%
rename from hapi-fhir-testconsolidated/pom.xml
rename to hapi-fhir-cobertura/pom.xml
index 1d009cfb029..5b58e0b6345 100644
--- a/hapi-fhir-testconsolidated/pom.xml
+++ b/hapi-fhir-cobertura/pom.xml
@@ -9,7 +9,7 @@
../pom.xml
- hapi-fhir-testconsolidated
+ hapi-fhir-coberturajarHAPI FHIR - Consolidated Test Project
@@ -258,6 +258,8 @@
../hapi-fhir-structures-dstu2/src/test/java../hapi-fhir-structures-hl7org-dstu2/src/test/java../hapi-fhir-jpaserver-base/src/test/java
+ ../hapi-fhir-base/src/main/java
+ ../hapi-fhir-jpaserver-base/src/main/java
diff --git a/pom.xml b/pom.xml
index eb031d1dc6f..9b9ca79fff3 100644
--- a/pom.xml
+++ b/pom.xml
@@ -938,7 +938,7 @@
COBERTURA
- hapi-fhir-testconsolidated
+ hapi-fhir-cobertura
From e67bcec46539bafd24c2a23f0e458f908d6587d0 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 20:37:47 -0400
Subject: [PATCH 21/35] Travis
---
.travis.yml | 2 +-
hapi-fhir-cobertura/pom.xml | 6 +++---
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index 636ca0255d9..5e0bb5cb879 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -11,7 +11,7 @@ cache:
install: /bin/true
script:
- - mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+ - cd hapi-fhir-cobertura && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
# - mvn -B clean install -Dcobertura.skip=true && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml
index 5b58e0b6345..a0732ce7d1f 100644
--- a/hapi-fhir-cobertura/pom.xml
+++ b/hapi-fhir-cobertura/pom.xml
@@ -252,7 +252,7 @@
UTF-8travis-ci
- ${env.TRAVIS_JOB_ID}
+ ${env.TRAVIS_JOB_ID}../hapi-fhir-structures-dstu/src/test/java../hapi-fhir-structures-dstu2/src/test/java
@@ -290,8 +290,8 @@
-
+
+
From f64426e4bbd7f52f66fd3bfe3c306831e2c0c56e Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 20:43:34 -0400
Subject: [PATCH 22/35] Travis
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 9b9ca79fff3..331f5b062f5 100644
--- a/pom.xml
+++ b/pom.xml
@@ -274,7 +274,7 @@
maven-surefire-plugin${maven_surefire_plugin_version}
-
+ truerandom-Dfile.encoding=UTF-8
From 772c9d1e7b8aad32008b802361588b012685f1bb Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 23:50:49 -0400
Subject: [PATCH 23/35] Travis
---
hapi-fhir-cobertura/pom.xml | 11 +++++------
.../src/test/resources/logback-test.xml | 8 ++++----
2 files changed, 9 insertions(+), 10 deletions(-)
diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml
index a0732ce7d1f..13e1966f791 100644
--- a/hapi-fhir-cobertura/pom.xml
+++ b/hapi-fhir-cobertura/pom.xml
@@ -62,13 +62,12 @@
jcl-over-slf4j${slf4j_version}
+
+ org.slf4j
+ slf4j-nop
+ ${slf4j_version}
+
-
- ch.qos.logback
- logback-classic
- ${logback_version}
- test
- org.hamcrestjava-hamcrest
diff --git a/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml b/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
index 658cd6bad1c..fe5d65d196e 100644
--- a/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
+++ b/hapi-fhir-jpaserver-base/src/test/resources/logback-test.xml
@@ -10,19 +10,19 @@
-
+
-
+
-
+
-
+
From 6d0a7870b536f9413d2a185fd15897f44a7814cc Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sat, 20 Jun 2015 23:55:47 -0400
Subject: [PATCH 24/35] Travis
---
.travis.yml | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.travis.yml b/.travis.yml
index 5e0bb5cb879..72b14e81dd8 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,9 @@ sudo: false
language: java
jdk:
- oraclejdk7
+env:
+ global:
+ - MAVEN_OPTS="-XX:MaxPermSize=512m -Xmx4g"
cache:
directories:
From 7acacda758d850740ed3c507f77467ee3af4fe10 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 00:07:48 -0400
Subject: [PATCH 25/35] Travis
---
.../ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java | 2 +-
.../java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 20 +++++++++++++++++++
.../jpa/dao/FhirResourceDaoDstu1Test.java | 2 +-
.../jpa/dao/FhirResourceDaoDstu2Test.java | 2 +-
.../fhir/jpa/dao/FhirSystemDaoDstu1Test.java | 2 +-
.../fhir/jpa/dao/FhirSystemDaoDstu2Test.java | 6 ++++--
.../provider/ResourceProviderDstu1Test.java | 3 ++-
.../provider/ResourceProviderDstu2Test.java | 3 ++-
.../ResourceProviderMultiVersionTest.java | 3 ++-
.../jpa/provider/SystemProviderDstu1Test.java | 3 ++-
.../jpa/provider/SystemProviderDstu2Test.java | 3 ++-
11 files changed, 38 insertions(+), 11 deletions(-)
create mode 100644 hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java
index 82ef8eac653..ff538892abd 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseFhirDaoTest.java
@@ -7,7 +7,7 @@ import org.junit.Test;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.model.dstu2.resource.Condition;
-public class BaseFhirDaoTest {
+public class BaseFhirDaoTest extends BaseJpaTest {
private static FhirContext ourCtx = FhirContext.forDstu2();
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
new file mode 100644
index 00000000000..1cb376e895e
--- /dev/null
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
@@ -0,0 +1,20 @@
+package ca.uhn.fhir.jpa.dao;
+
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.SQLNonTransientConnectionException;
+
+import org.junit.AfterClass;
+
+public class BaseJpaTest {
+
+ @AfterClass
+ public static void afterClassShutdownDerby() throws SQLException {
+ try {
+ DriverManager.getConnection("jdbc:derby:memory:myUnitTestDB;drop=true");
+ } catch (SQLNonTransientConnectionException e) {
+ // expected.. for some reason....
+ }
+ }
+
+}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java
index 82963836453..bb6571cecd4 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu1Test.java
@@ -25,7 +25,7 @@ import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
-public class FhirResourceDaoDstu1Test {
+public class FhirResourceDaoDstu1Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx;
private static IFhirResourceDao ourDeviceDao;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java
index 1749b67e9da..6c8e0a7b9cf 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirResourceDaoDstu2Test.java
@@ -93,7 +93,7 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
@SuppressWarnings("unchecked")
-public class FhirResourceDaoDstu2Test {
+public class FhirResourceDaoDstu2Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx;
private static IFhirResourceDao ourDeviceDao;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java
index cf4971e8a3d..37cfda114ef 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu1Test.java
@@ -45,7 +45,7 @@ import ca.uhn.fhir.rest.param.TokenParam;
import ca.uhn.fhir.rest.server.IBundleProvider;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
-public class FhirSystemDaoDstu1Test {
+public class FhirSystemDaoDstu1Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx;
private static FhirContext ourFhirContext;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java
index 6afacf45aa1..517992b5afc 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/FhirSystemDaoDstu2Test.java
@@ -8,6 +8,8 @@ import static org.hamcrest.Matchers.startsWith;
import static org.junit.Assert.*;
import java.io.InputStream;
+import java.sql.DriverManager;
+import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
@@ -45,7 +47,7 @@ import ca.uhn.fhir.rest.server.exceptions.PreconditionFailedException;
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
-public class FhirSystemDaoDstu2Test {
+public class FhirSystemDaoDstu2Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourCtx;
private static FhirContext ourFhirContext;
@@ -953,7 +955,7 @@ public class FhirSystemDaoDstu2Test {
}
@AfterClass
- public static void afterClass() {
+ public static void afterClass() throws SQLException {
ourCtx.close();
}
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
index d705d64e0ba..05546effce1 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu1Test.java
@@ -17,6 +17,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
@@ -49,7 +50,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
-public class ResourceProviderDstu1Test {
+public class ResourceProviderDstu1Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourAppCtx;
private static IGenericClient ourClient;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
index dc66f2dafae..aeccb5e1c89 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderDstu2Test.java
@@ -48,6 +48,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
@@ -96,7 +97,7 @@ import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
-public class ResourceProviderDstu2Test {
+public class ResourceProviderDstu2Test extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourAppCtx;
private static IGenericClient ourClient;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
index b5bfd1dcbc1..7a5673a01cd 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/ResourceProviderMultiVersionTest.java
@@ -13,6 +13,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.testutil.RandomServerPortProvider;
import ca.uhn.fhir.model.api.Bundle;
import ca.uhn.fhir.model.dstu.resource.Patient;
@@ -26,7 +27,7 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer;
-public class ResourceProviderMultiVersionTest {
+public class ResourceProviderMultiVersionTest extends BaseJpaTest {
private static ClassPathXmlApplicationContext ourAppCtx;
private static IGenericClient ourClientDstu2;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
index 58b03c85ad0..380079407bd 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu1Test.java
@@ -19,6 +19,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.rp.dstu.ObservationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu.OrganizationResourceProvider;
@@ -34,7 +35,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.server.RestfulServer;
-public class SystemProviderDstu1Test {
+public class SystemProviderDstu1Test extends BaseJpaTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SystemProviderDstu1Test.class);
private static Server ourServer;
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
index 1a6ba0c4fdf..8c68a7e3ade 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/SystemProviderDstu2Test.java
@@ -15,6 +15,7 @@ import org.junit.Test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import ca.uhn.fhir.context.FhirContext;
+import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.dao.IFhirResourceDao;
import ca.uhn.fhir.jpa.rp.dstu.ObservationResourceProvider;
import ca.uhn.fhir.jpa.rp.dstu.OrganizationResourceProvider;
@@ -29,7 +30,7 @@ import ca.uhn.fhir.model.primitive.IdDt;
import ca.uhn.fhir.rest.client.IGenericClient;
import ca.uhn.fhir.rest.server.RestfulServer;
-public class SystemProviderDstu2Test {
+public class SystemProviderDstu2Test extends BaseJpaTest {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(SystemProviderDstu2Test.class);
private static Server ourServer;
From 6907009cab98af1a259c46f8d5196e1ef66b0ae2 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 00:12:33 -0400
Subject: [PATCH 26/35] Travis
---
hapi-fhir-cobertura/pom.xml | 1 +
.../src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java | 10 +++++-----
2 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml
index 13e1966f791..0ae80227bb5 100644
--- a/hapi-fhir-cobertura/pom.xml
+++ b/hapi-fhir-cobertura/pom.xml
@@ -301,6 +301,7 @@
maven-surefire-pluginalphabetical
+ false
diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
index 1cb376e895e..73131570890 100644
--- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
+++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/BaseJpaTest.java
@@ -10,11 +10,11 @@ public class BaseJpaTest {
@AfterClass
public static void afterClassShutdownDerby() throws SQLException {
- try {
- DriverManager.getConnection("jdbc:derby:memory:myUnitTestDB;drop=true");
- } catch (SQLNonTransientConnectionException e) {
- // expected.. for some reason....
- }
+// try {
+// DriverManager.getConnection("jdbc:derby:memory:myUnitTestDB;drop=true");
+// } catch (SQLNonTransientConnectionException e) {
+// // expected.. for some reason....
+// }
}
}
From d8c4bce72ac761a353987cb5cf49aa5df11ab1af Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 00:27:58 -0400
Subject: [PATCH 27/35] Travis
---
.travis.yml | 2 +-
README.md | 2 ++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/.travis.yml b/.travis.yml
index 72b14e81dd8..5403384d97c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -14,7 +14,7 @@ cache:
install: /bin/true
script:
- - cd hapi-fhir-cobertura && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
+ - mvn -B clean install && cd hapi-fhir-cobertura && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
# - mvn -B clean install -Dcobertura.skip=true && mvn -B -DTRAVIS_JOB_ID=$TRAVIS_JOB_ID -P COBERTURA clean cobertura:cobertura coveralls:report
diff --git a/README.md b/README.md
index 1a8f09d2609..d15ccb3cbd2 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,8 @@ hapi-fhir
HAPI FHIR - Java API for HL7 FHIR Clients and Servers
![Travis](https://travis-ci.org/jamesagnew/hapi-fhir.svg?branch=master)
+[![Coverage Status](https://coveralls.io/repos/jamesagnew/hapi-fhir/badge.svg?branch=master)](https://coveralls.io/r/jamesagnew/hapi-fhir?branch=master)
+![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)
Complete project documentation is available here:
http://jamesagnew.github.io/hapi-fhir/
From e9ac63688c963e781a618b875c09c867f21f58d0 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 00:48:10 -0400
Subject: [PATCH 28/35] Finally have travis and coveralls working!
---
hapi-fhir-base/pom.xml | 35 +++---
.../uhn/fhir/model/api/annotation/Child.java | 3 +
.../valueset/QuantityCompararatorEnum.java | 2 +
.../valueset/RestfulOperationSystemEnum.java | 2 +
.../valueset/RestfulOperationTypeEnum.java | 2 +
.../SecurityEventObjectSensitivityEnum.java | 2 +
.../valueset/SecurityEventObjectTypeEnum.java | 2 +
.../fhir/model/primitive/PositiveIntDt.java | 2 +
.../fhir/model/primitive/UnsignedIntDt.java | 2 +
.../valueset/BundleEntrySearchModeEnum.java | 2 +
.../BundleEntryTransactionMethodEnum.java | 2 +
.../fhir/model/valueset/BundleTypeEnum.java | 2 +
.../rest/server/ResponseResourceList.java | 118 ------------------
...CustomThymeleafNarrativeGeneratorTest.java | 2 +-
.../uhn/fhir/parser/JsonParserHl7OrgTest.java | 16 +--
.../fhir/parser/XmlParserHl7OrgDstu2Test.java | 9 +-
16 files changed, 47 insertions(+), 156 deletions(-)
delete mode 100644 hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/ResponseResourceList.java
diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml
index e521a9c49bd..5ec0e9da0de 100644
--- a/hapi-fhir-base/pom.xml
+++ b/hapi-fhir-base/pom.xml
@@ -161,6 +161,13 @@
test
+
+ net.sourceforge.cobertura
+ cobertura
+ 2.1.1
+ provided
+
+
@@ -195,13 +202,8 @@
-
+
org.apache.maven.pluginsmaven-jxr-plugin
@@ -213,20 +215,11 @@
jxr
-
+
", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
@@ -1231,11 +1230,6 @@ public class JsonParserHl7OrgTest {
}
- @BeforeClass
- public static void beforeClass() {
- ourCtx = FhirContext.forDstu2Hl7Org();
- }
-
@ResourceDef(name = "Patient")
public static class MyPatientWithOneDeclaredAddressExtension extends Patient {
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
index 209bf39e1e6..a4272882475 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
@@ -1107,7 +1107,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testLoadAndEncodeDeclaredExtensions() throws ConfigurationException, DataFormatException, SAXException, IOException {
- IParser p = new FhirContext(ResourceWithExtensionsA.class).newXmlParser();
+ IParser p = ourCtx.newXmlParser();
//@formatter:off
String msg = "\n" +
@@ -1142,7 +1142,7 @@ public class XmlParserHl7OrgDstu2Test {
"";
//@formatter:on
- ResourceWithExtensionsA resource = (ResourceWithExtensionsA) p.parseResource(msg);
+ ResourceWithExtensionsA resource = (ResourceWithExtensionsA) p.parseResource(ResourceWithExtensionsA.class, msg);
assertEquals("IdentifierLabel", resource.getIdentifier().get(0).getValue());
assertEquals("Foo1Value", resource.getFoo1().get(0).getValue());
assertEquals("Foo1Value2", resource.getFoo1().get(1).getValue());
@@ -1503,9 +1503,8 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException {
- FhirContext fhirCtx = new FhirContext(MyObservationWithExtensions.class);
String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
- MyObservationWithExtensions obs = fhirCtx.newXmlParser().parseResource(MyObservationWithExtensions.class, xmlString);
+ MyObservationWithExtensions obs = ourCtx.newXmlParser().parseResource(MyObservationWithExtensions.class, xmlString);
assertEquals(0, obs.getExtension().size());
assertEquals("aaaa", obs.getExtAtt().getContentType());
@@ -1516,7 +1515,7 @@ public class XmlParserHl7OrgDstu2Test {
Extension undeclaredExtension = undeclaredExtensions.get(0);
assertEquals("http://hl7.org/fhir/Profile/iso-21090#qualifier", undeclaredExtension.getUrl());
- IParser jsonParser = fhirCtx.newJsonParser().setPrettyPrint(true);
+ IParser jsonParser = ourCtx.newJsonParser().setPrettyPrint(true);
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
From 591f16fa9d50b27141555d17b85b570d45e8df3f Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 00:56:23 -0400
Subject: [PATCH 29/35] Fix cobertura
---
README.md | 4 ++--
hapi-fhir-base/pom.xml | 7 -------
pom.xml | 6 ++++++
3 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/README.md b/README.md
index d15ccb3cbd2..722eed8ca3c 100644
--- a/README.md
+++ b/README.md
@@ -3,9 +3,9 @@ hapi-fhir
HAPI FHIR - Java API for HL7 FHIR Clients and Servers
-![Travis](https://travis-ci.org/jamesagnew/hapi-fhir.svg?branch=master)
+[![Build Status](https://travis-ci.org/jamesagnew/hapi-fhir.svg?branch=master)](https://travis-ci.org/jamesagnew/hapi-fhir)
[![Coverage Status](https://coveralls.io/repos/jamesagnew/hapi-fhir/badge.svg?branch=master)](https://coveralls.io/r/jamesagnew/hapi-fhir?branch=master)
-![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)
+[![Maven Central](https://maven-badges.herokuapp.com/maven-central/ca.uhn.hapi.fhir/hapi-fhir-base/badge.svg)](http://search.maven.org/#search|ga|1|ca.uhn.hapi.fhir)
Complete project documentation is available here:
http://jamesagnew.github.io/hapi-fhir/
diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml
index 5ec0e9da0de..c5af475c091 100644
--- a/hapi-fhir-base/pom.xml
+++ b/hapi-fhir-base/pom.xml
@@ -160,13 +160,6 @@
${junit_version}test
-
-
- net.sourceforge.cobertura
- cobertura
- 2.1.1
- provided
-
diff --git a/pom.xml b/pom.xml
index 331f5b062f5..8c6e7f6d372 100644
--- a/pom.xml
+++ b/pom.xml
@@ -45,6 +45,12 @@
+
+ net.sourceforge.cobertura
+ cobertura
+ 2.1.1
+ provided
+
From b48843a12887b8259c452c4486810eec9c6483e0 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 12:16:33 -0400
Subject: [PATCH 30/35] More work on test coverage
---
.../uhn/fhir/model/api/annotation/Child.java | 3 ++
.../java/ca/uhn/fhir/parser/XmlParser.java | 51 +++++++++----------
.../FhirClientConnectionException.java | 2 +
...ClientInappropriateForServerException.java | 2 +
.../exceptions/InvalidResponseException.java | 2 +
.../exceptions/NonFhirResponseException.java | 3 ++
.../exceptions/AuthenticationException.java | 2 +
.../ForbiddenOperationException.java | 2 +
.../exceptions/InternalErrorException.java | 2 +
.../exceptions/InvalidRequestException.java | 2 +
.../exceptions/MethodNotAllowedException.java | 1 +
.../NotImplementedOperationException.java | 2 +
.../exceptions/NotModifiedException.java | 2 +
.../PreconditionFailedException.java | 2 +
.../exceptions/ResourceGoneException.java | 2 +
.../exceptions/ResourceNotFoundException.java | 3 ++
.../ResourceVersionConflictException.java | 2 +
.../ResourceVersionNotSpecifiedException.java | 2 +
.../UnclassifiedServerFailureException.java | 2 +
.../UnprocessableEntityException.java | 2 +
hapi-fhir-cobertura/pom.xml | 27 +++++++---
.../uhn/fhir/parser/JsonParserHl7OrgTest.java | 9 +++-
.../fhir/parser/XmlParserHl7OrgDstu2Test.java | 8 +--
... example-patient-general-hl7orgdstu2.json} | 0
...> example-patient-general-hl7orgdstu2.xml} | 0
25 files changed, 94 insertions(+), 41 deletions(-)
rename hapi-fhir-structures-hl7org-dstu2/src/test/resources/{example-patient-general.json => example-patient-general-hl7orgdstu2.json} (100%)
rename hapi-fhir-structures-hl7org-dstu2/src/test/resources/{example-patient-general.xml => example-patient-general-hl7orgdstu2.xml} (100%)
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java
index 25bb24df6e6..b0370b6c625 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/model/api/annotation/Child.java
@@ -111,15 +111,18 @@ public @interface Child {
@CoverageIgnore
public static class NoEnumFactory implements IBaseEnumFactory> {
+ @CoverageIgnore
private NoEnumFactory() {
// non instantiable
}
+ @CoverageIgnore
@Override
public Enum> fromCode(String theCodeString) throws IllegalArgumentException {
return null;
}
+ @CoverageIgnore
@Override
public String toCode(Enum> theCode) {
return null;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
index 37972bb1a0a..f32023ec0e4 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/parser/XmlParser.java
@@ -91,7 +91,8 @@ import ca.uhn.fhir.util.PrettyPrintWriterWrapper;
import ca.uhn.fhir.util.XmlUtil;
/**
- * This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use {@link FhirContext#newXmlParser()} to get an instance.
+ * This class is the FHIR XML parser/encoder. Users should not interact with this class directly, but should use
+ * {@link FhirContext#newXmlParser()} to get an instance.
*/
public class XmlParser extends BaseParser implements IParser {
@@ -110,7 +111,8 @@ public class XmlParser extends BaseParser implements IParser {
private boolean myPrettyPrint;
/**
- * Do not use this constructor, the recommended way to obtain a new instance of the XML parser is to invoke {@link FhirContext#newXmlParser()}.
+ * Do not use this constructor, the recommended way to obtain a new instance of the XML parser is to invoke
+ * {@link FhirContext#newXmlParser()}.
*
* @param theParserErrorHandler
*/
@@ -187,13 +189,11 @@ public class XmlParser extends BaseParser implements IParser {
}
- for (@SuppressWarnings("unchecked")
- Iterator iter = elem.getAttributes(); iter.hasNext();) {
+ @SuppressWarnings("unchecked")
+ Iterator attributes = elem.getAttributes();
+ for (Iterator iter = attributes; iter.hasNext();) {
Attribute next = iter.next();
- // if
- // (next.getName().getLocalPart().equals("value")) {
parserState.attributeValue(next.getName().getLocalPart(), next.getValue());
- // }
}
} else if (nextEvent.isAttribute()) {
@@ -446,8 +446,7 @@ public class XmlParser extends BaseParser implements IParser {
theEventWriter.close();
}
- private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase nextValue, String childName, BaseRuntimeElementDefinition> childDef,
- String theExtensionUrl, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
+ private void encodeChildElementToStreamWriter(IBaseResource theResource, XMLStreamWriter theEventWriter, IBase nextValue, String childName, BaseRuntimeElementDefinition> childDef, String theExtensionUrl, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
if (nextValue == null || nextValue.isEmpty()) {
if (isChildContained(childDef, theIncludedResource)) {
// We still want to go in..
@@ -502,9 +501,10 @@ public class XmlParser extends BaseParser implements IParser {
case CONTAINED_RESOURCE_LIST:
case CONTAINED_RESOURCES: {
/*
- * Disable per #103 for (IResource next : value.getContainedResources()) { if (getContainedResources().getResourceId(next) != null) { continue; }
- * theEventWriter.writeStartElement("contained"); encodeResourceToXmlStreamWriter(next, theEventWriter, true, fixContainedResourceId(next.getId().getValue()));
- * theEventWriter.writeEndElement(); }
+ * Disable per #103 for (IResource next : value.getContainedResources()) { if
+ * (getContainedResources().getResourceId(next) != null) { continue; }
+ * theEventWriter.writeStartElement("contained"); encodeResourceToXmlStreamWriter(next, theEventWriter, true,
+ * fixContainedResourceId(next.getId().getValue())); theEventWriter.writeEndElement(); }
*/
for (IBaseResource next : getContainedResources().getContainedResources()) {
IIdType resourceId = getContainedResources().getResourceId(next);
@@ -548,8 +548,7 @@ public class XmlParser extends BaseParser implements IParser {
}
- private void encodeCompositeElementChildrenToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, List extends BaseRuntimeChildDefinition> children,
- boolean theIncludedResource) throws XMLStreamException, DataFormatException {
+ private void encodeCompositeElementChildrenToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, List extends BaseRuntimeChildDefinition> children, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
for (BaseRuntimeChildDefinition nextChild : children) {
if (nextChild.getElementName().equals("extension") || nextChild.getElementName().equals("modifierExtension")) {
continue;
@@ -586,7 +585,8 @@ public class XmlParser extends BaseParser implements IParser {
// RuntimeChildNarrativeDefinition child = (RuntimeChildNarrativeDefinition) nextChild;
// String childName = nextChild.getChildNameByDatatype(child.getDatatype());
// BaseRuntimeElementDefinition> type = child.getChildByName(childName);
- // encodeChildElementToStreamWriter(theResource, theEventWriter, narr2, childName, type, null, theIncludedResource);
+ // encodeChildElementToStreamWriter(theResource, theEventWriter, narr2, childName, type, null,
+ // theIncludedResource);
// continue;
// }
}
@@ -594,8 +594,7 @@ public class XmlParser extends BaseParser implements IParser {
if (nextChild instanceof RuntimeChildContainedResources) {
if (!theIncludedResource) {
- encodeChildElementToStreamWriter(theResource, theEventWriter, null, nextChild.getChildNameByDatatype(null), nextChild.getChildElementDefinitionByDatatype(null), null,
- theIncludedResource);
+ encodeChildElementToStreamWriter(theResource, theEventWriter, null, nextChild.getChildNameByDatatype(null), nextChild.getChildElementDefinitionByDatatype(null), null, theIncludedResource);
}
} else {
@@ -641,8 +640,7 @@ public class XmlParser extends BaseParser implements IParser {
}
}
- private void encodeCompositeElementToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition> theElementDefinition,
- boolean theIncludedResource) throws XMLStreamException, DataFormatException {
+ private void encodeCompositeElementToStreamWriter(IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition> theElementDefinition, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
encodeExtensionsIfPresent(theResource, theEventWriter, theElement, theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, theElementDefinition.getExtensions(), theIncludedResource);
encodeCompositeElementChildrenToStreamWriter(theResource, theElement, theEventWriter, theElementDefinition.getChildren(), theIncludedResource);
@@ -665,8 +663,9 @@ public class XmlParser extends BaseParser implements IParser {
}
/**
- * This is just to work around the fact that casting java.util.List to java.util.List extends org.hl7.fhir.instance.model.api.IBaseExtension, ?>> seems to be
- * rejected by the compiler some of the time.
+ * This is just to work around the fact that casting java.util.List to
+ * java.util.List extends org.hl7.fhir.instance.model.api.IBaseExtension, ?>> seems to be rejected by the
+ * compiler some of the time.
*/
private > List> toBaseExtensionList(final List theList) {
List> retVal = new ArrayList>(theList.size());
@@ -691,11 +690,10 @@ public class XmlParser extends BaseParser implements IParser {
}
}
- private void encodeResourceToStreamWriterInDstu2Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter,
- BaseRuntimeElementCompositeDefinition> resDef, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
+ private void encodeResourceToStreamWriterInDstu2Format(RuntimeResourceDefinition theResDef, IBaseResource theResource, IBase theElement, XMLStreamWriter theEventWriter, BaseRuntimeElementCompositeDefinition> resDef, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
/*
- * DSTU2 requires extensions to come in a specific spot within the encoded content - This is a bit of a messy way to make that happen, but hopefully this won't matter as much once we use the
- * HL7 structures
+ * DSTU2 requires extensions to come in a specific spot within the encoded content - This is a bit of a messy way
+ * to make that happen, but hopefully this won't matter as much once we use the HL7 structures
*/
List preExtensionChildren = new ArrayList();
@@ -885,8 +883,7 @@ public class XmlParser extends BaseParser implements IParser {
}
}
- private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List extends IBaseExtension, ?>> theExtensions, String tagName, boolean theIncludedResource)
- throws XMLStreamException, DataFormatException {
+ private void encodeUndeclaredExtensions(IBaseResource theResource, XMLStreamWriter theWriter, List extends IBaseExtension, ?>> theExtensions, String tagName, boolean theIncludedResource) throws XMLStreamException, DataFormatException {
for (IBaseExtension, ?> next : theExtensions) {
if (next == null || (ElementUtil.isEmpty(next.getValue()) && next.getExtension().isEmpty())) {
continue;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java
index afb18fd43f2..573749d554f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientConnectionException.java
@@ -20,12 +20,14 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
/**
* Represents a failure by the HAPI FHIR Client to successfully communicate
* with a FHIR server, because of IO failures, incomprehensible response, etc.
*/
+@CoverageIgnore
public class FhirClientConnectionException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java
index c3bbd991acb..b8c5e69ce58 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/FhirClientInappropriateForServerException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
/**
@@ -27,6 +28,7 @@ import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
* communicate with a server which is a valid FHIR server but is incompatible
* with this client for some reason.
*/
+@CoverageIgnore
public class FhirClientInappropriateForServerException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java
index 59dd892a84d..5b4ac7070fc 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/InvalidResponseException.java
@@ -20,8 +20,10 @@ package ca.uhn.fhir.rest.client.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
+@CoverageIgnore
public class InvalidResponseException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java
index 0836d473dd7..a4142968e84 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/client/exceptions/NonFhirResponseException.java
@@ -25,10 +25,13 @@ import static org.apache.commons.lang3.StringUtils.*;
import java.io.IOException;
import java.io.Reader;
+import net.sourceforge.cobertura.CoverageIgnore;
+
import org.apache.commons.io.IOUtils;
import ca.uhn.fhir.rest.server.exceptions.BaseServerResponseException;
+@CoverageIgnore
public class NonFhirResponseException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java
index 9b74f843e37..57005048353 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/AuthenticationException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.rest.server.Constants;
/*
@@ -25,6 +26,7 @@ import ca.uhn.fhir.rest.server.Constants;
/**
* Represents an HTTP 401 Client Unauthorized response, which means that the client needs to provide credentials, or has provided invalid credentials.
*/
+@CoverageIgnore
public class AuthenticationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_401_CLIENT_UNAUTHORIZED;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java
index 6696e8bbde2..dd6fc5b5b16 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ForbiddenOperationException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -35,6 +36,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary.
*
*/
+@CoverageIgnore
public class ForbiddenOperationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_403_FORBIDDEN;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java
index 197d2f5cf9d..aca46166774 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InternalErrorException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -39,6 +40,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see UnprocessableEntityException Which should be used for business level validation failures
*/
+@CoverageIgnore
public class InternalErrorException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_500_INTERNAL_ERROR;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java
index 1f60ebe24e4..960d1b290c9 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/InvalidRequestException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -36,6 +37,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see UnprocessableEntityException Which should be used for business level validation failures
*/
+@CoverageIgnore
public class InvalidRequestException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_400_BAD_REQUEST;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java
index 9321b73c1bc..434276e57db 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/MethodNotAllowedException.java
@@ -5,6 +5,7 @@ import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.api.RequestTypeEnum;
import ca.uhn.fhir.rest.server.Constants;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java
index 13b63936a68..3bda91cfe5a 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotImplementedOperationException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -32,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary.
*
*/
+@CoverageIgnore
public class NotImplementedOperationException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_501_NOT_IMPLEMENTED;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java
index 82ffd9fdbda..bd77f74f2c6 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/NotModifiedException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -33,6 +34,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Summary.
*
*/
+@CoverageIgnore
public class NotModifiedException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_304_NOT_MODIFIED;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java
index 4161c7ccd5e..e931cd719d8 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/PreconditionFailedException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.annotation.Update;
import ca.uhn.fhir.rest.server.Constants;
@@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* be specified in an HTTP header, and none was.
*/
@SuppressWarnings("deprecation")
+@CoverageIgnore
public class PreconditionFailedException extends ResourceVersionNotSpecifiedException {
@SuppressWarnings("hiding")
public static final int STATUS_CODE = Constants.STATUS_HTTP_412_PRECONDITION_FAILED;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java
index be728be8408..285d29f5716 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceGoneException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.base.composite.BaseIdentifierDt;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
@@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* Represents an HTTP 410 Resource Gone response, which geenerally
* indicates that the resource has been deleted
*/
+@CoverageIgnore
public class ResourceGoneException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_410_GONE;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java
index 2d89461d86d..56b8f84672c 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceNotFoundException.java
@@ -20,6 +20,8 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
+
import org.hl7.fhir.instance.model.api.IIdType;
import ca.uhn.fhir.model.api.IResource;
@@ -31,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
/**
* Represents an HTTP 404 Resource Not Found response, which means that the request is pointing to a resource that does not exist.
*/
+@CoverageIgnore
public class ResourceNotFoundException extends BaseServerResponseException {
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java
index 9924f72a7f4..8f4ff824414 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionConflictException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.annotation.Delete;
import ca.uhn.fhir.rest.annotation.Update;
@@ -30,6 +31,7 @@ import ca.uhn.fhir.rest.server.Constants;
* thrown in methods which accept a version (e.g. {@link Update}, {@link Delete})
* when the operation fails because of a version conflict as specified in the FHIR specification.
*/
+@CoverageIgnore
public class ResourceVersionConflictException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_409_CONFLICT;
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java
index 7758c4611a6..07e343214ac 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/ResourceVersionNotSpecifiedException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -28,6 +29,7 @@ import ca.uhn.fhir.rest.server.Constants;
* strangely named and will be removed at some point.
*/
@Deprecated
+@CoverageIgnore
public class ResourceVersionNotSpecifiedException extends BaseServerResponseException {
public static final int STATUS_CODE = Constants.STATUS_HTTP_412_PRECONDITION_FAILED;
private static final long serialVersionUID = 1L;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java
index 46bf595df95..557b6e3cea8 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnclassifiedServerFailureException.java
@@ -1,5 +1,6 @@
package ca.uhn.fhir.rest.server.exceptions;
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
/*
@@ -26,6 +27,7 @@ import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
* Exception for use when a response is received or being sent that does not correspond to any other exception type. An HTTP status code must be provided, and will be provided to the caller in the
* case of a server implementation.
*/
+@CoverageIgnore
public class UnclassifiedServerFailureException extends BaseServerResponseException {
/**
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java
index 000b0aca59e..67c6d2e0d82 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/rest/server/exceptions/UnprocessableEntityException.java
@@ -20,6 +20,7 @@ package ca.uhn.fhir.rest.server.exceptions;
* #L%
*/
+import net.sourceforge.cobertura.CoverageIgnore;
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
import ca.uhn.fhir.rest.server.Constants;
@@ -32,6 +33,7 @@ import ca.uhn.fhir.rest.server.Constants;
*
* @see InvalidRequestException Which corresponds to an HTTP 400 Bad Request failure
*/
+@CoverageIgnore
public class UnprocessableEntityException extends BaseServerResponseException {
private static final String DEFAULT_MESSAGE = "Unprocessable Entity";
diff --git a/hapi-fhir-cobertura/pom.xml b/hapi-fhir-cobertura/pom.xml
index 0ae80227bb5..11d49becab3 100644
--- a/hapi-fhir-cobertura/pom.xml
+++ b/hapi-fhir-cobertura/pom.xml
@@ -62,11 +62,13 @@
jcl-over-slf4j${slf4j_version}
-
- org.slf4j
- slf4j-nop
- ${slf4j_version}
-
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback_version}
+ org.hamcrest
@@ -215,7 +217,10 @@
${maven_cobertura_plugin_version}false
- xml
+
+ html
+ xml
+ 256m
@@ -225,6 +230,11 @@
**/valueset/*.class**/exceptions/*.class
+
@@ -289,8 +299,9 @@
-
-
+
+
+
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
index 948141d4f52..89b264637ec 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
@@ -58,6 +58,7 @@ import org.hl7.fhir.instance.model.annotations.ResourceDef;
import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.utilities.xhtml.XhtmlNode;
+import org.junit.After;
import org.junit.BeforeClass;
import org.junit.Test;
import org.xml.sax.SAXException;
@@ -71,6 +72,10 @@ public class JsonParserHl7OrgTest {
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserHl7OrgTest.class);
+ @After
+ public void after() {
+ ourCtx.setNarrativeGenerator(null);
+ }
@Test
@@ -1133,7 +1138,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException, SAXException {
- String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
+ String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
MyObservationWithExtensions obs = ourCtx.newJsonParser().parseResource(MyObservationWithExtensions.class, jsonString);
assertEquals(0, obs.getExtension().size());
@@ -1149,7 +1154,7 @@ public class JsonParserHl7OrgTest {
String encoded = xmlParser.encodeResourceToString(obs);
encoded = encoded.replaceAll("", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
- String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
+ String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
xmlString = xmlString.replaceAll("", "").replace("\n", "").replace("\r", "").replaceAll(">\\s+<", "><");
ourLog.info("Expected: " + xmlString);
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
index a4272882475..8e94cfa56bc 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/XmlParserHl7OrgDstu2Test.java
@@ -1477,7 +1477,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncode() throws IOException, SAXException {
- String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
+ String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
Patient obs = ourCtx.newJsonParser().parseResource(Patient.class, xmlString);
List undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getExtension();
@@ -1490,7 +1490,7 @@ public class XmlParserHl7OrgDstu2Test {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
- String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
+ String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
String expected = (jsonString);
String actual = (encoded.trim());
@@ -1503,7 +1503,7 @@ public class XmlParserHl7OrgDstu2Test {
@Test
public void testSimpleResourceEncodeWithCustomType() throws IOException {
- String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
+ String xmlString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
MyObservationWithExtensions obs = ourCtx.newXmlParser().parseResource(MyObservationWithExtensions.class, xmlString);
assertEquals(0, obs.getExtension().size());
@@ -1519,7 +1519,7 @@ public class XmlParserHl7OrgDstu2Test {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
- String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
+ String jsonString = IOUtils.toString(XmlParserHl7OrgDstu2Test.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
JSON expected = JSONSerializer.toJSON(jsonString);
JSON actual = JSONSerializer.toJSON(encoded.trim());
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.json b/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.json
similarity index 100%
rename from hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.json
rename to hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.json
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.xml b/hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.xml
similarity index 100%
rename from hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general.xml
rename to hapi-fhir-structures-hl7org-dstu2/src/test/resources/example-patient-general-hl7orgdstu2.xml
From 9758f32021dc5ea8cba2e5107e79b983bdefa6cb Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 12:22:14 -0400
Subject: [PATCH 31/35] Fix build
---
.../java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java | 8 ++++----
pom.xml | 4 ++++
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
index 89b264637ec..9cee97ecc49 100644
--- a/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
+++ b/hapi-fhir-structures-hl7org-dstu2/src/test/java/ca/uhn/fhir/parser/JsonParserHl7OrgTest.java
@@ -1078,7 +1078,7 @@ public class JsonParserHl7OrgTest {
*/
@Test
public void testParseWithIncorrectReference() throws IOException {
- String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.json"));
+ String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"));
jsonString = jsonString.replace("\"reference\"", "\"resource\"");
Patient parsed = ourCtx.newJsonParser().parseResource(Patient.class, jsonString);
assertEquals("Organization/1", parsed.getManagingOrganization().getReference());
@@ -1087,7 +1087,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testSimpleParse() throws DataFormatException, IOException {
- String msg = IOUtils.toString(XmlParser.class.getResourceAsStream("/example-patient-general.json"));
+ String msg = IOUtils.toString(XmlParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"));
IParser p = ourCtx.newJsonParser();
// ourLog.info("Reading in message: {}", msg);
Patient res = p.parseResource(Patient.class, msg);
@@ -1104,7 +1104,7 @@ public class JsonParserHl7OrgTest {
@Test
public void testSimpleResourceEncode() throws IOException {
- String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.xml"), Charset.forName("UTF-8"));
+ String xmlString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.xml"), Charset.forName("UTF-8"));
Patient obs = ourCtx.newXmlParser().parseResource(Patient.class, xmlString);
List undeclaredExtensions = obs.getContact().get(0).getName().getFamily().get(0).getExtension();
@@ -1117,7 +1117,7 @@ public class JsonParserHl7OrgTest {
String encoded = jsonParser.encodeResourceToString(obs);
ourLog.info(encoded);
- String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general.json"), Charset.forName("UTF-8"));
+ String jsonString = IOUtils.toString(JsonParser.class.getResourceAsStream("/example-patient-general-hl7orgdstu2.json"), Charset.forName("UTF-8"));
JSON expected = JSONSerializer.toJSON(jsonString);
JSON actual = JSONSerializer.toJSON(encoded.trim());
diff --git a/pom.xml b/pom.xml
index 8c6e7f6d372..5373c838f23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -518,6 +518,9 @@
+
+
+
@@ -893,6 +896,7 @@
hapi-fhir-structures-dstu2hapi-fhir-structures-hl7org-dstu2hapi-fhir-jpaserver-base
+ hapi-fhir-coberturaexamples
From 685fa6d1646af80c32d6f4780f6a0e7c6bd2c497 Mon Sep 17 00:00:00 2001
From: jamesagnew
Date: Sun, 21 Jun 2015 22:10:13 -0400
Subject: [PATCH 32/35] Code and site cleanup
---
examples/pom.xml | 16 +-
hapi-deployable-pom/pom.xml | 12 +-
hapi-fhir-base/pom.xml | 8 +-
.../BaseRuntimeChildDatatypeDefinition.java | 10 +-
.../context/BaseRuntimeChildDefinition.java | 14 +-
...BaseRuntimeElementCompositeDefinition.java | 2 +-
.../context/BaseRuntimeElementDefinition.java | 3 -
.../java/ca/uhn/fhir/context/FhirContext.java | 2 +-
.../ca/uhn/fhir/context/ModelScanner.java | 12 +-
.../fhir/context/ProvidedResourceScanner.java | 81 +++---
...ntimeChildDeclaredExtensionDefinition.java | 1 -
.../context/RuntimeChildDirectResource.java | 1 -
.../RuntimeChildResourceDefinition.java | 3 -
.../RuntimeCompositeDatatypeDefinition.java | 2 +-
.../RuntimePrimitiveDatatypeDefinition.java | 2 +-
.../context/RuntimeResourceDefinition.java | 2 +-
.../RuntimeResourceReferenceDefinition.java | 2 +-
.../java/ca/uhn/fhir/model/api/IResource.java | 10 +-
.../model/base/composite/BaseQuantityDt.java | 1 -
.../fhir/model/primitive/BaseDateTimeDt.java | 6 +-
.../ca/uhn/fhir/model/primitive/IdDt.java | 2 +-
.../ca/uhn/fhir/model/view/ViewGenerator.java | 1 -
.../BaseThymeleafNarrativeGenerator.java | 2 +-
.../java/ca/uhn/fhir/parser/BaseParser.java | 6 +-
.../java/ca/uhn/fhir/parser/JsonParser.java | 19 +-
.../fhir/rest/gclient/TokenClientParam.java | 2 +-
.../BaseHttpClientInvocationWithContents.java | 1 -
.../fhir/rest/method/BaseMethodBinding.java | 2 -
.../BaseResourceReturningMethodBinding.java | 2 +-
.../rest/method/ConditionalParamBinder.java | 2 +-
.../rest/method/HistoryMethodBinding.java | 3 +-
.../rest/method/HttpGetClientInvocation.java | 1 -
.../fhir/rest/method/UpdateMethodBinding.java | 2 +-
.../ca/uhn/fhir/rest/param/NumberParam.java | 2 +-
.../ca/uhn/fhir/rest/param/ParameterUtil.java | 2 -
.../ca/uhn/fhir/rest/param/QuantityParam.java | 4 +-
.../uhn/fhir/rest/param/ReferenceParam.java | 3 +-
.../fhir/rest/param/ResourceParameter.java | 3 +-
.../java/ca/uhn/fhir/rest/param/UriParam.java | 2 +-
.../fhir/rest/server/BundleInclusionRule.java | 4 +-
.../uhn/fhir/rest/server/BundleProviders.java | 1 -
.../uhn/fhir/rest/server/RestfulServer.java | 2 +-
.../fhir/rest/server/RestfulServerUtils.java | 2 +-
.../exceptions/MethodNotAllowedException.java | 1 -
.../ExceptionHandlingInterceptor.java | 2 +-
.../interceptor/InterceptorAdapter.java | 2 -
.../java/ca/uhn/fhir/util/IModelVisitor.java | 4 +-
.../uhn/fhir/util/ResourceReferenceInfo.java | 1 -
hapi-fhir-cobertura/pom.xml | 29 ++-
pom.xml | 242 ++++++++----------
src/changes/changes.xml | 4 +-
src/checkstyle/checkstyle.xml | 17 +-
.../css/bootstrap-responsive.min.css | 20 ++
src/site/resources/hapi.css | 8 +-
src/site/site.xml | 8 +-
src/site/xdoc/doc_dstu2.xml | 136 ++++++++--
src/site/xdoc/download.xml.vm | 56 ++--
src/site/xdoc/index.xml | 15 +-
58 files changed, 457 insertions(+), 348 deletions(-)
create mode 100644 src/site/resources/css/bootstrap-responsive.min.css
diff --git a/examples/pom.xml b/examples/pom.xml
index 4316da83aab..1a58bcc20d8 100644
--- a/examples/pom.xml
+++ b/examples/pom.xml
@@ -1,4 +1,5 @@
-
+4.0.0
@@ -42,6 +43,19 @@
+
+
+
+ org.apache.maven.plugins
+ maven-project-info-reports-plugin
+ ${maven_project_info_plugin_version}
+
+ true
+
+
+
+
+
diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml
index 15f21b5f436..0af7779d6c5 100644
--- a/hapi-deployable-pom/pom.xml
+++ b/hapi-deployable-pom/pom.xml
@@ -18,14 +18,10 @@
org.apache.maven.pluginsmaven-project-info-reports-plugin
- 2.7
-
-
-
- scm
-
-
-
+ ${maven_project_info_plugin_version}
+
+ true
+ org.apache.maven.plugins
diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml
index c5af475c091..9fcea136f95 100644
--- a/hapi-fhir-base/pom.xml
+++ b/hapi-fhir-base/pom.xml
@@ -180,7 +180,7 @@
SITE
-
+
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDatatypeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDatatypeDefinition.java
index d019bdeed64..f4b22953899 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDatatypeDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDatatypeDefinition.java
@@ -41,14 +41,15 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
public BaseRuntimeChildDatatypeDefinition(Field theField, String theElementName, Child theChildAnnotation, Description theDescriptionAnnotation, Class extends IBase> theDatatype) {
super(theField, theChildAnnotation, theDescriptionAnnotation, theElementName);
- assert Modifier.isInterface(theDatatype.getModifiers()) == false : "Type of " + theDatatype + " shouldn't be here"; // should use RuntimeChildAny
+ // should use RuntimeChildAny
+ assert Modifier.isInterface(theDatatype.getModifiers()) == false : "Type of " + theDatatype + " shouldn't be here";
myDatatype = theDatatype;
}
@Override
public String getChildNameByDatatype(Class extends IBase> theDatatype) {
Class> nextType = theDatatype;
- while(nextType.equals(Object.class)==false) {
+ while (nextType.equals(Object.class) == false) {
if (myDatatype.equals(nextType)) {
return getElementName();
}
@@ -60,7 +61,7 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
@Override
public BaseRuntimeElementDefinition> getChildElementDefinitionByDatatype(Class extends IBase> theDatatype) {
Class> nextType = theDatatype;
- while(nextType.equals(Object.class)==false) {
+ while (nextType.equals(Object.class) == false) {
if (myDatatype.equals(nextType)) {
return myElementDefinition;
}
@@ -102,11 +103,10 @@ public abstract class BaseRuntimeChildDatatypeDefinition extends BaseRuntimeDecl
}
myCodeType = theType;
}
-
+
@Override
public String toString() {
return getClass().getSimpleName() + "[" + getElementName() + "]";
}
-
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java
index de200b7d5ff..e6063c01bce 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeChildDefinition.java
@@ -32,7 +32,7 @@ public abstract class BaseRuntimeChildDefinition {
@Override
public String toString() {
- return getClass().getSimpleName()+"[" + getElementName() + "]";
+ return getClass().getSimpleName() + "[" + getElementName() + "]";
}
public abstract BaseRuntimeElementDefinition> getChildByName(String theName);
@@ -52,11 +52,11 @@ public abstract class BaseRuntimeChildDefinition {
}
public abstract String getElementName();
-
+
public abstract int getMax();
-
+
public abstract int getMin();
-
+
public interface IMutator {
void setValue(Object theTarget, IBase theValue);
@@ -71,7 +71,7 @@ public abstract class BaseRuntimeChildDefinition {
return null;
}
-// public String getExtensionUrl() {
-// return null;
-// }
+ // public String getExtensionUrl() {
+ // return null;
+ // }
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
index 5f824db904b..688e70317a8 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementCompositeDefinition.java
@@ -41,7 +41,7 @@ public abstract class BaseRuntimeElementCompositeDefinition ext
super(theName, theImplementingClass, theStandardType);
}
- public void addChild(BaseRuntimeChildDefinition theNext) {
+ void addChild(BaseRuntimeChildDefinition theNext) {
if (theNext == null) {
throw new NullPointerException();
}
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java
index 5dd67fd5921..8fdc4c412de 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/BaseRuntimeElementDefinition.java
@@ -30,9 +30,6 @@ import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.hl7.fhir.instance.model.api.IBase;
-import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
-
-import ca.uhn.fhir.model.api.IValueSetEnumBinder;
public abstract class BaseRuntimeElementDefinition {
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
index df3aace9a4a..6a6f6ac7b3f 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/FhirContext.java
@@ -40,8 +40,8 @@ import ca.uhn.fhir.model.api.IResource;
import ca.uhn.fhir.model.view.ViewGenerator;
import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.parser.DataFormatException;
-import ca.uhn.fhir.parser.IParserErrorHandler;
import ca.uhn.fhir.parser.IParser;
+import ca.uhn.fhir.parser.IParserErrorHandler;
import ca.uhn.fhir.parser.JsonParser;
import ca.uhn.fhir.parser.LenientErrorHandler;
import ca.uhn.fhir.parser.XmlParser;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
index afeff8dc838..a425da2a4e2 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ModelScanner.java
@@ -48,21 +48,21 @@ import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
-import org.hl7.fhir.instance.model.api.IBase;
-import org.hl7.fhir.instance.model.api.IBaseResource;
-import org.hl7.fhir.instance.model.api.ICompositeType;
-import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.instance.model.api.IAnyResource;
+import org.hl7.fhir.instance.model.api.IBase;
import org.hl7.fhir.instance.model.api.IBaseBackboneElement;
import org.hl7.fhir.instance.model.api.IBaseDatatype;
+import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
import org.hl7.fhir.instance.model.api.IBaseEnumFactory;
import org.hl7.fhir.instance.model.api.IBaseEnumeration;
import org.hl7.fhir.instance.model.api.IBaseExtension;
+import org.hl7.fhir.instance.model.api.IBaseReference;
+import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IBaseXhtml;
-import org.hl7.fhir.instance.model.api.IBaseDatatypeElement;
+import org.hl7.fhir.instance.model.api.ICompositeType;
import org.hl7.fhir.instance.model.api.IIdType;
import org.hl7.fhir.instance.model.api.INarrative;
-import org.hl7.fhir.instance.model.api.IBaseReference;
+import org.hl7.fhir.instance.model.api.IPrimitiveType;
import ca.uhn.fhir.model.api.CodeableConceptElement;
import ca.uhn.fhir.model.api.ExtensionDt;
diff --git a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ProvidedResourceScanner.java b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ProvidedResourceScanner.java
index c0c3f6d693a..5f41f077fe1 100644
--- a/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ProvidedResourceScanner.java
+++ b/hapi-fhir-base/src/main/java/ca/uhn/fhir/context/ProvidedResourceScanner.java
@@ -20,7 +20,8 @@ package ca.uhn.fhir.context;
* #L%
*/
-import ca.uhn.fhir.model.api.IResource;
+import org.hl7.fhir.instance.model.api.IBaseResource;
+
import ca.uhn.fhir.model.api.annotation.ProvidesResources;
/**
@@ -30,42 +31,48 @@ import ca.uhn.fhir.model.api.annotation.ProvidesResources;
* @see ca.uhn.fhir.model.api.annotation.ProvidesResources
*/
public class ProvidedResourceScanner {
- private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ModelScanner.class);
- private FhirContext myContext;
+ private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ProvidedResourceScanner.class);
+ private FhirContext myContext;
- /**
- * Constructor
- * @param theContext - context whose resource definition list is to be updated by the scanner
- */
- public ProvidedResourceScanner(FhirContext theContext) {
- myContext = theContext;
- }
+ /**
+ * Constructor
+ *
+ * @param theContext
+ * - context whose resource definition list is to be updated by the scanner
+ */
+ public ProvidedResourceScanner(FhirContext theContext) {
+ myContext = theContext;
+ }
- /**
- * If {@code theProvider} is tagged with the {@code ProvidesResources} annotation, this method will add every resource listed
- * by the {@code resources} method.
- *
- * Notes:
- *
- *
- *
if {@code theProvider} isn't annotated with {@code resources} nothing is done; it's expected that most RestfulServers and
- * ResourceProviders won't be annotated.
- *
any object listed in {@code resources} that doesn't implement {@code IResource} will generate a warning in the log.
- *
- *
- * @param theProvider - Normally, either a {@link ca.uhn.fhir.rest.server.RestfulServer} or a {@link ca.uhn.fhir.rest.server.IResourceProvider}
- * that might be annotated with {@link ca.uhn.fhir.model.api.annotation.ProvidesResources}
- */
- public void scanForProvidedResources(Object theProvider) {
- ProvidesResources annotation = theProvider.getClass().getAnnotation(ProvidesResources.class);
- if (annotation == null)
- return;
- for (Class clazz : annotation.resources()) {
- if (IResource.class.isAssignableFrom(clazz)) {
- myContext.getResourceDefinition(clazz);
- } else {
- ourLog.warn(clazz.getSimpleName() + "is not assignable from IResource");
- }
- }
- }
+ /**
+ * If {@code theProvider} is tagged with the {@code ProvidesResources} annotation, this method will add every
+ * resource listed by the {@code resources} method.
+ *
+ * Notes:
+ *
+ *
+ *
if {@code theProvider} isn't annotated with {@code resources} nothing is done; it's expected that most
+ * RestfulServers and ResourceProviders won't be annotated.
+ *
any object listed in {@code resources} that doesn't implement {@code IResource} will generate a warning in the
+ * log.