Try to fix an intermittent test failure

This commit is contained in:
James Agnew 2018-10-04 13:07:52 -04:00
parent 2464599a68
commit da3b4d4071
1 changed files with 7 additions and 10 deletions

View File

@ -32,10 +32,7 @@ import org.hl7.fhir.dstu3.model.Resource;
import org.hl7.fhir.instance.model.api.IBaseBundle; import org.hl7.fhir.instance.model.api.IBaseBundle;
import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IBaseResource;
import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.instance.model.api.IIdType;
import org.junit.After; import org.junit.*;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Rule;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.jpa.JpaTransactionManager; import org.springframework.orm.jpa.JpaTransactionManager;
@ -126,11 +123,6 @@ public abstract class BaseJpaTest {
when(mySrd.getHeaders(eq(JpaConstants.HEADER_META_SNAPSHOT_MODE))).thenReturn(new ArrayList<>()); when(mySrd.getHeaders(eq(JpaConstants.HEADER_META_SNAPSHOT_MODE))).thenReturn(new ArrayList<>());
} }
@Before
public void beforeRandomizeLocale() {
randomizeLocale();
}
protected abstract FhirContext getContext(); protected abstract FhirContext getContext();
protected abstract PlatformTransactionManager getTxManager(); protected abstract PlatformTransactionManager getTxManager();
@ -152,7 +144,7 @@ public abstract class BaseJpaTest {
} }
public <T> T runInTransaction(Callable<T> theRunnable) { public <T> T runInTransaction(Callable<T> theRunnable) {
return newTxTemplate().execute(t->{ return newTxTemplate().execute(t -> {
try { try {
return theRunnable.call(); return theRunnable.call();
} catch (Exception theE) { } catch (Exception theE) {
@ -333,6 +325,11 @@ public abstract class BaseJpaTest {
return retVal.toArray(new String[retVal.size()]); return retVal.toArray(new String[retVal.size()]);
} }
@BeforeClass
public static void beforeClassRandomizeLocale() {
randomizeLocale();
}
@SuppressWarnings("RedundantThrows") @SuppressWarnings("RedundantThrows")
@AfterClass @AfterClass
public static void afterClassClearContext() throws Exception { public static void afterClassClearContext() throws Exception {