use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.
the class IndexTransactionStateTestBase method shouldPerformStringSuffixSearch.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringSuffixSearch(boolean needsValues) throws Exception {
// given
Set<Pair<Long, Value>> expected = new HashSet<>();
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithProp(tx, "1suff"));
entityWithProp(tx, "pluff");
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
expected.add(entityWithProp(tx, "2suff"));
entityWithPropId(tx, "skruff");
IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
assertEntityAndValueForSeek(expected, tx, index, needsValues, "pasuff", PropertyIndexQuery.stringSuffix(prop, stringValue("suff")));
}
}
use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.
the class IndexTransactionStateTestBase method shouldPerformStringContainsSearch.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
void shouldPerformStringContainsSearch(boolean needsValues) throws Exception {
// given
Set<Pair<Long, Value>> expected = new HashSet<>();
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithProp(tx, "gnomebat"));
entityWithPropId(tx, "fishwombat");
tx.commit();
}
createIndex();
// when
try (KernelTransaction tx = beginTransaction()) {
expected.add(entityWithProp(tx, "homeopatic"));
entityWithPropId(tx, "telephonecompany");
IndexDescriptor index = tx.schemaRead().indexGetForName(INDEX_NAME);
int prop = tx.tokenRead().propertyKey(DEFAULT_PROPERTY_NAME);
assertEntityAndValueForSeek(expected, tx, index, needsValues, "immense", PropertyIndexQuery.stringContains(prop, stringValue("me")));
}
}
use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.
the class DuplicatingLogTest method shouldOutputToMultipleLogs.
@ParameterizedTest
@ValueSource(strings = { "debug", "info", "warn", "error" })
void shouldOutputToMultipleLogs(String type) throws Exception {
// Given
DuplicatingLog log = new DuplicatingLog(log1, log2);
Method m = Log.class.getMethod(type, String.class);
// When
m.invoke(log, "When the going gets weird");
// Then
m.invoke(verify(log1), "When the going gets weird");
m.invoke(verify(log2), "When the going gets weird");
verifyNoMoreInteractions(log1);
verifyNoMoreInteractions(log2);
}
use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.
the class LatchMapTest method takeOrAwaitLatchMustAwaitExistingLatchAndReturnNull.
@ValueSource(ints = { LatchMap.DEFAULT_FAULT_LOCK_STRIPING, 1 << 10, 1 << 11 })
@ParameterizedTest
void takeOrAwaitLatchMustAwaitExistingLatchAndReturnNull(int size) throws Exception {
LatchMap latches = new LatchMap(size);
AtomicReference<Thread> threadRef = new AtomicReference<>();
BinaryLatch latch = latches.takeOrAwaitLatch(42);
assertThat(latch).isNotNull();
ExecutorService executor = null;
try {
executor = Executors.newSingleThreadExecutor();
Future<BinaryLatch> future = executor.submit(() -> {
threadRef.set(Thread.currentThread());
return latches.takeOrAwaitLatch(42);
});
Thread th;
do {
th = threadRef.get();
} while (th == null);
ThreadTestUtils.awaitThreadState(th, 10_000, Thread.State.WAITING);
latch.release();
assertThat(future.get(1, TimeUnit.SECONDS)).isNull();
} finally {
if (executor != null) {
executor.shutdown();
}
}
}
use of org.junit.jupiter.params.provider.ValueSource in project neo4j by neo4j.
the class LatchMapTest method takeOrAwaitLatchMustReturnLatchIfAvailable.
@ValueSource(ints = { LatchMap.DEFAULT_FAULT_LOCK_STRIPING, 1 << 10, 1 << 11 })
@ParameterizedTest
void takeOrAwaitLatchMustReturnLatchIfAvailable(int size) {
LatchMap latches = new LatchMap(size);
BinaryLatch latch = latches.takeOrAwaitLatch(0);
assertThat(latch).isNotNull();
latch.release();
}
Aggregations