More fighting with tests
This commit is contained in:
parent
3a6a045d87
commit
ff477885e1
|
@ -19,8 +19,10 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.lang.Nullable;
|
||||||
import org.springframework.test.util.AopTestUtils;
|
import org.springframework.test.util.AopTestUtils;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
|
import org.springframework.transaction.support.TransactionCallback;
|
||||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
@ -351,19 +353,21 @@ public class FhirResourceDaoDstu3SearchPageExpiryTest extends BaseJpaDstu3Test {
|
||||||
params.setCount(1);
|
params.setCount(1);
|
||||||
final IBundleProvider bundleProvider = myPatientDao.search(params);
|
final IBundleProvider bundleProvider = myPatientDao.search(params);
|
||||||
|
|
||||||
newTxTemplate().execute(new TransactionCallbackWithoutResult() {
|
Search search = null;
|
||||||
@Override
|
for (int i = 0; i < 100 && search == null; i++) {
|
||||||
protected void doInTransactionWithoutResult(TransactionStatus theArg0) {
|
search = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||||
Search search = null;
|
@Nullable
|
||||||
for (int i = 0; i < 100 && search == null; i++) {
|
@Override
|
||||||
search = mySearchEntityDao.findByUuid(bundleProvider.getUuid());
|
public Search doInTransaction(TransactionStatus status) {
|
||||||
if (search == null) {
|
return mySearchEntityDao.findByUuid(bundleProvider.getUuid());
|
||||||
sleepAtLeast(100);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
assertNotNull("Search " + bundleProvider.getUuid() + " not found on disk after 10 seconds", search);
|
});
|
||||||
|
if (search == null) {
|
||||||
|
sleepAtLeast(100);
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
assertNotNull("Search " + bundleProvider.getUuid() + " not found on disk after 10 seconds", search);
|
||||||
|
|
||||||
|
|
||||||
myDaoConfig.setExpireSearchResults(false);
|
myDaoConfig.setExpireSearchResults(false);
|
||||||
StaleSearchDeletingSvcImpl.setNowForUnitTests(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY);
|
StaleSearchDeletingSvcImpl.setNowForUnitTests(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY);
|
||||||
|
|
|
@ -19,9 +19,11 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.test.util.AopTestUtils;
|
import org.springframework.test.util.AopTestUtils;
|
||||||
import org.springframework.transaction.TransactionStatus;
|
import org.springframework.transaction.TransactionStatus;
|
||||||
|
import org.springframework.transaction.support.TransactionCallback;
|
||||||
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
import org.springframework.transaction.support.TransactionCallbackWithoutResult;
|
||||||
import org.springframework.transaction.support.TransactionTemplate;
|
import org.springframework.transaction.support.TransactionTemplate;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
@ -342,7 +344,21 @@ public class FhirResourceDaoR4SearchPageExpiryTest extends BaseJpaR4Test {
|
||||||
params.setCount(1);
|
params.setCount(1);
|
||||||
final IBundleProvider bundleProvider = myPatientDao.search(params);
|
final IBundleProvider bundleProvider = myPatientDao.search(params);
|
||||||
|
|
||||||
waitForSearchToSave(bundleProvider.getUuid());
|
Search search = null;
|
||||||
|
for (int i = 0; i < 100 && search == null; i++) {
|
||||||
|
search = newTxTemplate().execute(new TransactionCallback<Search>() {
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
public Search doInTransaction(TransactionStatus status) {
|
||||||
|
return mySearchEntityDao.findByUuid(bundleProvider.getUuid());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (search == null) {
|
||||||
|
sleepAtLeast(100);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
assertNotNull("Search " + bundleProvider.getUuid() + " not found on disk after 10 seconds", search);
|
||||||
|
|
||||||
|
|
||||||
myDaoConfig.setExpireSearchResults(false);
|
myDaoConfig.setExpireSearchResults(false);
|
||||||
StaleSearchDeletingSvcImpl.setNowForUnitTests(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY);
|
StaleSearchDeletingSvcImpl.setNowForUnitTests(System.currentTimeMillis() + DateUtils.MILLIS_PER_DAY);
|
||||||
|
|
Loading…
Reference in New Issue