Make our NoFt tests actually run without Ft.

Hibernate search was always configured with a lucene heap engine in all JPA tests.
Added a new config param - hapi_test.enable_lucene - to disable with config params on the NoFt tests.
This commit is contained in:
Michael Buckley 2021-09-24 12:05:16 -04:00
parent 79a3fb19b2
commit db55837c3c
17 changed files with 100 additions and 40 deletions

View File

@ -276,7 +276,7 @@ public class LegacySearchBuilder implements ISearchBuilder {
*/ */
if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT) || myParams.isLastN()) { if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT) || myParams.isLastN()) {
if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT)) { if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT)) {
if (myFulltextSearchSvc == null) { if (myFulltextSearchSvc == null || myFulltextSearchSvc.isDisabled()) {
if (myParams.containsKey(Constants.PARAM_TEXT)) { if (myParams.containsKey(Constants.PARAM_TEXT)) {
throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_TEXT); throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_TEXT);
} else if (myParams.containsKey(Constants.PARAM_CONTENT)) { } else if (myParams.containsKey(Constants.PARAM_CONTENT)) {

View File

@ -314,7 +314,7 @@ public class SearchBuilder implements ISearchBuilder {
*/ */
if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT) || myParams.isLastN()) { if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT) || myParams.isLastN()) {
if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT)) { if (myParams.containsKey(Constants.PARAM_CONTENT) || myParams.containsKey(Constants.PARAM_TEXT)) {
if (myFulltextSearchSvc == null) { if (myFulltextSearchSvc == null || myFulltextSearchSvc.isDisabled()) {
if (myParams.containsKey(Constants.PARAM_TEXT)) { if (myParams.containsKey(Constants.PARAM_TEXT)) {
throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_TEXT); throw new InvalidRequestException("Fulltext search is not enabled on this service, can not process parameter: " + Constants.PARAM_TEXT);
} else if (myParams.containsKey(Constants.PARAM_CONTENT)) { } else if (myParams.containsKey(Constants.PARAM_CONTENT)) {

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.config; package ca.uhn.fhir.jpa.config;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer;
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
@ -155,7 +156,14 @@ public class TestDstu2Config extends BaseJavaConfigDstu2 {
extraProperties.put("hibernate.hbm2ddl.auto", "update"); extraProperties.put("hibernate.hbm2ddl.auto", "update");
extraProperties.put("hibernate.dialect", H2Dialect.class.getName()); extraProperties.put("hibernate.dialect", H2Dialect.class.getName());
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties()); boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, false);
if (enableLucene) {
ourLog.warn("Hibernate Search is enabled");
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties());
} {
ourLog.warn("Hibernate Search is disabled");
extraProperties.put("hibernate.search.enabled", "false");
}
return extraProperties; return extraProperties;
} }

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.config; package ca.uhn.fhir.jpa.config;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer;
import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl; import ca.uhn.fhir.jpa.subscription.match.deliver.email.EmailSenderImpl;
import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender; import ca.uhn.fhir.jpa.subscription.match.deliver.email.IEmailSender;
@ -30,6 +31,7 @@ import java.sql.Connection;
import java.util.Properties; import java.util.Properties;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import static ca.uhn.fhir.jpa.dao.BaseJpaTest.buildHeapLuceneHibernateSearchProperties;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
@Configuration @Configuration
@ -155,11 +157,14 @@ public class TestDstu3Config extends BaseJavaConfigDstu3 {
extraProperties.put("hibernate.hbm2ddl.auto", "update"); extraProperties.put("hibernate.hbm2ddl.auto", "update");
extraProperties.put("hibernate.dialect", H2Dialect.class.getName()); extraProperties.put("hibernate.dialect", H2Dialect.class.getName());
extraProperties.put(BackendSettings.backendKey(BackendSettings.TYPE), "lucene"); boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, true);
extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.ANALYSIS_CONFIGURER), HapiLuceneAnalysisConfigurer.class.getName()); if (enableLucene) {
extraProperties.put(BackendSettings.backendKey(LuceneIndexSettings.DIRECTORY_TYPE), "local-heap"); ourLog.warn("Hibernate Search is enabled");
extraProperties.put(BackendSettings.backendKey(LuceneBackendSettings.LUCENE_VERSION), "LUCENE_CURRENT"); extraProperties.putAll(buildHeapLuceneHibernateSearchProperties());
extraProperties.put(HibernateOrmMapperSettings.ENABLED, "true"); } {
ourLog.warn("Hibernate Search is disabled");
extraProperties.put("hibernate.search.enabled", "false");
}
return extraProperties; return extraProperties;
} }

View File

@ -1,11 +1,11 @@
package ca.uhn.fhir.jpa.config; package ca.uhn.fhir.jpa.config;
import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.batch.BatchJobsConfig; import ca.uhn.fhir.jpa.batch.BatchJobsConfig;
import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter; import ca.uhn.fhir.jpa.batch.api.IBatchJobSubmitter;
import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl; import ca.uhn.fhir.jpa.batch.svc.BatchJobSubmitterImpl;
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor; import ca.uhn.fhir.rest.server.interceptor.RequestValidatingInterceptor;
@ -58,7 +58,6 @@ public class TestR4Config extends BaseJavaConfigR4 {
private Exception myLastStackTrace; private Exception myLastStackTrace;
@Override @Override
@Bean @Bean
public IBatchJobSubmitter batchJobSubmitter() { public IBatchJobSubmitter batchJobSubmitter() {
@ -164,7 +163,14 @@ public class TestR4Config extends BaseJavaConfigR4 {
extraProperties.put("hibernate.hbm2ddl.auto", "update"); extraProperties.put("hibernate.hbm2ddl.auto", "update");
extraProperties.put("hibernate.dialect", H2Dialect.class.getName()); extraProperties.put("hibernate.dialect", H2Dialect.class.getName());
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties()); boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, false);
if (enableLucene) {
ourLog.warn("Hibernate Search is enabled");
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties());
} {
ourLog.warn("Hibernate Search is disabled");
extraProperties.put("hibernate.search.enabled", "false");
}
return extraProperties; return extraProperties;
} }

View File

@ -2,6 +2,7 @@ package ca.uhn.fhir.jpa.config;
import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc; import ca.uhn.fhir.jpa.binstore.IBinaryStorageSvc;
import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl; import ca.uhn.fhir.jpa.binstore.MemoryBinaryStorageSvcImpl;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer; import ca.uhn.fhir.jpa.search.HapiLuceneAnalysisConfigurer;
import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CircularQueueCaptureQueriesListener;
import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener; import ca.uhn.fhir.jpa.util.CurrentThreadCaptureQueriesListener;
@ -154,7 +155,14 @@ public class TestR5Config extends BaseJavaConfigR5 {
extraProperties.put("hibernate.hbm2ddl.auto", "update"); extraProperties.put("hibernate.hbm2ddl.auto", "update");
extraProperties.put("hibernate.dialect", H2Dialect.class.getName()); extraProperties.put("hibernate.dialect", H2Dialect.class.getName());
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties()); boolean enableLucene = myEnv.getProperty(BaseJpaTest.CONFIG_ENABLE_LUCENE, Boolean.TYPE, false);
if (enableLucene) {
ourLog.warn("Hibernate Search is enabled");
extraProperties.putAll(buildHeapLuceneHibernateSearchProperties());
} {
ourLog.warn("Hibernate Search is disabled");
extraProperties.put("hibernate.search.enabled", "false");
}
return extraProperties; return extraProperties;
} }

View File

@ -118,6 +118,8 @@ import static org.mockito.Mockito.when;
UnregisterScheduledProcessor.SCHEDULING_DISABLED_EQUALS_TRUE UnregisterScheduledProcessor.SCHEDULING_DISABLED_EQUALS_TRUE
}) })
public abstract class BaseJpaTest extends BaseTest { public abstract class BaseJpaTest extends BaseTest {
public static final String CONFIG_ENABLE_LUCENE="hapi_test.enable_lucene";
public static final String CONFIG_ENABLE_LUCENE_FALSE = CONFIG_ENABLE_LUCENE + "=false";
protected static final String CM_URL = "http://example.com/my_concept_map"; protected static final String CM_URL = "http://example.com/my_concept_map";
protected static final String CS_URL = "http://example.com/my_code_system"; protected static final String CS_URL = "http://example.com/my_code_system";
@ -180,6 +182,8 @@ public abstract class BaseJpaTest extends BaseTest {
private IResourceHistoryTableDao myResourceHistoryTableDao; private IResourceHistoryTableDao myResourceHistoryTableDao;
@Autowired @Autowired
private IForcedIdDao myForcedIdDao; private IForcedIdDao myForcedIdDao;
@Autowired
protected IFulltextSearchSvc myFulltestSearchSvc;
@AfterEach @AfterEach
public void afterPerformCleanup() { public void afterPerformCleanup() {

View File

@ -226,12 +226,15 @@ public abstract class BaseJpaDstu2Test extends BaseJpaTest {
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { if (!myFulltestSearchSvc.isDisabled()) {
SearchSession searchSession = Search.session(myEntityManager); runInTransaction(() -> {
searchSession.workspace(ResourceTable.class).purge(); SearchSession searchSession = Search.session(myEntityManager);
// searchSession.workspace(ResourceIndexedSearchParamString.class).purge(); searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute(); // searchSession.workspace(ResourceIndexedSearchParamString.class).purge();
}); searchSession.indexingPlan().execute();
});
}
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);

View File

@ -386,12 +386,14 @@ public abstract class BaseJpaDstu3Test extends BaseJpaTest {
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { if (!myFulltestSearchSvc.isDisabled()) {
SearchSession searchSession = Search.session(myEntityManager); runInTransaction(() -> {
searchSession.workspace(ResourceTable.class).purge(); SearchSession searchSession = Search.session(myEntityManager);
// searchSession.workspace(ResourceIndexedSearchParamString.class).purge(); searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute(); // searchSession.workspace(ResourceIndexedSearchParamString.class).purge();
}); searchSession.indexingPlan().execute();
});
}
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED); myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.ENABLED);

View File

@ -4,6 +4,7 @@ import ca.uhn.fhir.context.phonetic.ApacheEncoder;
import ca.uhn.fhir.context.phonetic.NumericEncoder; import ca.uhn.fhir.context.phonetic.NumericEncoder;
import ca.uhn.fhir.context.phonetic.PhoneticEncoderEnum; import ca.uhn.fhir.context.phonetic.PhoneticEncoderEnum;
import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
import ca.uhn.fhir.rest.param.StringParam; import ca.uhn.fhir.rest.param.StringParam;
@ -19,6 +20,7 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.TestPropertySource;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -30,6 +32,9 @@ import static org.hamcrest.Matchers.hasSize;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals;
@TestPropertySource(properties = {
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
})
public class FhirResourceDaoDstu3PhoneticSearchNoFtTest extends BaseJpaDstu3Test { public class FhirResourceDaoDstu3PhoneticSearchNoFtTest extends BaseJpaDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3PhoneticSearchNoFtTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3PhoneticSearchNoFtTest.class);
public static final String GALE = "Gale"; public static final String GALE = "Gale";

View File

@ -1,6 +1,7 @@
package ca.uhn.fhir.jpa.dao.dstu3; package ca.uhn.fhir.jpa.dao.dstu3;
import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamDate;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamNumber;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamQuantity;
@ -95,6 +96,7 @@ import org.hl7.fhir.instance.model.api.IPrimitiveType;
import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionCallback;
@ -125,6 +127,9 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
@TestPropertySource(properties = {
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
})
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test { public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SearchNoFtTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoDstu3SearchNoFtTest.class);
@ -2234,12 +2239,11 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
} }
@Test @Test
@Disabled
public void testSearchUnknownContentParam() { public void testSearchUnknownContentParam() {
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
params.add(Constants.PARAM_CONTENT, new StringParam("fulltext")); params.add(Constants.PARAM_CONTENT, new StringParam("fulltext"));
try { try {
myPatientDao.search(params); myPatientDao.search(params).getAllResources();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("Fulltext search is not enabled on this service, can not process parameter: _content", e.getMessage()); assertEquals("Fulltext search is not enabled on this service, can not process parameter: _content", e.getMessage());
@ -2247,12 +2251,11 @@ public class FhirResourceDaoDstu3SearchNoFtTest extends BaseJpaDstu3Test {
} }
@Test @Test
@Disabled
public void testSearchUnknownTextParam() { public void testSearchUnknownTextParam() {
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
params.add(Constants.PARAM_TEXT, new StringParam("fulltext")); params.add(Constants.PARAM_TEXT, new StringParam("fulltext"));
try { try {
myPatientDao.search(params); myPatientDao.search(params).getAllResources();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("Fulltext search is not enabled on this service, can not process parameter: _text", e.getMessage()); assertEquals("Fulltext search is not enabled on this service, can not process parameter: _text", e.getMessage());

View File

@ -551,9 +551,11 @@ public abstract class BaseJpaR4Test extends BaseJpaTest implements ITestDataBuil
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { runInTransaction(() -> {
SearchSession searchSession = Search.session(myEntityManager); if (!myFulltestSearchSvc.isDisabled()) {
searchSession.workspace(ResourceTable.class).purge(); SearchSession searchSession = Search.session(myEntityManager);
searchSession.indexingPlan().execute(); searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute();
}
}); });
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);

View File

@ -5,6 +5,7 @@ import ca.uhn.fhir.interceptor.api.HookParams;
import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor; import ca.uhn.fhir.interceptor.api.IAnonymousInterceptor;
import ca.uhn.fhir.interceptor.api.Pointcut; import ca.uhn.fhir.interceptor.api.Pointcut;
import ca.uhn.fhir.jpa.api.config.DaoConfig; import ca.uhn.fhir.jpa.api.config.DaoConfig;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.entity.Search; import ca.uhn.fhir.jpa.entity.Search;
import ca.uhn.fhir.jpa.model.config.PartitionSettings; import ca.uhn.fhir.jpa.model.config.PartitionSettings;
import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig;
@ -132,6 +133,7 @@ import org.junit.jupiter.api.Test;
import org.mockito.ArgumentCaptor; import org.mockito.ArgumentCaptor;
import org.mockito.ArgumentMatchers; import org.mockito.ArgumentMatchers;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.TestPropertySource;
import org.springframework.transaction.TransactionDefinition; import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.TransactionStatus;
import org.springframework.transaction.support.TransactionCallback; import org.springframework.transaction.support.TransactionCallback;
@ -174,9 +176,11 @@ import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
@SuppressWarnings({"unchecked", "Duplicates"}) @SuppressWarnings({"unchecked", "Duplicates"})
@TestPropertySource(properties = {
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
})
public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test { public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR4SearchNoFtTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR4SearchNoFtTest.class);
@Autowired @Autowired
MatchUrlService myMatchUrlService; MatchUrlService myMatchUrlService;
@ -3981,12 +3985,11 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
} }
@Test @Test
@Disabled
public void testSearchUnknownContentParam() { public void testSearchUnknownContentParam() {
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
params.add(Constants.PARAM_CONTENT, new StringParam("fulltext")); params.add(Constants.PARAM_CONTENT, new StringParam("fulltext"));
try { try {
myPatientDao.search(params); myPatientDao.search(params).getAllResources();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("Fulltext search is not enabled on this service, can not process parameter: _content", e.getMessage()); assertEquals("Fulltext search is not enabled on this service, can not process parameter: _content", e.getMessage());
@ -3994,12 +3997,11 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
} }
@Test @Test
@Disabled
public void testSearchUnknownTextParam() { public void testSearchUnknownTextParam() {
SearchParameterMap params = new SearchParameterMap(); SearchParameterMap params = new SearchParameterMap();
params.add(Constants.PARAM_TEXT, new StringParam("fulltext")); params.add(Constants.PARAM_TEXT, new StringParam("fulltext"));
try { try {
myPatientDao.search(params); myPatientDao.search(params).getAllResources();
fail(); fail();
} catch (InvalidRequestException e) { } catch (InvalidRequestException e) {
assertEquals("Fulltext search is not enabled on this service, can not process parameter: _text", e.getMessage()); assertEquals("Fulltext search is not enabled on this service, can not process parameter: _text", e.getMessage());

View File

@ -478,10 +478,11 @@ public abstract class BaseJpaR5Test extends BaseJpaTest implements ITestDataBuil
@BeforeEach @BeforeEach
public void beforeFlushFT() { public void beforeFlushFT() {
runInTransaction(() -> { runInTransaction(() -> {
SearchSession searchSession = Search.session(myEntityManager); if (!myFulltestSearchSvc.isDisabled()) {
searchSession.workspace(ResourceTable.class).purge(); SearchSession searchSession = Search.session(myEntityManager);
// searchSession.workspace(ResourceIndexedSearchParamString.class).purge(); searchSession.workspace(ResourceTable.class).purge();
searchSession.indexingPlan().execute(); searchSession.indexingPlan().execute();
}
}); });
myDaoConfig.setSchedulingDisabled(true); myDaoConfig.setSchedulingDisabled(true);

View File

@ -1,5 +1,6 @@
package ca.uhn.fhir.jpa.dao.r5; package ca.uhn.fhir.jpa.dao.r5;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable; import ca.uhn.fhir.jpa.model.entity.ResourceHistoryTable;
import ca.uhn.fhir.jpa.model.entity.ResourceTable; import ca.uhn.fhir.jpa.model.entity.ResourceTable;
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
@ -16,12 +17,16 @@ import org.hl7.fhir.r5.model.Practitioner;
import org.hl7.fhir.r5.model.PractitionerRole; import org.hl7.fhir.r5.model.PractitionerRole;
import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.test.context.TestPropertySource;
import java.util.Date; import java.util.Date;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@TestPropertySource(properties = {
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
})
@SuppressWarnings({"unchecked", "Duplicates"}) @SuppressWarnings({"unchecked", "Duplicates"})
public class FhirResourceDaoR5SearchNoFtTest extends BaseJpaR5Test { public class FhirResourceDaoR5SearchNoFtTest extends BaseJpaR5Test {
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR5SearchNoFtTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(FhirResourceDaoR5SearchNoFtTest.class);

View File

@ -3,6 +3,7 @@ package ca.uhn.fhir.jpa.subscription.module.matcher;
import ca.uhn.fhir.context.FhirContext; import ca.uhn.fhir.context.FhirContext;
import ca.uhn.fhir.jpa.config.TestR4Config; import ca.uhn.fhir.jpa.config.TestR4Config;
import ca.uhn.fhir.jpa.dao.BaseJpaTest;
import ca.uhn.fhir.jpa.model.entity.ModelConfig; import ca.uhn.fhir.jpa.model.entity.ModelConfig;
import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel; import ca.uhn.fhir.jpa.model.entity.NormalizedQuantitySearchLevel;
import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString; import ca.uhn.fhir.jpa.model.entity.ResourceIndexedSearchParamString;
@ -70,6 +71,7 @@ import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit.jupiter.SpringExtension; import org.springframework.test.context.junit.jupiter.SpringExtension;
import java.math.BigDecimal; import java.math.BigDecimal;
@ -83,6 +85,9 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail; import static org.junit.jupiter.api.Assertions.fail;
@TestPropertySource(properties = {
BaseJpaTest.CONFIG_ENABLE_LUCENE_FALSE
})
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {TestR4Config.class}) @ContextConfiguration(classes = {TestR4Config.class})
public class InMemorySubscriptionMatcherR4Test { public class InMemorySubscriptionMatcherR4Test {

View File

@ -43,6 +43,7 @@ import java.util.concurrent.TimeUnit;
@Import(CommonConfig.class) @Import(CommonConfig.class)
@EnableTransactionManagement() @EnableTransactionManagement()
public class TestDstu2Config extends BaseJavaConfigDstu2 { public class TestDstu2Config extends BaseJavaConfigDstu2 {
// fixme - is this used in NoFt tests?
public static final String FHIR_LUCENE_LOCATION_DSTU2 = "${fhir.lucene.location.dstu2}"; public static final String FHIR_LUCENE_LOCATION_DSTU2 = "${fhir.lucene.location.dstu2}";