Enable subscriptions and upgrade to jetty 12

This commit is contained in:
James Agnew
2023-12-15 08:56:17 -05:00
parent 0133663fbc
commit b746573253
5 changed files with 41 additions and 67 deletions

View File

@@ -164,7 +164,6 @@ class ExampleServerDstu3IT implements IServerSupport {
}
@Test
@Disabled
void testWebsocketSubscription() throws Exception {
/*
* Create subscription

View File

@@ -217,7 +217,6 @@ class ExampleServerR4IT implements IServerSupport {
ourClient.transaction().withBundle(bundle).execute();
}
@Disabled
@Test
@Order(1)
void testWebsocketSubscription() throws Exception {

View File

@@ -1,9 +1,5 @@
package ca.uhn.fhir.jpa.starter;
import static ca.uhn.fhir.util.TestUtil.waitForSize;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.rest.api.CacheControlDirective;
import ca.uhn.fhir.rest.api.EncodingEnum;
@@ -11,10 +7,6 @@ import ca.uhn.fhir.rest.api.MethodOutcome;
import ca.uhn.fhir.rest.client.api.IGenericClient;
import ca.uhn.fhir.rest.client.api.ServerValidationModeEnum;
import ca.uhn.fhir.rest.client.interceptor.LoggingInterceptor;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import jakarta.websocket.ContainerProvider;
import jakarta.websocket.Session;
import jakarta.websocket.WebSocketContainer;
@@ -26,20 +18,25 @@ import org.hl7.fhir.r5.model.Patient;
import org.hl7.fhir.r5.model.Subscription;
import org.hl7.fhir.r5.model.SubscriptionTopic;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.net.URI;
import static ca.uhn.fhir.util.TestUtil.waitForSize;
import static org.awaitility.Awaitility.await;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(SpringExtension.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = {Application.class}, properties =
{
"spring.datasource.url=jdbc:h2:mem:dbr5",
"hapi.fhir.fhir_version=r5",
"hapi.fhir.cr_enabled=false",
// "hapi.fhir.subscription.websocket_enabled=true"
"hapi.fhir.subscription.websocket_enabled=true"
})
public class ExampleServerR5IT {
@@ -68,7 +65,6 @@ public class ExampleServerR5IT {
}
@Test
@Disabled
void testWebsocketSubscription() throws Exception {
String endpoint = "ws://localhost:" + port + "/websocket";
/*

View File

@@ -1,7 +1,7 @@
package ca.uhn.fhir.jpa.starter;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jetty.websocket.server.config.JettyWebSocketServletContainerInitializer;
import org.eclipse.jetty.ee10.webapp.WebAppContext;
import org.eclipse.jetty.ee10.websocket.jakarta.server.config.JakartaWebSocketServletContainerInitializer;
import org.springframework.boot.web.embedded.jetty.JettyServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.context.annotation.Bean;
@@ -15,18 +15,18 @@ import org.springframework.context.annotation.Configuration;
public class JpaStarterWebsocketDispatcherConfig {
@Bean
public Jetty10WebSocketServletWebServerCustomizer jetty10WebSocketServletWebServerCustomizer() {
return new Jetty10WebSocketServletWebServerCustomizer();
public Jetty12WebSocketServletWebServerCustomizer jetty10WebSocketServletWebServerCustomizer() {
return new Jetty12WebSocketServletWebServerCustomizer();
}
static class Jetty10WebSocketServletWebServerCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory> {
static class Jetty12WebSocketServletWebServerCustomizer implements WebServerFactoryCustomizer<JettyServletWebServerFactory> {
@Override
public void customize(JettyServletWebServerFactory factory) {
factory.addServerCustomizers(server -> {
WebAppContext ctx = (WebAppContext) server.getHandler();
JettyWebSocketServletContainerInitializer.configure(ctx, null);
JakartaWebSocketServletContainerInitializer.configure(ctx, null);
});
}