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 { public class DaoConfig {
/**
* Constructor
*/
public DaoConfig() {
setSubscriptionEnabled(true);
setSubscriptionPollDelay(0);
setSubscriptionPurgeInactiveAfterMillis(Long.MAX_VALUE);
}
/** /**
* Default {@link #getTreatReferencesAsLogical() logical URL bases}. Includes the following * Default {@link #getTreatReferencesAsLogical() logical URL bases}. Includes the following
* values: * values:
@ -76,68 +85,13 @@ public class DaoConfig {
private boolean myEnforceReferentialIntegrityOnDelete = true; private boolean myEnforceReferentialIntegrityOnDelete = true;
private boolean myUniqueIndexesEnabled = 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 myUniqueIndexesCheckedBeforeSave = true;
private boolean myEnforceReferentialIntegrityOnWrite = true; private boolean myEnforceReferentialIntegrityOnWrite = true;
private int myEverythingIncludesFetchPageSize = 50; private int myEverythingIncludesFetchPageSize = 50;
/** /**
* update setter javadoc if default changes * update setter javadoc if default changes
*/ */
private long myExpireSearchResultsAfterMillis = DateUtils.MILLIS_PER_HOUR; private long myExpireSearchResultsAfterMillis = DateUtils.MILLIS_PER_HOUR;
/** /**
* update setter javadoc if default changes * update setter javadoc if default changes
*/ */
@ -148,9 +102,7 @@ public class DaoConfig {
* update setter javadoc if default changes * update setter javadoc if default changes
*/ */
private boolean myIndexContainedResources = true; private boolean myIndexContainedResources = true;
private List<IServerInterceptor> myInterceptors; private List<IServerInterceptor> myInterceptors;
/** /**
* update setter javadoc if default changes * update setter javadoc if default changes
*/ */
@ -163,12 +115,6 @@ public class DaoConfig {
private Integer myResourceMetaCountHardLimit = 1000; private Integer myResourceMetaCountHardLimit = 1000;
private Long myReuseCachedSearchResultsForMillis = DEFAULT_REUSE_CACHED_SEARCH_RESULTS_FOR_MILLIS; private Long myReuseCachedSearchResultsForMillis = DEFAULT_REUSE_CACHED_SEARCH_RESULTS_FOR_MILLIS;
private boolean mySchedulingDisabled; private boolean mySchedulingDisabled;
private boolean mySubscriptionEnabled;
/**
* update setter javadoc if default changes
*/
private long mySubscriptionPollDelay = 1000;
private Long mySubscriptionPurgeInactiveAfterMillis;
private boolean mySuppressUpdatesWithNoChange = true; private boolean mySuppressUpdatesWithNoChange = true;
private Set<String> myTreatBaseUrlsAsLocal = new HashSet<String>(); private Set<String> myTreatBaseUrlsAsLocal = new HashSet<String>();
private Set<String> myTreatReferencesAsLogical = new HashSet<String>(DEFAULT_LOGICAL_BASE_URLS); 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. * This may be used to optionally register server interceptors directly against the DAOs.
*/ */
public void setInterceptors(IServerInterceptor... theInterceptor) { public void setInterceptors(List<IServerInterceptor> theInterceptors) {
setInterceptors(new ArrayList<IServerInterceptor>()); myInterceptors = theInterceptors;
if (theInterceptor != null && theInterceptor.length != 0) {
getInterceptors().addAll(Arrays.asList(theInterceptor));
}
} }
/** /**
@ -477,23 +420,22 @@ public class DaoConfig {
myReuseCachedSearchResultsForMillis = theReuseCachedSearchResultsForMillis; 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) { public void setSubscriptionPollDelay(long theSubscriptionPollDelay) {
mySubscriptionPollDelay = theSubscriptionPollDelay; // ignore
}
public Long getSubscriptionPurgeInactiveAfterMillis() {
return mySubscriptionPurgeInactiveAfterMillis;
} }
/**
* @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) { public void setSubscriptionPurgeInactiveAfterMillis(Long theMillis) {
if (theMillis != null) { // ignore
Validate.exclusiveBetween(0, Long.MAX_VALUE, theMillis);
}
mySubscriptionPurgeInactiveAfterMillis = theMillis;
} }
/** /**
@ -872,20 +814,14 @@ public class DaoConfig {
mySchedulingDisabled = theSchedulingDisabled; mySchedulingDisabled = theSchedulingDisabled;
} }
/**
* See {@link #setSubscriptionEnabled(boolean)}
*/
public boolean isSubscriptionEnabled() {
return mySubscriptionEnabled;
}
/** /**
* If set to true, the server will enable support for subscriptions. Subscriptions * @deprecated As of HAPI FHIR 3.0.0, subscriptions no longer use polling for
* 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 * detecting changes, so this setting has no effect
* config for the scheduled tasks used by the subscription module.
*/ */
@Deprecated
public void setSubscriptionEnabled(boolean theSubscriptionEnabled) { 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 * 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 * 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. * This may be used to optionally register server interceptors directly against the DAOs.
*/ */
public void setInterceptors(List<IServerInterceptor> theInterceptors) { public void setInterceptors(IServerInterceptor... theInterceptor) {
myInterceptors = theInterceptors; setInterceptors(new ArrayList<IServerInterceptor>());
if (theInterceptor != null && theInterceptor.length != 0) {
getInterceptors().addAll(Arrays.asList(theInterceptor));
}
} }
public void setSubscriptionPurgeInactiveAfterSeconds(int theSeconds) { public void setSubscriptionPurgeInactiveAfterSeconds(int theSeconds) {

View File

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

View File

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

View File

@ -1,14 +1,19 @@
package ca.uhn.fhir.jpa.subscription; package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains; import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test;
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.subscription.websocket.SubscriptionWebsocketInterceptor; 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.api.Session;
import org.eclipse.jetty.websocket.client.ClientUpgradeRequest; import org.eclipse.jetty.websocket.client.ClientUpgradeRequest;
import org.eclipse.jetty.websocket.client.WebSocketClient; import org.eclipse.jetty.websocket.client.WebSocketClient;
@ -17,14 +22,12 @@ import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;
import ca.uhn.fhir.jpa.dao.DaoConfig; import java.net.URI;
import ca.uhn.fhir.jpa.provider.BaseResourceProviderDstu2Test; import java.util.concurrent.Future;
import ca.uhn.fhir.model.dstu2.composite.*; import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.model.dstu2.resource.*;
import ca.uhn.fhir.model.dstu2.resource.Subscription.Channel; import static org.hamcrest.Matchers.contains;
import ca.uhn.fhir.model.dstu2.valueset.*; import static org.junit.Assert.*;
import ca.uhn.fhir.rest.api.EncodingEnum;
import ca.uhn.fhir.rest.api.MethodOutcome;
/** /**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the * Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -52,20 +55,20 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
@After @After
public void after() throws Exception { public void after() throws Exception {
super.after(); super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class); SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor); ourRestServer.unregisterInterceptor(interceptor);
} }
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class); SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor); ourRestServer.registerInterceptor(interceptor);
@ -111,12 +114,6 @@ public class WebsocketWithSubscriptionIdDstu2Test extends BaseResourceProviderDs
ourLog.info("Connected to WS: {}", session.isOpen()); ourLog.info("Connected to WS: {}", session.isOpen());
} }
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test @Test
public void createObservation() throws Exception { public void createObservation() throws Exception {
Observation observation = new Observation(); Observation observation = new Observation();

View File

@ -1,25 +1,24 @@
package ca.uhn.fhir.jpa.subscription; package ca.uhn.fhir.jpa.subscription;
import static org.hamcrest.Matchers.contains; import ca.uhn.fhir.jpa.provider.dstu3.BaseResourceProviderDstu3Test;
import static org.junit.Assert.assertEquals; import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor;
import static org.junit.Assert.assertThat; 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.net.URI;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor; import static org.hamcrest.Matchers.contains;
import org.eclipse.jetty.websocket.api.Session; import static org.junit.Assert.*;
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;
/** /**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the * Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -50,21 +49,21 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
@After @After
public void after() throws Exception { public void after() throws Exception {
super.after(); super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class); SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor); ourRestServer.unregisterInterceptor(interceptor);
}
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
} }
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor);
myDaoConfig.setSubscriptionEnabled(true); myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L); myDaoConfig.setSubscriptionPollDelay(0L);
@ -110,12 +109,6 @@ public class WebsocketWithSubscriptionIdDstu3Test extends BaseResourceProviderDs
ourLog.info("Connected to WS: {}", session.isOpen()); ourLog.info("Connected to WS: {}", session.isOpen());
} }
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test @Test
public void createObservation() throws Exception { public void createObservation() throws Exception {
Observation observation = new Observation(); Observation observation = new Observation();

View File

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

View File

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

View File

@ -1,26 +1,25 @@
package ca.uhn.fhir.jpa.subscription.r4; package ca.uhn.fhir.jpa.subscription.r4;
import static org.hamcrest.Matchers.contains; import ca.uhn.fhir.jpa.provider.r4.BaseResourceProviderR4Test;
import static org.junit.Assert.assertEquals; import ca.uhn.fhir.jpa.subscription.SocketImplementation;
import static org.junit.Assert.assertThat; 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.net.URI;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import ca.uhn.fhir.jpa.subscription.websocket.SubscriptionWebsocketInterceptor; import static org.hamcrest.Matchers.contains;
import org.eclipse.jetty.websocket.api.Session; import static org.junit.Assert.*;
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;
/** /**
* Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the * Adds a FHIR subscription with criteria through the rest interface. Then creates a websocket with the id of the
@ -51,20 +50,20 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
@After @After
public void after() throws Exception { public void after() throws Exception {
super.after(); super.after();
myDaoConfig.setSubscriptionEnabled(new DaoConfig().isSubscriptionEnabled());
myDaoConfig.setSubscriptionPollDelay(new DaoConfig().getSubscriptionPollDelay());
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class); SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.unregisterInterceptor(interceptor); ourRestServer.unregisterInterceptor(interceptor);
} }
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Before @Before
public void before() throws Exception { public void before() throws Exception {
super.before(); super.before();
myDaoConfig.setSubscriptionEnabled(true);
myDaoConfig.setSubscriptionPollDelay(0L);
SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class); SubscriptionWebsocketInterceptor interceptor = ourWebApplicationContext.getBean(SubscriptionWebsocketInterceptor.class);
ourRestServer.registerInterceptor(interceptor); ourRestServer.registerInterceptor(interceptor);
@ -110,12 +109,6 @@ public class WebsocketWithSubscriptionIdR4Test extends BaseResourceProviderR4Tes
ourLog.info("Connected to WS: {}", session.isOpen()); ourLog.info("Connected to WS: {}", session.isOpen());
} }
@After
public void afterCloseWebsocket() throws Exception {
ourLog.info("Shutting down websocket client");
myWebSocketClient.stop();
}
@Test @Test
public void createObservation() throws Exception { public void createObservation() throws Exception {
Observation observation = new Observation(); Observation observation = new Observation();