Fixed ServerFileLoaderTest broken due to removal of print line

This commit is contained in:
Aurora Lahtela 2022-06-04 09:27:27 +03:00
parent 1522a8731d
commit 33de99cfab
1 changed files with 14 additions and 8 deletions

View File

@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
class ServerFileLoaderTest { class ServerFileLoaderTest {
static PlanSystem system; static PlanSystem system;
static ServerFileLoader underTest; static ServerLoader underTest;
private static ServerUUID serverUUID; private static ServerUUID serverUUID;
@BeforeAll @BeforeAll
@ -57,7 +57,9 @@ class ServerFileLoaderTest {
@BeforeEach @BeforeEach
void setUpEach() { void setUpEach() {
underTest = new ServerFileLoader(TestConstants.VERSION, system.getPlanFiles(), system.getConfigSystem().getConfig()); underTest = new AtomicServerLoader(
new ServerFileLoader(TestConstants.VERSION, system.getPlanFiles(), system.getConfigSystem().getConfig())
);
Optional<Server> loaded = underTest.load(null); Optional<Server> loaded = underTest.load(null);
assertTrue(loaded.isPresent()); assertTrue(loaded.isPresent());
@ -71,16 +73,20 @@ class ServerFileLoaderTest {
ExecutorService executorService = new ScheduledThreadPoolExecutor(6); ExecutorService executorService = new ScheduledThreadPoolExecutor(6);
AtomicInteger runs = new AtomicInteger(1); AtomicInteger runs = new AtomicInteger(1);
int expected = 10000; int expected = 1000;
AtomicInteger fails = new AtomicInteger(0); AtomicInteger fails = new AtomicInteger(0);
try { try {
for (int i = 0; i < expected; i++) { for (int i = 0; i < expected; i++) {
executorService.submit(() -> { executorService.submit(() -> {
Optional<Server> load = underTest.load(null); try {
if (load.isPresent()) { Optional<Server> load = underTest.load(null);
underTest.save(load.get()); if (load.isPresent()) {
} else { underTest.save(load.get());
System.out.println("Failure " + fails.incrementAndGet()); } else {
System.out.println("Failure " + fails.incrementAndGet());
}
} finally {
runs.incrementAndGet();
} }
}); });
} }