use of org.junit.jupiter.params.provider.EnumSource in project neo4j by neo4j.
the class SingleInstanceGetRoutingTableProcedureTest method shouldThrowIfClientProvidedPortIsNotANumber.
@ParameterizedTest
@EnumSource(value = RoutingMode.class)
void shouldThrowIfClientProvidedPortIsNotANumber(RoutingMode routingMode) {
// given
var advertisedBoldPort = 8776;
var clientProvidedPort = "bolt";
var advertisedBoltAddress = new SocketAddress("neo4j.com", advertisedBoldPort);
var clientProvidedHostPortStr = String.format("%s:%s", "my.neo4j-service.com", clientProvidedPort);
var ctxContents = new MapValueBuilder();
ctxContents.add(ADDRESS_CONTEXT_KEY, Values.stringValue(clientProvidedHostPortStr));
var ctx = ctxContents.build();
var portRegister = mock(ConnectorPortRegister.class);
when(portRegister.getLocalAddress(BoltConnector.NAME)).thenReturn(new HostnamePort("neo4j.com", advertisedBoldPort));
var config = newConfig(Config.defaults(SERVER_DEFAULTS), Duration.ofSeconds(100), advertisedBoltAddress);
config.set(routing_default_router, routingMode);
var databaseManager = databaseManagerMock(config, true);
var logProvider = new AssertableLogProvider();
var procedure = newProcedure(databaseManager, portRegister, config, logProvider);
var expectedMessage = "An address key is included in the query string provided to the GetRoutingTableProcedure, but its value could not be parsed.";
// when
assertThrows(ProcedureException.class, () -> invoke(procedure, ID, ctx), expectedMessage);
}
use of org.junit.jupiter.params.provider.EnumSource in project neo4j by neo4j.
the class TestRecoveryScenarios method shouldRecoverTransactionWhereNodeIsDeletedInTheFuture.
@ParameterizedTest
@EnumSource(FlushStrategy.class)
void shouldRecoverTransactionWhereNodeIsDeletedInTheFuture(FlushStrategy strategy) throws Exception {
// GIVEN
Node node = createNodeWithProperty("key", "value", label);
checkPoint();
setProperty(node, "other-key", 1);
deleteNode(node);
strategy.flush(db);
// WHEN
crashAndRestart();
// -- really the problem was that recovery threw exception, so mostly assert that.
try (Transaction tx = db.beginTx()) {
node = tx.getNodeById(node.getId());
tx.commit();
fail("Should not exist");
} catch (NotFoundException e) {
assertEquals("Node " + node.getId() + " not found", e.getMessage());
}
}
use of org.junit.jupiter.params.provider.EnumSource in project neo4j by neo4j.
the class TokenIndexAccessorTest method readerShouldFindManyWithOtherTokens.
@ParameterizedTest
@EnumSource(IndexOrder.class)
void readerShouldFindManyWithOtherTokens(IndexOrder indexOrder) throws Exception {
// Given
int tokenId = 1;
long[] entityIds = new long[] { 1, 2, 3, 64, 65, 1000, 2001 };
long[] otherEntityIds = new long[] { 1, 2, 4, 64, 66, 1000, 2000 };
addToIndex(tokenId, entityIds);
addToIndex(2, otherEntityIds);
LongList expectedIds = LongLists.immutable.of(entityIds);
// When
assertReaderFindsExpected(indexOrder, tokenId, expectedIds);
}
use of org.junit.jupiter.params.provider.EnumSource in project neo4j by neo4j.
the class EntityCommandGrouperTest method shouldSeeSingleGroupOfPropertiesWithoutEntity.
@ParameterizedTest
@EnumSource(Factory.class)
void shouldSeeSingleGroupOfPropertiesWithoutEntity(Factory factory) {
// given
EntityCommandGrouper grouper = new EntityCommandGrouper<>(factory.command(0).getClass(), 8);
long entityId = 1;
BaseCommand<? extends PrimitiveRecord> entity = factory.command(entityId);
PropertyCommand property1 = property(entity.getAfter());
PropertyCommand property2 = property(entity.getAfter());
// intentionally DO NOT add the entity command
grouper.add(property1);
grouper.add(property2);
EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
// when/then
assertGroups(cursor, group(entityId, null, property1, property2));
}
use of org.junit.jupiter.params.provider.EnumSource in project neo4j by neo4j.
the class EntityCommandGrouperTest method shouldSeeMultipleGroupsSomeOfThemWithEntity.
@ParameterizedTest
@EnumSource(Factory.class)
void shouldSeeMultipleGroupsSomeOfThemWithEntity(Factory factory) {
// given
EntityCommandGrouper grouper = new EntityCommandGrouper<>(factory.command(0).getClass(), 64);
Group[] groups = new Group[random.nextInt(10, 30)];
for (int entityId = 0; entityId < groups.length; entityId++) {
BaseCommand entityCommand = random.nextBoolean() ? factory.command(entityId) : null;
groups[entityId] = new Group(entityId, entityCommand);
if (entityCommand != null) {
// <-- storage transaction logs are sorted such that entity commands comes before property commands
grouper.add(entityCommand);
}
}
int totalNumberOfProperties = random.nextInt(10, 100);
for (int i = 0; i < totalNumberOfProperties; i++) {
int entityId = random.nextInt(groups.length);
PropertyCommand property = property(factory.command(entityId).getAfter());
groups[entityId].addProperty(property);
grouper.add(property);
}
// ^^^ OK so we've generated property commands for random entities in random order, let's sort them
EntityCommandGrouper.Cursor cursor = grouper.sortAndAccessGroups();
// then
assertGroups(cursor, groups);
}
Aggregations