Add support for websockets
This commit is contained in:
@@ -35,7 +35,7 @@ public class FhirServerConfigDstu2 extends BaseJavaConfigDstu2 {
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
retVal.setPersistenceUnitName("HAPI_PU");
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FhirServerConfigDstu3 extends BaseJavaConfigDstu3 {
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
retVal.setPersistenceUnitName("HAPI_PU");
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class FhirServerConfigR4 extends BaseJavaConfigR4 {
|
||||
@Bean()
|
||||
public LocalContainerEntityManagerFactoryBean entityManagerFactory() {
|
||||
LocalContainerEntityManagerFactoryBean retVal = super.entityManagerFactory();
|
||||
retVal.setPersistenceUnitName(HapiProperties.getPersistenceUnitName());
|
||||
retVal.setPersistenceUnitName("HAPI_PU");
|
||||
|
||||
try {
|
||||
retVal.setDataSource(myDataSource);
|
||||
|
||||
@@ -32,9 +32,7 @@ public class HapiProperties {
|
||||
static final String LOGGER_NAME = "logger.name";
|
||||
static final String MAX_FETCH_SIZE = "max_fetch_size";
|
||||
static final String MAX_PAGE_SIZE = "max_page_size";
|
||||
static final String PERSISTENCE_UNIT_NAME = "persistence_unit_name";
|
||||
static final String SERVER_ADDRESS = "server_address";
|
||||
static final String SERVER_BASE = "server.base";
|
||||
static final String SERVER_ID = "server.id";
|
||||
static final String SERVER_NAME = "server.name";
|
||||
static final String SUBSCRIPTION_EMAIL_ENABLED = "subscription.email.enabled";
|
||||
@@ -201,10 +199,6 @@ public class HapiProperties {
|
||||
return HapiProperties.getIntegerProperty(MAX_FETCH_SIZE, Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
public static String getPersistenceUnitName() {
|
||||
return HapiProperties.getProperty(PERSISTENCE_UNIT_NAME, "HAPI_PU");
|
||||
}
|
||||
|
||||
public static String getLoggerName() {
|
||||
return HapiProperties.getProperty(LOGGER_NAME, "fhirtest.access");
|
||||
}
|
||||
@@ -269,10 +263,6 @@ public class HapiProperties {
|
||||
return HapiProperties.getProperty(CORS_ALLOWED_ORIGIN, "*");
|
||||
}
|
||||
|
||||
public static String getServerBase() {
|
||||
return HapiProperties.getProperty(SERVER_BASE, "/fhir");
|
||||
}
|
||||
|
||||
public static String getServerName() {
|
||||
return HapiProperties.getProperty(SERVER_NAME, "Local Tester");
|
||||
}
|
||||
|
||||
@@ -6,11 +6,12 @@ fhir_version=DSTU3
|
||||
# This is the address that the FHIR server will report as its own address.
|
||||
# If this server will be deployed (for example) to an internet accessible
|
||||
# server, put the DNS name of that server here.
|
||||
server_address=http://localhost:8080/fhir/
|
||||
|
||||
# This is the context path for the FHIR endpoint. If this is changed, the
|
||||
# setting above should also be changed.
|
||||
server.base=/fhir
|
||||
#
|
||||
# Note that this is also the address that the hapi-fhir-testpage-overlay
|
||||
# (the web UI similar to the one at http://hapi.fhir.org) will use to
|
||||
# connect internally to the FHIR server, so this also needs to be a name
|
||||
# accessible from the server itself.
|
||||
server_address=http://localhost:8080/hapi-fhir-jpaserver/fhir/
|
||||
|
||||
default_encoding=JSON
|
||||
etag_support=ENABLED
|
||||
|
||||
@@ -13,8 +13,6 @@ import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
@@ -33,14 +31,13 @@ public class ExampleServerDstu2IT {
|
||||
HapiProperties.forceReload();
|
||||
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "DSTU2");
|
||||
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:derby:memory:dbr2;create=true");
|
||||
HapiProperties.setProperty(HapiProperties.TEST_PORT, Integer.toString(PortUtil.findFreePort()));
|
||||
ourCtx = FhirContext.forDstu2();
|
||||
ourPort = HapiProperties.getTestPort();
|
||||
ourPort = PortUtil.findFreePort();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndRead() throws IOException {
|
||||
ourLog.info("Base URL is: http://localhost:" + ourPort + HapiProperties.getServerBase());
|
||||
public void testCreateAndRead() {
|
||||
ourLog.info("Base URL is: " + HapiProperties.getServerAddress());
|
||||
String methodName = "testCreateResourceConditional";
|
||||
|
||||
Patient pt = new Patient();
|
||||
@@ -62,13 +59,10 @@ public class ExampleServerDstu2IT {
|
||||
|
||||
ourLog.info("Project base path is: {}", path);
|
||||
|
||||
if (ourPort == 0) {
|
||||
ourPort = RandomServerPortProvider.findFreePort();
|
||||
}
|
||||
ourServer = new Server(ourPort);
|
||||
|
||||
WebAppContext webAppContext = new WebAppContext();
|
||||
webAppContext.setContextPath("/");
|
||||
webAppContext.setContextPath("/hapi-fhir-jpaserver");
|
||||
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
|
||||
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
|
||||
webAppContext.setParentLoaderPriority(true);
|
||||
@@ -78,7 +72,7 @@ public class ExampleServerDstu2IT {
|
||||
|
||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
||||
ourServerBase = "http://localhost:" + ourPort + HapiProperties.getServerBase();
|
||||
ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||
}
|
||||
|
||||
@@ -44,15 +44,14 @@ public class ExampleServerDstu3IT {
|
||||
HapiProperties.forceReload();
|
||||
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "DSTU3");
|
||||
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:derby:memory:dbr3;create=true");
|
||||
HapiProperties.setProperty(HapiProperties.TEST_PORT, Integer.toString(PortUtil.findFreePort()));
|
||||
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
||||
ourCtx = FhirContext.forDstu3();
|
||||
ourPort = HapiProperties.getTestPort();
|
||||
ourPort = PortUtil.findFreePort();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndRead() throws IOException {
|
||||
ourLog.info("Base URL is: http://localhost:" + ourPort + HapiProperties.getServerBase());
|
||||
public void testCreateAndRead() {
|
||||
ourLog.info("Base URL is: " + HapiProperties.getServerAddress());
|
||||
String methodName = "testCreateResourceConditional";
|
||||
|
||||
Patient pt = new Patient();
|
||||
@@ -92,7 +91,7 @@ public class ExampleServerDstu3IT {
|
||||
SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
|
||||
|
||||
myWebSocketClient.start();
|
||||
URI echoUri = new URI("ws://localhost:" + ourPort + "/websocket");
|
||||
URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
|
||||
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
||||
ourLog.info("Connecting to : {}", echoUri);
|
||||
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
|
||||
@@ -138,7 +137,7 @@ public class ExampleServerDstu3IT {
|
||||
ourServer = new Server(ourPort);
|
||||
|
||||
WebAppContext webAppContext = new WebAppContext();
|
||||
webAppContext.setContextPath("/");
|
||||
webAppContext.setContextPath("/hapi-fhir-jpaserver");
|
||||
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
|
||||
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
|
||||
webAppContext.setParentLoaderPriority(true);
|
||||
@@ -148,7 +147,7 @@ public class ExampleServerDstu3IT {
|
||||
|
||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
||||
ourServerBase = "http://localhost:" + ourPort + HapiProperties.getServerBase();
|
||||
ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||
}
|
||||
|
||||
@@ -45,15 +45,14 @@ public class ExampleServerR4IT {
|
||||
HapiProperties.forceReload();
|
||||
HapiProperties.setProperty(HapiProperties.DATASOURCE_URL, "jdbc:derby:memory:dbr4;create=true");
|
||||
HapiProperties.setProperty(HapiProperties.FHIR_VERSION, "R4");
|
||||
HapiProperties.setProperty(HapiProperties.TEST_PORT, Integer.toString(PortUtil.findFreePort()));
|
||||
HapiProperties.setProperty(HapiProperties.SUBSCRIPTION_WEBSOCKET_ENABLED, "true");
|
||||
ourCtx = FhirContext.forR4();
|
||||
ourPort = HapiProperties.getTestPort();
|
||||
ourPort = PortUtil.findFreePort();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateAndRead() throws IOException {
|
||||
ourLog.info("Base URL is: http://localhost:" + ourPort + HapiProperties.getServerBase());
|
||||
public void testCreateAndRead() {
|
||||
ourLog.info("Base URL is: " + HapiProperties.getServerAddress());
|
||||
String methodName = "testCreateResourceConditional";
|
||||
|
||||
Patient pt = new Patient();
|
||||
@@ -93,7 +92,7 @@ public class ExampleServerR4IT {
|
||||
SocketImplementation mySocketImplementation = new SocketImplementation(mySubscriptionId.getIdPart(), EncodingEnum.JSON);
|
||||
|
||||
myWebSocketClient.start();
|
||||
URI echoUri = new URI("ws://localhost:" + ourPort + "/websocket");
|
||||
URI echoUri = new URI("ws://localhost:" + ourPort + "/hapi-fhir-jpaserver/websocket");
|
||||
ClientUpgradeRequest request = new ClientUpgradeRequest();
|
||||
ourLog.info("Connecting to : {}", echoUri);
|
||||
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
|
||||
@@ -139,7 +138,7 @@ public class ExampleServerR4IT {
|
||||
ourServer = new Server(ourPort);
|
||||
|
||||
WebAppContext webAppContext = new WebAppContext();
|
||||
webAppContext.setContextPath("/");
|
||||
webAppContext.setContextPath("/hapi-fhir-jpaserver");
|
||||
webAppContext.setDisplayName("HAPI FHIR");
|
||||
webAppContext.setDescriptor(path + "/src/main/webapp/WEB-INF/web.xml");
|
||||
webAppContext.setResourceBase(path + "/target/hapi-fhir-jpaserver-starter");
|
||||
@@ -150,8 +149,8 @@ public class ExampleServerR4IT {
|
||||
|
||||
ourCtx.getRestfulClientFactory().setServerValidationMode(ServerValidationModeEnum.NEVER);
|
||||
ourCtx.getRestfulClientFactory().setSocketTimeout(1200 * 1000);
|
||||
ourServerBase = "http://localhost:" + ourPort + HapiProperties.getServerBase();
|
||||
ourClient = ourCtx.newRestfulGenericClient(ourServerBase);
|
||||
ourServerBase = HapiProperties.getServerAddress();
|
||||
ourServerBase = "http://localhost:" + ourPort + "/hapi-fhir-jpaserver/fhir/";
|
||||
ourClient.registerInterceptor(new LoggingInterceptor(true));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user