From 76650df4dcd0bf6944b9a80ddd1d0070ffc41422 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Tue, 10 Jan 2023 14:51:32 -0500 Subject: [PATCH 1/3] First commit to restore hapi-fhir 6.3.6-SNAPSHOT changes. Add static code blocks to Application.java as well as all tests to System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); --- pom.xml | 8 ++++---- src/main/java/ca/uhn/fhir/jpa/starter/Application.java | 4 ++++ .../fhir/jpa/starter/common/FhirServerConfigDstu2.java | 6 ------ .../uhn/fhir/jpa/starter/common/StarterJpaConfig.java | 10 ---------- .../java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java | 4 ++++ .../ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java | 4 ++++ .../uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java | 6 +++++- .../ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java | 4 ++++ .../ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java | 4 ++++ .../ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java | 6 ++++-- .../ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java | 5 +++++ .../ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java | 6 +++++- .../ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java | 3 +++ 13 files changed, 46 insertions(+), 24 deletions(-) diff --git a/pom.xml b/pom.xml index 700161b..d56db5c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,7 +14,7 @@ ca.uhn.hapi.fhir hapi-fhir - 6.2.2 + 6.3.6-SNAPSHOT hapi-fhir-jpaserver-starter @@ -44,12 +44,12 @@ org.eclipse.jetty.websocket - websocket-api + websocket-jetty-api ${jetty_version} org.eclipse.jetty.websocket - websocket-client + websocket-jetty-client ${jetty_version} @@ -246,7 +246,7 @@ org.eclipse.jetty.websocket - websocket-server + websocket-jetty-server test diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java index 8031c59..71ada0b 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java @@ -38,6 +38,10 @@ import org.springframework.web.servlet.DispatcherServlet; }) public class Application extends SpringBootServletInitializer { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + public static void main(String[] args) { SpringApplication.run(Application.class, args); diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.java index baf5044..9416d28 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/FhirServerConfigDstu2.java @@ -2,7 +2,6 @@ package ca.uhn.fhir.jpa.starter.common; import ca.uhn.fhir.jpa.config.JpaDstu2Config; import ca.uhn.fhir.jpa.starter.annotations.OnDSTU2Condition; -import ca.uhn.fhir.jpa.term.TermCodeSystemStorageSvcImpl; import ca.uhn.fhir.jpa.term.TermLoaderSvcImpl; import ca.uhn.fhir.jpa.term.api.ITermCodeSystemStorageSvc; import ca.uhn.fhir.jpa.term.api.ITermDeferredStorageSvc; @@ -24,9 +23,4 @@ public class FhirServerConfigDstu2 { return new TermLoaderSvcImpl(theDeferredStorageSvc, theCodeSystemStorageSvc); } - @Bean - public ITermCodeSystemStorageSvc termCodeSystemStorageSvc() { - return new TermCodeSystemStorageSvcImpl(); - } - } diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java index 74ac24c..3fac5b7 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/common/StarterJpaConfig.java @@ -206,16 +206,6 @@ public class StarterJpaConfig { return packageInstallerSvc; } - @Bean - @Primary - /* - This bean is currently necessary to override from MDM settings - */ - IMdmLinkDao mdmLinkDao() { - return new MdmLinkDaoJpaImpl(); - } - - @Bean @Conditional(OnCorsPresent.class) public CorsInterceptor corsInterceptor(AppProperties appProperties) { diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java index af9db0d..842798c 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java @@ -13,6 +13,10 @@ import org.springframework.boot.test.context.SpringBootTest; }) public class CustomBeanTest { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + @Autowired some.custom.pkg1.CustomBean customBean1; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java index 377719e..9939210 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java @@ -23,6 +23,10 @@ import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; public class CustomInterceptorTest { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + @LocalServerPort private int port; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java index 3a84047..0aea7f8 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java @@ -57,8 +57,12 @@ import org.testcontainers.elasticsearch.ElasticsearchContainer; }) @ContextConfiguration(initializers = ElasticsearchLastNR4IT.Initializer.class) public class ElasticsearchLastNR4IT { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } - private IGenericClient ourClient; + + private IGenericClient ourClient; private FhirContext ourCtx; private static final String ELASTIC_VERSION = "7.16.3"; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java index e20aff8..1c5a565 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java @@ -23,6 +23,10 @@ import static org.junit.jupiter.api.Assertions.assertEquals; }) public class ExampleServerDstu2IT { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index 826f311..d7745bd 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -51,6 +51,10 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class ExampleServerDstu3IT implements IServerSupport { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java index 0092722..2157c28 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java @@ -20,13 +20,15 @@ import static org.junit.jupiter.api.Assertions.assertEquals; "hapi.fhir.fhir_version=r4b", "hapi.fhir.subscription.websocket_enabled=false", "hapi.fhir.mdm_enabled=false", - "hapi.fhir.implementationguides.dk-core.name=hl7.fhir.dk.core", - "hapi.fhir.implementationguides.dk-core.version=1.1.0", // Override is currently required when using MDM as the construction of the MDM // beans are ambiguous as they are constructed multiple places. This is evident // when running in a spring boot environment "spring.main.allow-bean-definition-overriding=true"}) class ExampleServerR4BIT { + + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4BIT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index 278a5f0..44808ad 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -43,6 +43,11 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; // when running in a spring boot environment "spring.main.allow-bean-definition-overriding=true" }) class ExampleServerR4IT { + + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java index ddbd6a7..f8e807e 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java @@ -41,7 +41,11 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; }) public class ExampleServerR5IT { - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } + + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java index 9d340b1..a5c2da5 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java @@ -28,6 +28,9 @@ import static org.junit.jupiter.api.Assertions.assertEquals; }) public class MultitenantServerR4IT { + static { + System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); + } private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; From 38ed00a84b1b7ff70771b5367e85ca41f7301251 Mon Sep 17 00:00:00 2001 From: Luke deGruchy Date: Tue, 10 Jan 2023 16:53:57 -0500 Subject: [PATCH 2/3] Implement a new solution: Instead of static code blocks disabling logging, rollback slf4j-api, logback-classic, and logback-core to older versions. It's the addition of the rollback for slf4j-api that seems to restore logging. --- pom.xml | 19 +++++++++++++++++++ .../ca/uhn/fhir/jpa/starter/Application.java | 4 ---- .../uhn/fhir/jpa/starter/CustomBeanTest.java | 4 ---- .../jpa/starter/CustomInterceptorTest.java | 4 ---- .../jpa/starter/ElasticsearchLastNR4IT.java | 4 ---- .../jpa/starter/ExampleServerDstu2IT.java | 4 ---- .../jpa/starter/ExampleServerDstu3IT.java | 4 ---- .../fhir/jpa/starter/ExampleServerR4BIT.java | 4 ---- .../fhir/jpa/starter/ExampleServerR4IT.java | 5 ----- .../fhir/jpa/starter/ExampleServerR5IT.java | 6 +----- .../jpa/starter/MultitenantServerR4IT.java | 3 --- 11 files changed, 20 insertions(+), 41 deletions(-) diff --git a/pom.xml b/pom.xml index d56db5c..bfa4419 100644 --- a/pom.xml +++ b/pom.xml @@ -22,6 +22,8 @@ 11 + 1.2.11 + 1.7.25 @@ -357,6 +359,23 @@ test + + org.slf4j + slf4j-api + ${slf4j-api.version} + + + + ch.qos.logback + logback-classic + ${logback-classic.version} + + + ch.qos.logback + logback-core + ${logback-classic.version} + + diff --git a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java index 71ada0b..8031c59 100644 --- a/src/main/java/ca/uhn/fhir/jpa/starter/Application.java +++ b/src/main/java/ca/uhn/fhir/jpa/starter/Application.java @@ -38,10 +38,6 @@ import org.springframework.web.servlet.DispatcherServlet; }) public class Application extends SpringBootServletInitializer { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - public static void main(String[] args) { SpringApplication.run(Application.class, args); diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java index 842798c..af9db0d 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java @@ -13,10 +13,6 @@ import org.springframework.boot.test.context.SpringBootTest; }) public class CustomBeanTest { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - @Autowired some.custom.pkg1.CustomBean customBean1; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java index 9939210..377719e 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java @@ -23,10 +23,6 @@ import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; public class CustomInterceptorTest { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - @LocalServerPort private int port; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java index 0aea7f8..064c240 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java @@ -57,10 +57,6 @@ import org.testcontainers.elasticsearch.ElasticsearchContainer; }) @ContextConfiguration(initializers = ElasticsearchLastNR4IT.Initializer.class) public class ElasticsearchLastNR4IT { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java index 1c5a565..e20aff8 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java @@ -23,10 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; }) public class ExampleServerDstu2IT { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index d7745bd..826f311 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -51,10 +51,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public class ExampleServerDstu3IT implements IServerSupport { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java index 2157c28..fc7bf58 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java @@ -25,10 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; // when running in a spring boot environment "spring.main.allow-bean-definition-overriding=true"}) class ExampleServerR4BIT { - - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4BIT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index 44808ad..278a5f0 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -43,11 +43,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull; // when running in a spring boot environment "spring.main.allow-bean-definition-overriding=true" }) class ExampleServerR4IT { - - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerR4IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java index f8e807e..ddbd6a7 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java @@ -41,11 +41,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; }) public class ExampleServerR5IT { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } - - private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); + private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; private FhirContext ourCtx; diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java index a5c2da5..9d340b1 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java @@ -28,9 +28,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals; }) public class MultitenantServerR4IT { - static { - System.setProperty("org.springframework.boot.logging.LoggingSystem", "none"); - } private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ExampleServerDstu2IT.class); private IGenericClient ourClient; From ea3d858563e97b5e6cd617ecd1c4e0ece6e08dcc Mon Sep 17 00:00:00 2001 From: James Agnew Date: Wed, 11 Jan 2023 16:30:12 -0500 Subject: [PATCH 3/3] Fix tests for websocket --- .../uhn/fhir/jpa/starter/CustomBeanTest.java | 2 +- .../jpa/starter/CustomInterceptorTest.java | 2 +- .../jpa/starter/ElasticsearchLastNR4IT.java | 2 +- .../jpa/starter/ExampleServerDstu2IT.java | 2 +- .../jpa/starter/ExampleServerDstu3IT.java | 2 +- .../fhir/jpa/starter/ExampleServerR4BIT.java | 2 +- .../fhir/jpa/starter/ExampleServerR4IT.java | 2 +- .../fhir/jpa/starter/ExampleServerR5IT.java | 2 +- .../JpaStarterWebsocketDispatcherConfig.java | 34 +++++++++++++++++++ .../jpa/starter/MultitenantServerR4IT.java | 2 +- 10 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 src/test/java/ca/uhn/fhir/jpa/starter/JpaStarterWebsocketDispatcherConfig.java diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java index af9db0d..07e7f58 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomBeanTest.java @@ -5,7 +5,7 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = { +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "hapi.fhir.custom-bean-packages=some.custom.pkg1,some.custom.pkg2", "spring.datasource.url=jdbc:h2:mem:dbr4", // "hapi.fhir.enable_repository_validating_interceptor=true", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java index 377719e..367857b 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/CustomInterceptorTest.java @@ -13,7 +13,7 @@ import ca.uhn.fhir.jpa.api.dao.IFhirResourceDao; import ca.uhn.fhir.rest.client.api.IGenericClient; import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = { +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "hapi.fhir.custom-bean-packages=some.custom.pkg1", "hapi.fhir.custom-interceptor-classes=some.custom.pkg1.CustomInterceptorBean,some.custom.pkg1.CustomInterceptorPojo", "spring.datasource.url=jdbc:h2:mem:dbr4", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java index 064c240..5cb0a4e 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ElasticsearchLastNR4IT.java @@ -36,7 +36,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import org.testcontainers.elasticsearch.ElasticsearchContainer; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr4", "hapi.fhir.fhir_version=r4", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java index e20aff8..4369086 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu2IT.java @@ -16,7 +16,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "hapi.fhir.fhir_version=dstu2", "spring.datasource.url=jdbc:h2:mem:dbr2", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java index 826f311..fb90784 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerDstu3IT.java @@ -38,7 +38,7 @@ import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr3", "hapi.fhir.cql_enabled=true", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java index fc7bf58..9f19fcb 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4BIT.java @@ -14,7 +14,7 @@ import org.springframework.boot.web.server.LocalServerPort; import static org.junit.jupiter.api.Assertions.assertEquals; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = { +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr4b", "hapi.fhir.enable_repository_validating_interceptor=true", "hapi.fhir.fhir_version=r4b", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java index 278a5f0..319ed1c 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR4IT.java @@ -30,7 +30,7 @@ import static org.awaitility.Awaitility.await; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = { +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr4", "hapi.fhir.enable_repository_validating_interceptor=true", "hapi.fhir.fhir_version=r4", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java index ddbd6a7..87e0121 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/ExampleServerR5IT.java @@ -32,7 +32,7 @@ import org.springframework.boot.web.server.LocalServerPort; import org.springframework.test.context.junit.jupiter.SpringExtension; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr5", "hapi.fhir.fhir_version=r5", diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/JpaStarterWebsocketDispatcherConfig.java b/src/test/java/ca/uhn/fhir/jpa/starter/JpaStarterWebsocketDispatcherConfig.java new file mode 100644 index 0000000..3503338 --- /dev/null +++ b/src/test/java/ca/uhn/fhir/jpa/starter/JpaStarterWebsocketDispatcherConfig.java @@ -0,0 +1,34 @@ +package ca.uhn.fhir.jpa.starter; + +import org.eclipse.jetty.webapp.WebAppContext; +import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer; +import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory; +import org.springframework.boot.web.server.WebServerFactoryCustomizer; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +/** + * This class ensures that websockets work with + * Spring + Spring Boot + Jetty + */ +@Configuration +public class JpaStarterWebsocketDispatcherConfig { + + @Bean + public Jetty10WebSocketServletWebServerCustomizer jetty10WebSocketServletWebServerCustomizer() { + return new Jetty10WebSocketServletWebServerCustomizer(); + } + + static class Jetty10WebSocketServletWebServerCustomizer implements WebServerFactoryCustomizer { + + @Override + public void customize(JettyServletWebServerFactory factory) { + + factory.addServerCustomizers(server -> { + WebAppContext ctx = (WebAppContext) server.getHandler(); + JettyWebSocketServletContainerInitializer.configure(ctx, null); + }); + + } + } +} diff --git a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java index 9d340b1..463a1c6 100644 --- a/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java +++ b/src/test/java/ca/uhn/fhir/jpa/starter/MultitenantServerR4IT.java @@ -18,7 +18,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import static org.junit.jupiter.api.Assertions.assertEquals; @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = Application.class, properties = +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class, JpaStarterWebsocketDispatcherConfig.class}, properties = { "spring.datasource.url=jdbc:h2:mem:dbr4-mt", "hapi.fhir.fhir_version=r4",