From 3173af31aeaa3132915febcfd3aae3283368a6e1 Mon Sep 17 00:00:00 2001 From: James Agnew Date: Sun, 17 Nov 2019 15:28:33 -0500 Subject: [PATCH] Try to avoid intermittent test failure --- .../fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java | 7 +++++++ .../fhir/test/utilities/UnregisterScheduledProcessor.java | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java index f20f42fe527..c3ff40c8ea2 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/provider/r4/StaleSearchDeletingSvcR4Test.java @@ -14,6 +14,7 @@ import ca.uhn.fhir.jpa.search.cache.DatabaseSearchCacheSvcImpl; import ca.uhn.fhir.rest.gclient.IClientExecutable; import ca.uhn.fhir.rest.gclient.IQuery; import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException; +import ca.uhn.fhir.test.utilities.UnregisterScheduledProcessor; import ca.uhn.fhir.util.TestUtil; import org.apache.commons.lang3.time.DateUtils; import org.hl7.fhir.r4.model.Bundle; @@ -24,6 +25,7 @@ import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.test.context.TestPropertySource; import org.springframework.test.util.AopTestUtils; import java.util.Date; @@ -33,6 +35,11 @@ import static ca.uhn.fhir.jpa.util.TestUtil.sleepAtLeast; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +@TestPropertySource(properties = { + // Since scheduled tasks can cause searches, which messes up the + // value returned by SearchBuilder.getLastHandlerMechanismForUnitTest() + UnregisterScheduledProcessor.SCHEDULING_DISABLED_EQUALS_TRUE +}) public class StaleSearchDeletingSvcR4Test extends BaseResourceProviderR4Test { private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(StaleSearchDeletingSvcR4Test.class); diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UnregisterScheduledProcessor.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UnregisterScheduledProcessor.java index d292b4ef6ec..fd943024dce 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UnregisterScheduledProcessor.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/UnregisterScheduledProcessor.java @@ -53,7 +53,7 @@ public class UnregisterScheduledProcessor implements BeanFactoryPostProcessor { } for (String beanName : beanFactory.getBeanNamesForType(ExecutorConfigurationSupport.class)) { - ExecutorConfigurationSupport executorConfigSupport = ((DefaultListableBeanFactory) beanFactory).getBean(beanName, ExecutorConfigurationSupport.class); + ExecutorConfigurationSupport executorConfigSupport = beanFactory.getBean(beanName, ExecutorConfigurationSupport.class); executorConfigSupport.shutdown(); } }