Search in sources :

Example 66 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class DefaultSchemaIndexConfigTest method indexShouldHaveIndexConfig.

@ParameterizedTest
@MethodSource("providers")
void indexShouldHaveIndexConfig(GraphDatabaseSettings.SchemaIndex provider) throws IndexNotFoundKernelException {
    DatabaseManagementServiceBuilder databaseManagementServiceBuilder = dbBuilder.setConfig(default_schema_provider, provider == null ? null : provider.providerName());
    DatabaseManagementService managementService = databaseManagementServiceBuilder.build();
    GraphDatabaseService db = managementService.database(DEFAULT_DATABASE_NAME);
    try {
        // when
        createIndex(db);
        // then
        validateIndexConfig(db);
    } finally {
        managementService.shutdown();
    }
    managementService = databaseManagementServiceBuilder.build();
    db = managementService.database(DEFAULT_DATABASE_NAME);
    try {
        validateIndexConfig(db);
    } finally {
        managementService.shutdown();
    }
}
Also used : GraphDatabaseService(org.neo4j.graphdb.GraphDatabaseService) TestDatabaseManagementServiceBuilder(org.neo4j.test.TestDatabaseManagementServiceBuilder) DatabaseManagementServiceBuilder(org.neo4j.dbms.api.DatabaseManagementServiceBuilder) DatabaseManagementService(org.neo4j.dbms.api.DatabaseManagementService) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 67 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class MultipleOpenCursorsTest method multipleIteratorsNestedInterleavedExact.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInterleavedExact(IndexCoordinator indexCoordinator) throws Exception {
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryExact(ktx)) {
            List<Long> actual1 = new ArrayList<>();
            try (NodeValueIndexCursor cursor2 = indexCoordinator.queryExact(ktx)) {
                List<Long> actual2 = new ArrayList<>();
                // Interleave
                exhaustInterleaved(cursor1, actual1, cursor2, actual2);
                // then
                indexCoordinator.assertExactResult(actual1);
                indexCoordinator.assertExactResult(actual2);
            }
        }
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NodeValueIndexCursor(org.neo4j.internal.kernel.api.NodeValueIndexCursor) ArrayList(java.util.ArrayList) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 68 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class UniqueIndexApplicationIT method tx_createNode_addLabel_tx_setProperty.

@ParameterizedTest
@MethodSource("indexTypes")
void tx_createNode_addLabel_tx_setProperty(Function<Transaction, Void> createIndexFunc) {
    createIndex(createIndexFunc);
    Node node;
    try (var transaction = db.beginTx()) {
        node = transaction.createNode();
        node.addLabel(label("Label1"));
        transaction.commit();
    }
    try (var transaction = db.beginTx()) {
        transaction.getNodeById(node.getId()).setProperty("key1", "value1");
        transaction.commit();
    }
}
Also used : Node(org.neo4j.graphdb.Node) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 69 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class UniqueIndexApplicationIT method tx_createNode_tx_addLabel_tx_setProperty.

@ParameterizedTest
@MethodSource("indexTypes")
void tx_createNode_tx_addLabel_tx_setProperty(Function<Transaction, Void> createIndexFunc) {
    createIndex(createIndexFunc);
    Node node;
    try (var transaction = db.beginTx()) {
        node = transaction.createNode();
        transaction.commit();
    }
    try (var transaction = db.beginTx()) {
        transaction.getNodeById(node.getId()).addLabel(label("Label1"));
        transaction.commit();
    }
    try (var transaction = db.beginTx()) {
        transaction.getNodeById(node.getId()).setProperty("key1", "value1");
        transaction.commit();
    }
}
Also used : Node(org.neo4j.graphdb.Node) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 70 with MethodSource

use of org.junit.jupiter.params.provider.MethodSource in project neo4j by neo4j.

the class MultipleOpenCursorsTest method multipleIteratorsNestedInterleavedRange.

@ParameterizedTest
@MethodSource(value = "params")
void multipleIteratorsNestedInterleavedRange(IndexCoordinator indexCoordinator) throws Exception {
    assumeTrue(indexCoordinator.supportRangeQuery());
    indexCoordinator.init(db);
    try (Transaction tx = db.beginTx()) {
        // when
        KernelTransaction ktx = ((InternalTransaction) tx).kernelTransaction();
        try (NodeValueIndexCursor cursor1 = indexCoordinator.queryRange(ktx);
            NodeValueIndexCursor cursor2 = indexCoordinator.queryRange(ktx)) {
            List<Long> actual1 = new ArrayList<>();
            List<Long> actual2 = new ArrayList<>();
            // Interleave
            exhaustInterleaved(cursor1, actual1, cursor2, actual2);
            // then
            indexCoordinator.assertRangeResult(actual1);
            indexCoordinator.assertRangeResult(actual2);
        }
        tx.commit();
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) NodeValueIndexCursor(org.neo4j.internal.kernel.api.NodeValueIndexCursor) ArrayList(java.util.ArrayList) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Aggregations

MethodSource (org.junit.jupiter.params.provider.MethodSource)1199 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)1184 Transaction (org.neo4j.graphdb.Transaction)103 Stream (java.util.stream.Stream)70 Test (org.junit.jupiter.api.Test)67 ArrayList (java.util.ArrayList)63 InterruptAfter (io.aeron.test.InterruptAfter)60 List (java.util.List)60 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)58 TimeUnit (java.util.concurrent.TimeUnit)54 IOException (java.io.IOException)52 CountDownLatch (java.util.concurrent.CountDownLatch)52 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)52 lombok.val (lombok.val)52 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)51 Arguments (org.junit.jupiter.params.provider.Arguments)47 AfterEach (org.junit.jupiter.api.AfterEach)46 SSLEngine (javax.net.ssl.SSLEngine)44 AtomicReference (java.util.concurrent.atomic.AtomicReference)43 Path (java.nio.file.Path)42