diff --git a/community/kernel/src/test/java/org/neo4j/graphdb/LabelScanStoreUpdateIT.java b/community/kernel/src/test/java/org/neo4j/graphdb/LabelScanStoreUpdateIT.java index 81f571bcb4983..42513b10e6006 100644 --- a/community/kernel/src/test/java/org/neo4j/graphdb/LabelScanStoreUpdateIT.java +++ b/community/kernel/src/test/java/org/neo4j/graphdb/LabelScanStoreUpdateIT.java @@ -20,7 +20,6 @@ package org.neo4j.graphdb; import org.junit.Before; -import org.junit.ClassRule; import org.hamcrest.Matchers; import org.junit.Rule; import org.junit.Test; @@ -31,10 +30,6 @@ import org.neo4j.helpers.collection.Iterables; import org.neo4j.helpers.collection.Iterators; -import org.neo4j.kernel.internal.GraphDatabaseAPI; -import org.neo4j.test.rule.DatabaseRule; -import org.neo4j.test.rule.ImpermanentDatabaseRule; - import static org.hamcrest.CoreMatchers.equalTo; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThat; @@ -43,11 +38,8 @@ import static org.neo4j.helpers.collection.Iterators.emptySetOf; import static org.neo4j.helpers.collection.Iterators.single; -public class LabelScanStoreUpdateIT +public abstract class LabelScanStoreUpdateIT { - @ClassRule - public static final DatabaseRule dbRule = new ImpermanentDatabaseRule(); - @Rule public final TestName testName = new TestName(); @@ -178,7 +170,7 @@ public void retrieveNodeIdsInAscendingOrder() public void shouldHandleLargeAmountsOfNodesAddedAndRemovedInSameTx() throws Exception { // Given - GraphDatabaseAPI db = dbRule.getGraphDatabaseAPI(); + GraphDatabaseService db = db(); int labelsToAdd = 80; int labelsToRemove = 40; @@ -216,11 +208,13 @@ public void shouldHandleLargeAmountsOfNodesAddedAndRemovedInSameTx() throws Exce } } + protected abstract GraphDatabaseService db(); + private void verifyFoundNodes( Label label, String sizeMismatchMessage, long... expectedNodeIds ) { - try ( Transaction ignored = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction ignored = db().beginTx() ) { - ResourceIterator nodes = dbRule.getGraphDatabaseAPI().findNodes( label ); + ResourceIterator nodes = db().findNodes( label ); List nodeList = Iterators.asList( nodes ); assertThat( sizeMismatchMessage, nodeList, Matchers.hasSize( expectedNodeIds.length ) ); int index = 0; @@ -233,7 +227,7 @@ private void verifyFoundNodes( Label label, String sizeMismatchMessage, long... private void removeLabels( Node node, Label... labels ) { - try ( Transaction tx = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction tx = db().beginTx() ) { for ( Label label : labels ) { @@ -245,7 +239,7 @@ private void removeLabels( Node node, Label... labels ) private void deleteNode( Node node ) { - try ( Transaction tx = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction tx = db().beginTx() ) { node.delete(); tx.success(); @@ -254,17 +248,17 @@ private void deleteNode( Node node ) private Set getAllNodesWithLabel( Label label ) { - try ( Transaction tx = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction tx = db().beginTx() ) { - return asSet( dbRule.getGraphDatabaseAPI().findNodes( label ) ); + return asSet( db().findNodes( label ) ); } } private Node createLabeledNode( Label... labels ) { - try ( Transaction tx = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction tx = db().beginTx() ) { - Node node = dbRule.getGraphDatabaseAPI().createNode( labels ); + Node node = db().createNode( labels ); tx.success(); return node; } @@ -272,7 +266,7 @@ private Node createLabeledNode( Label... labels ) private void addLabels( Node node, Label... labels ) { - try ( Transaction tx = dbRule.getGraphDatabaseAPI().beginTx() ) + try ( Transaction tx = db().beginTx() ) { for ( Label label : labels ) { @@ -284,9 +278,9 @@ private void addLabels( Node node, Label... labels ) private Node getNodeById(long id) { - try (Transaction ignored = dbRule.beginTx()) + try (Transaction ignored = db().beginTx()) { - return dbRule.getNodeById( id ); + return db().getNodeById( id ); } } diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStoreUpdateIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStoreUpdateIT.java new file mode 100644 index 0000000000000..de5e897d58d64 --- /dev/null +++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/index/labelscan/NativeLabelScanStoreUpdateIT.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.kernel.impl.index.labelscan; + +import org.junit.ClassRule; + +import org.neo4j.graphdb.GraphDatabaseService; +import org.neo4j.graphdb.LabelScanStoreUpdateIT; +import org.neo4j.graphdb.factory.GraphDatabaseBuilder; +import org.neo4j.kernel.impl.api.scan.NativeLabelScanStoreExtension; +import org.neo4j.test.rule.DatabaseRule; +import org.neo4j.test.rule.ImpermanentDatabaseRule; + +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.label_scan_store; + +public class NativeLabelScanStoreUpdateIT extends LabelScanStoreUpdateIT +{ + @ClassRule + public static final DatabaseRule dbRule = new ImpermanentDatabaseRule() + { + @Override + protected void configure( GraphDatabaseBuilder builder ) + { + builder.setConfig( label_scan_store, NativeLabelScanStoreExtension.LABEL_SCAN_STORE_NAME ); + } + }; + + @Override + protected GraphDatabaseService db() + { + return dbRule; + } +} diff --git a/community/lucene-index/src/test/java/org/neo4j/graphdb/LuceneLabelScanStoreUpdateIT.java b/community/lucene-index/src/test/java/org/neo4j/graphdb/LuceneLabelScanStoreUpdateIT.java new file mode 100644 index 0000000000000..f27a6eed493ab --- /dev/null +++ b/community/lucene-index/src/test/java/org/neo4j/graphdb/LuceneLabelScanStoreUpdateIT.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2002-2017 "Neo Technology," + * Network Engine for Objects in Lund AB [http://neotechnology.com] + * + * This file is part of Neo4j. + * + * Neo4j is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package org.neo4j.graphdb; + +import org.junit.ClassRule; + +import org.neo4j.graphdb.factory.GraphDatabaseBuilder; +import org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStoreExtension; +import org.neo4j.test.rule.DatabaseRule; +import org.neo4j.test.rule.ImpermanentDatabaseRule; + +import static org.neo4j.graphdb.factory.GraphDatabaseSettings.label_scan_store; + +public class LuceneLabelScanStoreUpdateIT extends LabelScanStoreUpdateIT +{ + @ClassRule + public static final DatabaseRule dbRule = new ImpermanentDatabaseRule() + { + @Override + protected void configure( GraphDatabaseBuilder builder ) + { + builder.setConfig( label_scan_store, LuceneLabelScanStoreExtension.LABEL_SCAN_STORE_NAME ); + } + }; + + @Override + protected GraphDatabaseService db() + { + return dbRule; + } +}