Deprecate subscription settings in DaoConfig that are no longer used

This commit is contained in:
James Agnew 2017-09-15 05:57:42 -05:00
parent e94d639d29
commit 1ac45e27c6
8 changed files with 221 additions and 262 deletions

View File

@ -30,6 +30,15 @@ import java.util.*;
public class DaoConfig {
/**
* Constructor
*/
public DaoConfig() {
setSubscriptionEnabled(true);
setSubscriptionPollDelay(0);
setSubscriptionPurgeInactiveAfterMillis(Long.MAX_VALUE);
}
/**
* Default {@link #getTreatReferencesAsLogical() logical URL bases}. Includes the following
* values:
@ -76,68 +85,13 @@ public class DaoConfig {
private boolean myEnforceReferentialIntegrityOnDelete = true;
private boolean myUniqueIndexesEnabled = true;
/**
* If set to <code>true</code> (default is <code>true</code>), indexes will be
* created for search parameters marked as {@link ca.uhn.fhir.jpa.util.JpaConstants#EXT_SP_UNIQUE}.
* This is a HAPI FHIR specific extension which can be used to specify that no more than one
* resource can exist which matches a given criteria, using a database constraint to
* enforce this.
*/
public boolean isUniqueIndexesEnabled() {
return myUniqueIndexesEnabled;
}
/**
* If set to <code>true</code> (default is <code>true</code>), indexes will be
* created for search parameters marked as {@link ca.uhn.fhir.jpa.util.JpaConstants#EXT_SP_UNIQUE}.
* This is a HAPI FHIR specific extension which can be used to specify that no more than one
* resource can exist which matches a given criteria, using a database constraint to
* enforce this.
*/
public void setUniqueIndexesEnabled(boolean theUniqueIndexesEnabled) {
myUniqueIndexesEnabled = theUniqueIndexesEnabled;
}
/**
* When using {@link #setUniqueIndexesEnabled(boolean) unique indexes}, if this
* setting is set to <code>true</code> (default is <code>true</code>) the system
* will test for the existence of a particular unique index value prior to saving
* a new one.
* <p>
* This causes friendlier error messages to be generated, but adds an
* extra round-trip to the database for eavh save so it can cause
* a small performance hit.
* </p>
*/
public boolean isUniqueIndexesCheckedBeforeSave() {
return myUniqueIndexesCheckedBeforeSave;
}
/**
* When using {@link #setUniqueIndexesEnabled(boolean) unique indexes}, if this
* setting is set to <code>true</code> (default is <code>true</code>) the system
* will test for the existence of a particular unique index value prior to saving
* a new one.
* <p>
* This causes friendlier error messages to be generated, but adds an
* extra round-trip to the database for eavh save so it can cause
* a small performance hit.
* </p>
*/
public void setUniqueIndexesCheckedBeforeSave(boolean theUniqueIndexesCheckedBeforeSave) {
myUniqueIndexesCheckedBeforeSave = theUniqueIndexesCheckedBeforeSave;
}
private boolean myUniqueIndexesCheckedBeforeSave = true;
private boolean myEnforceReferentialIntegrityOnWrite = true;
private int myEverythingIncludesFetchPageSize = 50;
/**
* update setter javadoc if default changes
*/
private long myExpireSearchResultsAfterMillis = DateUtils.MILLIS_PER_HOUR;
/**
* update setter javadoc if default changes
*/
@ -148,9 +102,7 @@ public class DaoConfig {
* update setter javadoc if default changes
*/
private boolean myIndexContainedResources = true;
private List<IServerInterceptor> myInterceptors;
/**
* update setter javadoc if default changes
*/
@ -163,12 +115,6 @@ public class DaoConfig {
private Integer myResourceMetaCountHardLimit = 1000;
private Long myReuseCachedSearchResultsForMillis = DEFAULT_REUSE_CACHED_SEARCH_RESULTS_FOR_MILLIS;
private boolean mySchedulingDisabled;
private boolean mySubscriptionEnabled;
/**
* update setter javadoc if default changes
*/
private long mySubscriptionPollDelay = 1000;
private Long mySubscriptionPurgeInactiveAfterMillis;
private boolean mySuppressUpdatesWithNoChange = true;
private Set<String> myTreatBaseUrlsAsLocal = new HashSet<String>();
private Set<String> myTreatReferencesAsLogical = new HashSet<String>(DEFAULT_LOGICAL_BASE_URLS);
@ -356,11 +302,8 @@ public class DaoConfig {
/**
* This may be used to optionally register server interceptors directly against the DAOs.
*/
public void setInterceptors(IServerInterceptor... theInterceptor) {
setInterceptors(new ArrayList<IServerInterceptor>());
if (theInterceptor != null && theInterceptor.length != 0) {
getInterceptors().addAll(Arrays.asList(theInterceptor));
}
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
myInterceptors = theInterceptors;
}
/**
@ -477,23 +420,22 @@ public class DaoConfig {
myReuseCachedSearchResultsForMillis = theReuseCachedSearchResultsForMillis;
}
public long getSubscriptionPollDelay() {
return mySubscriptionPollDelay;
}
/**
* @deprecated As of HAPI FHIR 3.0.0, subscriptions no longer use polling for
* detecting changes, so this setting has no effect
*/
@Deprecated
public void setSubscriptionPollDelay(long theSubscriptionPollDelay) {
mySubscriptionPollDelay = theSubscriptionPollDelay;
}
public Long getSubscriptionPurgeInactiveAfterMillis() {
return mySubscriptionPurgeInactiveAfterMillis;
// ignore
}
/**
* @deprecated As of HAPI FHIR 3.0.0, subscriptions no longer use polling for
* detecting changes, so this setting has no effect
*/
@Deprecated
public void setSubscriptionPurgeInactiveAfterMillis(Long theMillis) {
if (theMillis != null) {
Validate.exclusiveBetween(0, Long.MAX_VALUE, theMillis);
}
mySubscriptionPurgeInactiveAfterMillis = theMillis;
// ignore
}
/**
@ -872,20 +814,14 @@ public class DaoConfig {
mySchedulingDisabled = theSchedulingDisabled;
}
/**
* See {@link #setSubscriptionEnabled(boolean)}
*/
public boolean isSubscriptionEnabled() {
return mySubscriptionEnabled;
}
/**
* If set to true, the server will enable support for subscriptions. Subscriptions
* will by default be handled via a polling task. Note that if this is enabled, you must also include Spring task scanning to your XML
* config for the scheduled tasks used by the subscription module.
* @deprecated As of HAPI FHIR 3.0.0, subscriptions no longer use polling for
* detecting changes, so this setting has no effect
*/
@Deprecated
public void setSubscriptionEnabled(boolean theSubscriptionEnabled) {
mySubscriptionEnabled = theSubscriptionEnabled;
// nothing
}
/**
@ -915,6 +851,58 @@ public class DaoConfig {
}
/**
* When using {@link #setUniqueIndexesEnabled(boolean) unique indexes}, if this
* setting is set to <code>true</code> (default is <code>true</code>) the system
* will test for the existence of a particular unique index value prior to saving
* a new one.
* <p>
* This causes friendlier error messages to be generated, but adds an
* extra round-trip to the database for eavh save so it can cause
* a small performance hit.
* </p>
*/
public boolean isUniqueIndexesCheckedBeforeSave() {
return myUniqueIndexesCheckedBeforeSave;
}
/**
* When using {@link #setUniqueIndexesEnabled(boolean) unique indexes}, if this
* setting is set to <code>true</code> (default is <code>true</code>) the system
* will test for the existence of a particular unique index value prior to saving
* a new one.
* <p>
* This causes friendlier error messages to be generated, but adds an
* extra round-trip to the database for eavh save so it can cause
* a small performance hit.
* </p>
*/
public void setUniqueIndexesCheckedBeforeSave(boolean theUniqueIndexesCheckedBeforeSave) {
myUniqueIndexesCheckedBeforeSave = theUniqueIndexesCheckedBeforeSave;
}
/**
* If set to <code>true</code> (default is <code>true</code>), indexes will be
* created for search parameters marked as {@link ca.uhn.fhir.jpa.util.JpaConstants#EXT_SP_UNIQUE}.
* This is a HAPI FHIR specific extension which can be used to specify that no more than one
* resource can exist which matches a given criteria, using a database constraint to
* enforce this.
*/
public boolean isUniqueIndexesEnabled() {
return myUniqueIndexesEnabled;
}
/**
* If set to <code>true</code> (default is <code>true</code>), indexes will be
* created for search parameters marked as {@link ca.uhn.fhir.jpa.util.JpaConstants#EXT_SP_UNIQUE}.
* This is a HAPI FHIR specific extension which can be used to specify that no more than one
* resource can exist which matches a given criteria, using a database constraint to
* enforce this.
*/
public void setUniqueIndexesEnabled(boolean theUniqueIndexesEnabled) {
myUniqueIndexesEnabled = theUniqueIndexesEnabled;
}
/**
* Do not call this method, it exists only for legacy reasons. It
* will be removed in a future version. Configure the page size on your
@ -931,8 +919,11 @@ public class DaoConfig {
/**
* This may be used to optionally register server interceptors directly against the DAOs.
*/
public void setInterceptors(List<IServerInterceptor> theInterceptors) {
myInterceptors = theInterceptors;
public void setInterceptors(IServerInterceptor... theInterceptor) {
setInterceptors(new ArrayList<IServerInterceptor>());
if (theInterceptor != null && theInterceptor.length != 0) {
getInterceptors().addAll(Arrays.asList(theInterceptor));
}
}
public void setSubscriptionPurgeInactiveAfterSeconds(int theSeconds) {

View File

@ -1,13 +1,18 @@
package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.resource.Subscription;
import ca.uhn.fhir.model.dstu2.resource.Subscription.Channel;
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -17,14 +22,12 @@ import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
import ca.uhn.fhir.model.dstu2.composite.*;
import ca.uhn.fhir.model.dstu2.resource.*;
import ca.uhn.fhir.model.dstu2.resource.Subscription.Channel;
import ca.uhn.fhir.model.dstu2.valueset.*;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
// This is currently disabled as the criteria mechanism was a non-standard experiment
@Ignore
@ -39,17 +42,12 @@ public class WebsocketWithCriteriaDstu2Test extends BaseResourceProviderDstu2Tes
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
}
@Before
public void before() throws Exception {
super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
/*
* Create patient
*/

View File

@ -1,24 +1,24 @@
package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.dstu3.model.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.dstu3.model.*;
import org.junit.*;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
// This is currently disabled as the criteria mechanism was a non-standard experiment
@Ignore
@ -34,17 +34,12 @@ public class WebsocketWithCriteriaDstu3Test extends BaseResourceProviderDstu3Tes
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
}
@Before
public void before() throws Exception {
super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
/*
* Create patient
*/

View File

@ -1,14 +1,19 @@
package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import ca.uhn.fhir.model.dstu2.composite.CodeableConceptDt;
import ca.uhn.fhir.model.dstu2.composite.CodingDt;
import ca.uhn.fhir.model.dstu2.composite.ResourceReferenceDt;
import ca.uhn.fhir.model.dstu2.resource.Observation;
import ca.uhn.fhir.model.dstu2.resource.Patient;
import ca.uhn.fhir.model.dstu2.resource.Subscription;
import ca.uhn.fhir.model.dstu2.resource.Subscription.Channel;
import ca.uhn.fhir.model.dstu2.valueset.ObservationStatusEnum;
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionChannelTypeEnum;
import ca.uhn.fhir.model.dstu2.valueset.SubscriptionStatusEnum;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -17,14 +22,12 @@ import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
import ca.uhn.fhir.model.dstu2.composite.*;
import ca.uhn.fhir.model.dstu2.resource.*;
import ca.uhn.fhir.model.dstu2.resource.Subscription.Channel;
import ca.uhn.fhir.model.dstu2.valueset.*;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
/**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -52,32 +55,32 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor);
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Before
public void before() throws Exception {
super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor);
/*
* Create patient
*/
Patient patient = FhirDstu2Util.getPatient();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
/*
* Create subscription
*/
Subscription subscription = new Subscription();
@ -93,7 +96,7 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
/*
* Attach websocket
*/
@ -107,16 +110,10 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
ourLog.info("Connecting to : {}", echoUri);
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
Session session = connection.get(2, TimeUnit.SECONDS);
ourLog.info("Connected to WS: {}", session.isOpen());
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test
public void createObservation() throws Exception {
Observation observation = new Observation();
@ -159,7 +156,7 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
observation.setId(observationId);
ourLog.info("Observation id generated by server is: " + observationId);
ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
waitForSize(2, mySocketImplementation.getMessages());
assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId));

View File

@ -1,25 +1,24 @@
package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.dstu3.model.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.dstu3.model.*;
import org.junit.*;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
/**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -50,33 +49,33 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor);
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Before
public void before() throws Exception {
super.before();
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor);
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
/*
* Create patient
*/
Patient patient = FhirDstu3Util.getPatient();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
/*
* Create subscription
*/
Subscription subscription = new Subscription();
@ -92,7 +91,7 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
/*
* Attach websocket
*/
@ -106,16 +105,10 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
ourLog.info("Connecting to : {}", echoUri);
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
Session session = connection.get(5, TimeUnit.SECONDS);
ourLog.info("Connected to WS: {}", session.isOpen());
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test
public void createObservation() throws Exception {
Observation observation = new Observation();
@ -134,7 +127,7 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
observation.setId(observationId);
ourLog.info("Observation id generated by server is: " + observationId);
ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
waitForSize(2, mySocketImplementation.getMessages());
assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId, "ping " + mySubscriptionId));
@ -158,7 +151,7 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
observation.setId(observationId);
ourLog.info("Observation id generated by server is: " + observationId);
ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
waitForSize(2, mySocketImplementation.getMessages());
assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId));

View File

@ -15,8 +15,6 @@ import org.slf4j.Logger;
import java.util.ArrayList;
import java.util.List;
import static org.hamcrest.Matchers.contains;
/**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
* subscription
@ -49,7 +47,6 @@ public class RestHookWithEventDefinitionR4Test extends BaseResourceProviderR4Tes
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
}
@After

View File

@ -1,25 +1,25 @@
package ca.uhn.fhir.jpa.subscription.r4;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import ca.uhn.fhir.jpa.subscription.SocketImplementation;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.r4.model.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.r4.model.*;
import org.junit.*;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import ca.uhn.fhir.jpa.subscription.SocketImplementation;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
// This is currently disabled as the criteria mechanism was a non-standard experiment
@ -37,8 +37,6 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
}
@Override
@ -46,9 +44,6 @@ public class WebsocketWithCriteriaR4Test extends BaseResourceProviderR4Test {
public void before() throws Exception {
super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
/*
* Create patient
*/

View File

@ -1,26 +1,25 @@
package ca.uhn.fhir.jpa.subscription.r4;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertThat;
import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import ca.uhn.fhir.jpa.subscription.SocketImplementation;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.r4.model.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
import java.net.URI;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import org.eclipse.jetty.websocket.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient;
import org.hl7.fhir.r4.model.*;
import org.junit.*;
import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig;
import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import ca.uhn.fhir.jpa.subscription.SocketImplementation;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
import static org.hamcrest.Matchers.contains;
import static org.junit.Assert.*;
/**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -51,19 +50,19 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
@After
public void after() throws Exception {
super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor);
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Before
public void before() throws Exception {
super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor);
@ -71,12 +70,12 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
/*
* Create patient
*/
Patient patient = FhirR4Util.getPatient();
MethodOutcome methodOutcome = ourClient.create().resource(patient).execute();
myPatientId = methodOutcome.getId().getIdPart();
/*
/*
* Create subscription
*/
Subscription subscription = new Subscription();
@ -92,7 +91,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
methodOutcome = ourClient.create().resource(subscription).execute();
mySubscriptionId = methodOutcome.getId().getIdPart();
/*
* Attach websocket
*/
@ -106,16 +105,10 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
ourLog.info("Connecting to : {}", echoUri);
Future<Session> connection = myWebSocketClient.connect(mySocketImplementation, echoUri, request);
Session session = connection.get(2, TimeUnit.SECONDS);
ourLog.info("Connected to WS: {}", session.isOpen());
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test
public void createObservation() throws Exception {
Observation observation = new Observation();
@ -134,7 +127,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
observation.setId(observationId);
ourLog.info("Observation id generated by server is: " + observationId);
ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
waitForSize(2, mySocketImplementation.getMessages());
assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId, "ping " + mySubscriptionId));
@ -158,7 +151,7 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
observation.setId(observationId);
ourLog.info("Observation id generated by server is: " + observationId);
ourLog.info("WS Messages: {}", mySocketImplementation.getMessages());
waitForSize(2, mySocketImplementation.getMessages());
assertThat(mySocketImplementation.getMessages(), contains("bound " + mySubscriptionId));