[mapdb] Make serialization asynchronous (#14900)

* [mapdb] Make serialization asynchronous

---------

Signed-off-by: Jan N. Klug <github@klug.nrw>
This commit is contained in:
J-N-K
2023-05-01 09:10:28 +02:00
committed by GitHub
parent acb73a2c7b
commit 990700de8d
2 changed files with 19 additions and 18 deletions

View File

@@ -23,6 +23,7 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.stream.Stream;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
@@ -62,7 +63,9 @@ public class MapDbPersistenceServiceOSGiTest extends JavaOSGiTest {
private static void removeDirRecursive(final String dir) throws IOException {
final Path path = Paths.get(dir);
if (Files.exists(path)) {
Files.walk(path).map(Path::toFile).sorted().forEach(File::delete);
try (Stream<Path> stream = Files.walk(path)) {
stream.map(Path::toFile).sorted().forEach(File::delete);
}
}
}
@@ -79,12 +82,12 @@ public class MapDbPersistenceServiceOSGiTest extends JavaOSGiTest {
persistenceService.store(item);
assertThat(persistenceService.getItemInfo(), hasItem(hasProperty("name", equalTo(name))));
waitForAssert(() -> assertThat(persistenceService.getItemInfo(), hasItem(hasProperty("name", equalTo(name)))));
persistenceService.store(item, alias);
assertThat(persistenceService.getItemInfo(),
hasItems(hasProperty("name", equalTo(name)), hasProperty("name", equalTo(alias))));
waitForAssert(() -> assertThat(persistenceService.getItemInfo(),
hasItems(hasProperty("name", equalTo(name)), hasProperty("name", equalTo(alias)))));
}
@Test
@@ -102,8 +105,8 @@ public class MapDbPersistenceServiceOSGiTest extends JavaOSGiTest {
persistenceService.store(item);
assertThat(persistenceService.query(filter),
contains(allOf(hasProperty("name", equalTo(name)), hasProperty("state", equalTo(state)))));
waitForAssert(() -> assertThat(persistenceService.query(filter),
contains(allOf(hasProperty("name", equalTo(name)), hasProperty("state", equalTo(state))))));
}
@Test
@@ -127,7 +130,7 @@ public class MapDbPersistenceServiceOSGiTest extends JavaOSGiTest {
persistenceService.store(item, alias);
assertThat(persistenceService.query(filterByName), is(emptyIterable()));
assertThat(persistenceService.query(filterByAlias),
contains(allOf(hasProperty("name", equalTo(alias)), hasProperty("state", equalTo(state)))));
waitForAssert(() -> assertThat(persistenceService.query(filterByAlias),
contains(allOf(hasProperty("name", equalTo(alias)), hasProperty("state", equalTo(state))))));
}
}