CavalliumDBEngine/src/test/java/it/cavallium/dbengine/TestDictionary.java

57 lines
1.7 KiB
Java
Raw Normal View History

2021-05-02 19:18:15 +02:00
package it.cavallium.dbengine;
2021-08-29 01:15:51 +02:00
import static it.cavallium.dbengine.DbTestUtils.destroyAllocator;
2021-08-28 22:42:51 +02:00
import static it.cavallium.dbengine.DbTestUtils.ensureNoLeaks;
2021-09-10 13:42:02 +02:00
import static it.cavallium.dbengine.DbTestUtils.isCIMode;
2021-08-29 01:15:51 +02:00
import static it.cavallium.dbengine.DbTestUtils.newAllocator;
2021-05-02 19:18:15 +02:00
import static it.cavallium.dbengine.DbTestUtils.tempDb;
import static it.cavallium.dbengine.DbTestUtils.tempDictionary;
2021-08-29 01:15:51 +02:00
import it.cavallium.dbengine.DbTestUtils.TestAllocator;
2021-05-02 19:18:15 +02:00
import it.cavallium.dbengine.database.LLDictionary;
import it.cavallium.dbengine.database.UpdateMode;
import java.util.Arrays;
import java.util.stream.Stream;
2021-08-28 22:42:51 +02:00
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
2021-05-02 19:18:15 +02:00
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import reactor.test.StepVerifier;
2021-09-06 01:15:13 +02:00
public abstract class TestDictionary {
2021-05-02 19:18:15 +02:00
2021-08-29 01:15:51 +02:00
private TestAllocator allocator;
2021-09-06 01:15:13 +02:00
protected abstract TemporaryDbGenerator getTempDbGenerator();
2021-05-02 19:18:15 +02:00
private static Stream<Arguments> provideArgumentsCreate() {
return Arrays.stream(UpdateMode.values()).map(Arguments::of);
}
2021-08-28 22:42:51 +02:00
@BeforeEach
public void beforeEach() {
2021-08-29 01:15:51 +02:00
this.allocator = newAllocator();
ensureNoLeaks(allocator.allocator(), false, false);
2021-08-28 22:42:51 +02:00
}
@AfterEach
public void afterEach() {
2021-09-10 13:42:02 +02:00
if (!isCIMode()) {
ensureNoLeaks(allocator.allocator(), true, false);
}
2021-08-29 01:15:51 +02:00
destroyAllocator(allocator);
2021-08-28 22:42:51 +02:00
}
2021-05-02 19:18:15 +02:00
@ParameterizedTest
@MethodSource("provideArgumentsCreate")
public void testCreate(UpdateMode updateMode) {
StepVerifier
2021-09-06 01:15:13 +02:00
.create(tempDb(getTempDbGenerator(), allocator, db -> tempDictionary(db, updateMode)
2021-05-02 19:18:15 +02:00
.flatMap(LLDictionary::clear)
.then()
))
.verifyComplete();
}
}