Fix tests

This commit is contained in:
jamesagnew 2016-07-24 09:20:54 -04:00
parent a9b29d5088
commit 7dbd5a21ca
54 changed files with 110 additions and 73 deletions

View File

@ -12,7 +12,7 @@ import ca.uhn.fhir.rest.gclient.ITransactionTyped;
public class ClientTest { public class ClientTest {
private static final FhirContext ctx = FhirContext.forDstu1(); private static FhirContext ctx = FhirContext.forDstu1();
@Test @Test
public void testTransaction() { public void testTransaction() {

View File

@ -5,6 +5,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.AfterClass;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
@ -12,14 +13,20 @@ import ca.uhn.fhir.model.dstu.composite.QuantityDt;
import ca.uhn.fhir.model.dstu.resource.Organization; import ca.uhn.fhir.model.dstu.resource.Organization;
import ca.uhn.fhir.model.dstu.resource.Patient; import ca.uhn.fhir.model.dstu.resource.Patient;
import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum; import ca.uhn.fhir.model.dstu.valueset.QuantityCompararatorEnum;
import ca.uhn.fhir.util.TestUtil;
public class MultiVersionXmlParserTest { public class MultiVersionXmlParserTest {
private static final FhirContext ourCtxDstu1 = FhirContext.forDstu1(); private static FhirContext ourCtxDstu1 = FhirContext.forDstu1();
private static final FhirContext ourCtxDstu2 = FhirContext.forDstu2(); private static FhirContext ourCtxDstu2 = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MultiVersionXmlParserTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MultiVersionXmlParserTest.class);
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Test @Test
public void testEncodeExtensionFromDifferentVersion() { public void testEncodeExtensionFromDifferentVersion() {
Patient p = new Patient(); Patient p = new Patient();

View File

@ -34,11 +34,11 @@ import ca.uhn.fhir.rest.server.exceptions.MethodNotAllowedException;
* other than those supported by the server with an HTTP 405. This is a requirement * other than those supported by the server with an HTTP 405. This is a requirement
* of some security assessments. * of some security assessments.
*/ */
public class BanUnsupprtedHttpMethodsInterceptor extends InterceptorAdapter { public class BanUnsupportedHttpMethodsInterceptor extends InterceptorAdapter {
private Set<RequestTypeEnum> myAllowedMethods = new HashSet<RequestTypeEnum>(); private Set<RequestTypeEnum> myAllowedMethods = new HashSet<RequestTypeEnum>();
public BanUnsupprtedHttpMethodsInterceptor() { public BanUnsupportedHttpMethodsInterceptor() {
myAllowedMethods.add(RequestTypeEnum.GET); myAllowedMethods.add(RequestTypeEnum.GET);
myAllowedMethods.add(RequestTypeEnum.OPTIONS); myAllowedMethods.add(RequestTypeEnum.OPTIONS);
myAllowedMethods.add(RequestTypeEnum.DELETE); myAllowedMethods.add(RequestTypeEnum.DELETE);

View File

@ -64,6 +64,7 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.EncodingEnum; import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.util.TestUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AbstractJaxRsResourceProviderDstu3Test { public class AbstractJaxRsResourceProviderDstu3Test {
@ -72,7 +73,7 @@ public class AbstractJaxRsResourceProviderDstu3Test {
private static IGenericClient client; private static IGenericClient client;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static final String PATIENT_NAME = "Van Houte"; private static final String PATIENT_NAME = "Van Houte";
private static int ourPort; private static int ourPort;
@ -87,6 +88,11 @@ public class AbstractJaxRsResourceProviderDstu3Test {
assertEquals(id, Integer.parseInt(resource.getIdElement().getIdPart())); assertEquals(id, Integer.parseInt(resource.getIdElement().getIdPart()));
} }
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
private void compareResultUrl(String url, IBaseResource resource) { private void compareResultUrl(String url, IBaseResource resource) {
assertEquals(url, resource.getIdElement().getValueAsString().substring(serverBase.length() - 1)); assertEquals(url, resource.getIdElement().getValueAsString().substring(serverBase.length() - 1));
} }

View File

@ -64,6 +64,7 @@ import ca.uhn.fhir.rest.param.StringAndListParam;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.rest.server.EncodingEnum; import ca.uhn.fhir.rest.server.EncodingEnum;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.util.TestUtil;
@FixMethodOrder(MethodSorters.NAME_ASCENDING) @FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class AbstractJaxRsResourceProviderTest { public class AbstractJaxRsResourceProviderTest {
@ -72,7 +73,7 @@ public class AbstractJaxRsResourceProviderTest {
private static IGenericClient client; private static IGenericClient client;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final String PATIENT_NAME = "Van Houte"; private static final String PATIENT_NAME = "Van Houte";
private static int ourPort; private static int ourPort;
@ -91,6 +92,11 @@ public class AbstractJaxRsResourceProviderTest {
assertEquals(url, resource.getId().getValueAsString().substring(serverBase.length() - 1)); assertEquals(url, resource.getId().getValueAsString().substring(serverBase.length() - 1));
} }
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
private Patient createPatient(long id) { private Patient createPatient(long id) {
Patient theResource = new Patient(); Patient theResource = new Patient();
theResource.setId(new IdDt(id)); theResource.setId(new IdDt(id));

View File

@ -42,11 +42,16 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
public class JaxRsPatientProviderDstu3Test { public class JaxRsPatientProviderDstu3Test {
private static IGenericClient client; private static IGenericClient client;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static final String PATIENT_NAME = "Van Houte"; private static final String PATIENT_NAME = "Van Houte";
private static int ourPort; private static int ourPort;
private static Server jettyServer; private static Server jettyServer;
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@BeforeClass @BeforeClass
public static void setUpClass() public static void setUpClass()
throws Exception { throws Exception {

View File

@ -41,11 +41,16 @@ import ca.uhn.fhir.rest.server.EncodingEnum;
public class JaxRsPatientProviderTest { public class JaxRsPatientProviderTest {
private static IGenericClient client; private static IGenericClient client;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final String PATIENT_NAME = "Van Houte"; private static final String PATIENT_NAME = "Van Houte";
private static int ourPort; private static int ourPort;
private static Server jettyServer; private static Server jettyServer;
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@BeforeClass @BeforeClass
public static void setUpClass() public static void setUpClass()
throws Exception { throws Exception {

View File

@ -19,7 +19,7 @@ import ca.uhn.fhir.util.TestUtil;
public class SearchParamExtractorDstu3Test { public class SearchParamExtractorDstu3Test {
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static IValidationSupport ourValidationSupport; private static IValidationSupport ourValidationSupport;
@AfterClass @AfterClass

View File

@ -21,7 +21,7 @@ import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
public class ExampleServerIT { public class ExampleServerIT {
private static IGenericClient ourClient; private static IGenericClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerIT.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerIT.class);
private static int ourPort; private static int ourPort;

View File

@ -32,7 +32,7 @@ import ca.uhn.fhir.rest.server.FifoMemoryPagingProvider;
import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy; import ca.uhn.fhir.rest.server.HardcodedServerAddressStrategy;
import ca.uhn.fhir.rest.server.IResourceProvider; import ca.uhn.fhir.rest.server.IResourceProvider;
import ca.uhn.fhir.rest.server.RestfulServer; import ca.uhn.fhir.rest.server.RestfulServer;
import ca.uhn.fhir.rest.server.interceptor.BanUnsupprtedHttpMethodsInterceptor; import ca.uhn.fhir.rest.server.interceptor.BanUnsupportedHttpMethodsInterceptor;
import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor; import ca.uhn.fhir.rest.server.interceptor.IServerInterceptor;
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor; import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
import ca.uhn.fhirtest.config.TestDstu3Config; import ca.uhn.fhirtest.config.TestDstu3Config;
@ -176,7 +176,7 @@ public class TestRestfulServer extends RestfulServer {
* makes things a little easier for testers. * makes things a little easier for testers.
*/ */
registerInterceptor(new ResponseHighlighterInterceptor()); registerInterceptor(new ResponseHighlighterInterceptor());
registerInterceptor(new BanUnsupprtedHttpMethodsInterceptor()); registerInterceptor(new BanUnsupportedHttpMethodsInterceptor());
/* /*
* Default to JSON with pretty printing * Default to JSON with pretty printing

View File

@ -15,7 +15,7 @@ import ca.uhn.fhir.util.TestUtil;
public class BaseParserTest { public class BaseParserTest {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseParserTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BaseParserTest.class);

View File

@ -43,7 +43,7 @@ import ch.qos.logback.core.Appender;
*/ */
public class LoggingInterceptorTest { public class LoggingInterceptorTest {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private Logger myLoggerRoot; private Logger myLoggerRoot;

View File

@ -41,7 +41,7 @@ import ca.uhn.fhir.util.TestUtil;
public class CompositeParameterTest { public class CompositeParameterTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;

View File

@ -39,7 +39,7 @@ import ca.uhn.fhir.util.TestUtil;
public class CompressionTest { public class CompressionTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompressionTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CompressionTest.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;

View File

@ -40,7 +40,7 @@ public class CorsTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static Server ourServer; private static Server ourServer;
private static String ourBaseUri; private static String ourBaseUri;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CorsTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CorsTest.class);
@Test @Test

View File

@ -49,7 +49,7 @@ import ca.uhn.fhir.util.TestUtil;
public class CreateTest { public class CreateTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static EncodingEnum ourLastEncoding; private static EncodingEnum ourLastEncoding;
private static String ourLastResourceBody; private static String ourLastResourceBody;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CreateTest.class);

View File

@ -40,7 +40,7 @@ import ca.uhn.fhir.util.TestUtil;
public class DefaultEncodingTest { public class DefaultEncodingTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static RestfulServer ourRestfulServer; private static RestfulServer ourRestfulServer;
private static Server ourServer; private static Server ourServer;

View File

@ -27,7 +27,7 @@ import ca.uhn.fhir.util.TestUtil;
@RunWith(MockitoJUnitRunner.class) @RunWith(MockitoJUnitRunner.class)
public class DestroyTest { public class DestroyTest {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
@Test @Test
public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException { public void testDestroyCallsAnnotatedMethodsOnProviders() throws ServletException {

View File

@ -51,7 +51,7 @@ public class ExceptionTest {
private static final String OPERATION_OUTCOME_DETAILS = "OperationOutcomeDetails"; private static final String OPERATION_OUTCOME_DETAILS = "OperationOutcomeDetails";
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static Class<? extends Exception> ourExceptionType; private static Class<? extends Exception> ourExceptionType;
private static boolean ourGenerateOperationOutcome; private static boolean ourGenerateOperationOutcome;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionTest.class);

View File

@ -49,7 +49,7 @@ import ca.uhn.fhir.util.TestUtil;
public class InterceptorTest { public class InterceptorTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer servlet; private static RestfulServer servlet;

View File

@ -49,7 +49,7 @@ public class PagingTest {
private static SimpleBundleProvider ourBundleProvider; private static SimpleBundleProvider ourBundleProvider;
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static FhirContext ourContext; private static FhirContext ourContext;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private IPagingProvider myPagingProvider; private IPagingProvider myPagingProvider;

View File

@ -50,7 +50,7 @@ import ca.uhn.fhir.util.TestUtil;
public class PlainProviderTest { public class PlainProviderTest {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PlainProviderTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(PlainProviderTest.class);
private CloseableHttpClient myClient; private CloseableHttpClient myClient;
private int myPort; private int myPort;

View File

@ -36,7 +36,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ReadDstu1Test { public class ReadDstu1Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadDstu1Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReadDstu1Test.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;

View File

@ -54,7 +54,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ReferenceParameterTest { public class ReferenceParameterTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static ReferenceParam ourLastRefParam; private static ReferenceParam ourLastRefParam;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReferenceParameterTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ReferenceParameterTest.class);
private static int ourPort; private static int ourPort;

View File

@ -24,7 +24,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ResourceProviderWithNoMethodsTest { public class ResourceProviderWithNoMethodsTest {
private Server ourServer; private Server ourServer;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
@After @After
public void after() throws Exception { public void after() throws Exception {

View File

@ -88,7 +88,7 @@ import ca.uhn.fhir.util.TestUtil;
public class RestfulServerMethodTest { public class RestfulServerMethodTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestfulServerMethodTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RestfulServerMethodTest.class);
private static int ourPort; private static int ourPort;
private static DummyDiagnosticReportResourceProvider ourReportProvider; private static DummyDiagnosticReportResourceProvider ourReportProvider;

View File

@ -51,7 +51,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ServerFeaturesTest { public class ServerFeaturesTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer servlet; private static RestfulServer servlet;

View File

@ -31,7 +31,7 @@ import ca.uhn.fhir.rest.param.StringParam;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
public class ServerInvalidDefinitionTest { public class ServerInvalidDefinitionTest {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
/** /**
* Normal, should initialize properly * Normal, should initialize properly

View File

@ -24,7 +24,7 @@ import java.util.List;
* Created by Bill de Beaubien on 11/1/2014. * Created by Bill de Beaubien on 11/1/2014.
*/ */
public class ServerProvidedResourceScannerTest extends TestCase { public class ServerProvidedResourceScannerTest extends TestCase {
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
@Test @Test
public void testWhenRestfulServerInitialized_annotatedResources_shouldBeAddedToContext() throws ServletException { public void testWhenRestfulServerInitialized_annotatedResources_shouldBeAddedToContext() throws ServletException {

View File

@ -62,7 +62,7 @@ import ca.uhn.fhir.util.TestUtil;
public class AuditingInterceptorTest { public class AuditingInterceptorTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer servlet; private static RestfulServer servlet;

View File

@ -48,7 +48,7 @@ public class ExceptionHandlingInterceptorTest {
private static ExceptionHandlingInterceptor myInterceptor; private static ExceptionHandlingInterceptor myInterceptor;
private static final String OPERATION_OUTCOME_DETAILS = "OperationOutcomeDetails"; private static final String OPERATION_OUTCOME_DETAILS = "OperationOutcomeDetails";
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static Class<? extends Exception> ourExceptionType; private static Class<? extends Exception> ourExceptionType;
private static boolean ourGenerateOperationOutcome; private static boolean ourGenerateOperationOutcome;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionTest.class);

View File

@ -41,7 +41,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ExceptionInterceptorMethodTest { public class ExceptionInterceptorMethodTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu1(); private static FhirContext ourCtx = FhirContext.forDstu1();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionInterceptorMethodTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExceptionInterceptorMethodTest.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;

View File

@ -26,7 +26,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ModelSerializationDstu2Test { public class ModelSerializationDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
@AfterClass @AfterClass
public static void afterClassClearContext() { public static void afterClassClearContext() {

View File

@ -35,7 +35,7 @@ import ca.uhn.fhir.util.TestUtil;
public class CustomTypeDstu2Test { public class CustomTypeDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomTypeDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomTypeDstu2Test.class);
@AfterClass @AfterClass

View File

@ -16,7 +16,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ExtensionsDstu2Test { public class ExtensionsDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
@AfterClass @AfterClass
public static void afterClassClearContext() { public static void afterClassClearContext() {

View File

@ -78,7 +78,7 @@ import net.sf.json.JSONSerializer;
import net.sf.json.JsonConfig; import net.sf.json.JsonConfig;
public class JsonParserDstu2Test { public class JsonParserDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserDstu2Test.class);
@Test @Test

View File

@ -103,7 +103,7 @@ import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.util.TestUtil; import ca.uhn.fhir.util.TestUtil;
public class XmlParserDstu2Test { public class XmlParserDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(XmlParserDstu2Test.class);
@Test @Test

View File

@ -31,7 +31,7 @@ import ca.uhn.fhir.util.TestUtil;
public class DeleteDstu2Test { public class DeleteDstu2Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static boolean ourInvoked; private static boolean ourInvoked;
private static String ourLastConditionalUrl; private static String ourLastConditionalUrl;
private static IdDt ourLastIdParam; private static IdDt ourLastIdParam;

View File

@ -59,7 +59,7 @@ import ca.uhn.fhir.util.TestUtil;
public class InterceptorUserDataMapDstu2Test { public class InterceptorUserDataMapDstu2Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(InterceptorUserDataMapDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(InterceptorUserDataMapDstu2Test.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;

View File

@ -65,7 +65,7 @@ import ca.uhn.fhir.util.TestUtil;
public class LoggingInterceptorDstu2Test { public class LoggingInterceptorDstu2Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer servlet; private static RestfulServer servlet;

View File

@ -74,7 +74,7 @@ import ca.uhn.fhir.util.UrlUtil;
public class ResponseHighlightingInterceptorTest { public class ResponseHighlightingInterceptorTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResponseHighlightingInterceptorTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResponseHighlightingInterceptorTest.class);
private static int ourPort; private static int ourPort;

View File

@ -56,7 +56,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ServerActionInterceptorTest { public class ServerActionInterceptorTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu2(); private static FhirContext ourCtx = FhirContext.forDstu2();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static IServerInterceptor ourInterceptor; private static IServerInterceptor ourInterceptor;

View File

@ -20,7 +20,7 @@ import ca.uhn.fhir.util.TestUtil;
public class MinimizeResources { public class MinimizeResources {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MinimizeResources.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MinimizeResources.class);
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
@AfterClass @AfterClass
public static void afterClassClearContext() { public static void afterClassClearContext() {

View File

@ -21,7 +21,7 @@ import ca.uhn.fhir.util.TestUtil;
public class ModelSerializationDstu3Test { public class ModelSerializationDstu3Test {
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
/** /**
* Verify that MaritalStatusCodeEnum (and, by extension, BoundCodeableConcepts in general) are serializable. Author: Nick Peterson (nrpeterson@gmail.com) * Verify that MaritalStatusCodeEnum (and, by extension, BoundCodeableConcepts in general) are serializable. Author: Nick Peterson (nrpeterson@gmail.com)

View File

@ -36,7 +36,7 @@ import ca.uhn.fhir.util.TestUtil;
public class CustomTypeDstu3Test { public class CustomTypeDstu3Test {
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomTypeDstu3Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(CustomTypeDstu3Test.class);
@Before @Before

View File

@ -36,7 +36,7 @@ import ca.uhn.fhir.util.TestUtil;
public class DateRangeParamSearchDstu3Test { public class DateRangeParamSearchDstu3Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static DateRangeParam ourLastDateRange; private static DateRangeParam ourLastDateRange;
private static int ourPort; private static int ourPort;

View File

@ -50,7 +50,7 @@ import ca.uhn.fhir.util.TestUtil;
public class InterceptorDstu3Test { public class InterceptorDstu3Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer ourServlet; private static RestfulServer ourServlet;

View File

@ -40,11 +40,12 @@ import ca.uhn.fhir.util.VersionUtil;
public class MetadataDstu3Test { public class MetadataDstu3Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
private static RestfulServer servlet; private static RestfulServer servlet;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MetadataDstu3Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(MetadataDstu3Test.class);
@Test @Test
public void testSummary() throws Exception { public void testSummary() throws Exception {
String output; String output;

View File

@ -1,13 +1,8 @@
package ca.uhn.fhir.rest.server.interceptor; package ca.uhn.fhir.rest.server.interceptor;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import java.net.URI; import java.net.URI;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -24,14 +19,11 @@ import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.servlet.ServletHandler; import org.eclipse.jetty.servlet.ServletHandler;
import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.servlet.ServletHolder;
import org.hamcrest.core.StringContains;
import org.hl7.fhir.dstu3.model.IdType; import org.hl7.fhir.dstu3.model.IdType;
import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Patient;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.BeforeClass; import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.slf4j.Logger;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.annotation.IdParam; import ca.uhn.fhir.rest.annotation.IdParam;
@ -45,7 +37,7 @@ import ca.uhn.fhir.util.TestUtil;
public class BanUnsupprtedHttpMethodsInterceptorDstu3Test { public class BanUnsupprtedHttpMethodsInterceptorDstu3Test {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BanUnsupprtedHttpMethodsInterceptorDstu3Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(BanUnsupprtedHttpMethodsInterceptorDstu3Test.class);
private static int ourPort; private static int ourPort;
private static Server ourServer; private static Server ourServer;
@ -127,7 +119,7 @@ public class BanUnsupprtedHttpMethodsInterceptorDstu3Test {
servlet = new RestfulServer(ourCtx); servlet = new RestfulServer(ourCtx);
servlet.setResourceProviders(new DummyPatientResourceProvider()); servlet.setResourceProviders(new DummyPatientResourceProvider());
servlet.registerInterceptor(new BanUnsupprtedHttpMethodsInterceptor()); servlet.registerInterceptor(new BanUnsupportedHttpMethodsInterceptor());
ServletHolder servletHolder = new ServletHolder(servlet); ServletHolder servletHolder = new ServletHolder(servlet);
proxyHandler.addServletWithMapping(servletHolder, "/*"); proxyHandler.addServletWithMapping(servletHolder, "/*");

View File

@ -50,7 +50,7 @@ import ca.uhn.fhir.util.TestUtil;
public class QuestionnaireResponseValidatorDstu3Test { public class QuestionnaireResponseValidatorDstu3Test {
private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport(); private static DefaultProfileValidationSupport myDefaultValidationSupport = new DefaultProfileValidationSupport();
private static final FhirContext ourCtx = FhirContext.forDstu3(); private static FhirContext ourCtx = FhirContext.forDstu3();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorDstu3Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorDstu3Test.class);
private FhirInstanceValidator myInstanceVal; private FhirInstanceValidator myInstanceVal;

View File

@ -10,7 +10,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
@ -61,6 +60,7 @@ import org.hl7.fhir.instance.model.api.INarrative;
import org.hl7.fhir.instance.model.api.IPrimitiveType; import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.hl7.fhir.instance.utilities.xhtml.XhtmlNode; import org.hl7.fhir.instance.utilities.xhtml.XhtmlNode;
import org.junit.After; import org.junit.After;
import org.junit.AfterClass;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
@ -71,11 +71,12 @@ import ca.uhn.fhir.model.api.annotation.Child;
import ca.uhn.fhir.model.api.annotation.ResourceDef; import ca.uhn.fhir.model.api.annotation.ResourceDef;
import ca.uhn.fhir.narrative.INarrativeGenerator; import ca.uhn.fhir.narrative.INarrativeGenerator;
import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.Constants;
import ca.uhn.fhir.util.TestUtil;
import net.sf.json.JSON; import net.sf.json.JSON;
import net.sf.json.JSONSerializer; import net.sf.json.JSONSerializer;
public class JsonParserHl7OrgDstu2Test { public class JsonParserHl7OrgDstu2Test {
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org(); private static FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserHl7OrgDstu2Test.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(JsonParserHl7OrgDstu2Test.class);
@After @After
@ -83,6 +84,11 @@ public class JsonParserHl7OrgDstu2Test {
ourCtx.setNarrativeGenerator(null); ourCtx.setNarrativeGenerator(null);
} }
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Test @Test
public void testEncodeUndeclaredExtensionWithEnumerationContent() { public void testEncodeUndeclaredExtensionWithEnumerationContent() {
IParser parser = ourCtx.newJsonParser(); IParser parser = ourCtx.newJsonParser();

View File

@ -35,7 +35,7 @@ public class DeleteConditionalHl7OrgTest {
private static CloseableHttpClient ourClient; private static CloseableHttpClient ourClient;
private static String ourLastConditionalUrl; private static String ourLastConditionalUrl;
private static int ourPort; private static int ourPort;
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org(); private static FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static Server ourServer; private static Server ourServer;
private static IdType ourLastIdParam; private static IdType ourLastIdParam;

View File

@ -3,8 +3,6 @@ package ca.uhn.fhir.validation;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;
@ -25,6 +23,7 @@ import org.hl7.fhir.instance.model.Reference;
import org.hl7.fhir.instance.model.StringType; import org.hl7.fhir.instance.model.StringType;
import org.hl7.fhir.instance.model.ValueSet; import org.hl7.fhir.instance.model.ValueSet;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.mockito.Mockito; import org.mockito.Mockito;
@ -33,16 +32,19 @@ import org.mockito.stubbing.Answer;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException; import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
import ca.uhn.fhir.util.TestUtil;
public class QuestionnaireResponseValidatorIntegrationTest { public class QuestionnaireResponseValidatorIntegrationTest {
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org(); private static FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorIntegrationTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorIntegrationTest.class);
private IResourceLoader myResourceLoaderMock; private IResourceLoader myResourceLoaderMock;
private FhirValidator myVal; private FhirValidator myVal;
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Before @Before
public void before() { public void before() {
myResourceLoaderMock = mock(IResourceLoader.class); myResourceLoaderMock = mock(IResourceLoader.class);

View File

@ -23,13 +23,15 @@ import org.hl7.fhir.instance.model.ValueSet;
import org.hl7.fhir.instance.utils.WorkerContext; import org.hl7.fhir.instance.utils.WorkerContext;
import org.hl7.fhir.instance.validation.QuestionnaireResponseValidator; import org.hl7.fhir.instance.validation.QuestionnaireResponseValidator;
import org.hl7.fhir.instance.validation.ValidationMessage; import org.hl7.fhir.instance.validation.ValidationMessage;
import org.junit.AfterClass;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.util.TestUtil;
public class QuestionnaireResponseValidatorTest { public class QuestionnaireResponseValidatorTest {
private static final FhirContext ourCtx = FhirContext.forDstu2Hl7Org(); private static FhirContext ourCtx = FhirContext.forDstu2Hl7Org();
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(QuestionnaireResponseValidatorTest.class);
private QuestionnaireResponseValidator myVal; private QuestionnaireResponseValidator myVal;
@ -42,6 +44,11 @@ public class QuestionnaireResponseValidatorTest {
myVal = new QuestionnaireResponseValidator(myWorkerCtx); myVal = new QuestionnaireResponseValidator(myWorkerCtx);
} }
@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
}
@Test @Test
public void testAnswerWithWrongType() { public void testAnswerWithWrongType() {
Questionnaire q = new Questionnaire(); Questionnaire q = new Questionnaire();