Skip to content

Commit

Permalink
Abstract LabelScanStoreStartupIT, implemented by Lucene
Browse files Browse the repository at this point in the history
LuceneLabelScanStoreStartupIT extends abstract LabelScanStoreStartupIT
and assert that Lucene is used.
Other LabelScanStore implementations should also use LabelScanStoreStartupIT

Set more specific name for
LabelScanStoreIT -> LabelScanStoreUpdateIT
  • Loading branch information
burqen committed Dec 27, 2016
1 parent e8f2c32 commit b98ec8d
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
Expand Up @@ -45,7 +45,7 @@
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

public class LuceneLabelScanStoreIT
public abstract class LabelScanStoreStartupIT
{
@Rule
public final DatabaseRule dbRule = new EmbeddedDatabaseRule( getClass() );
Expand All @@ -54,7 +54,7 @@ public class LuceneLabelScanStoreIT
public void scanStoreStartWithoutExistentIndex() throws IOException
{
NeoStoreDataSource dataSource = getDataSource();
LabelScanStore labelScanStore = getLabelScanStore();
LabelScanStore labelScanStore = getLabelScanStore( dbRule );
labelScanStore.shutdown();

File labelScanStoreDirectory = getLabelScanStoreDirectory( dataSource );
Expand All @@ -70,7 +70,7 @@ public void scanStoreStartWithoutExistentIndex() throws IOException
public void scanStoreRecreateCorruptedIndexOnStartup() throws IOException
{
NeoStoreDataSource dataSource = getDataSource();
LabelScanStore labelScanStore = getLabelScanStore();
LabelScanStore labelScanStore = getLabelScanStore( dbRule );

Node node = createTestNode();
long[] labels = readNodeLabels( labelScanStore, node );
Expand All @@ -97,7 +97,7 @@ private long[] readNodeLabels( LabelScanStore labelScanStore, Node node )

private Node createTestNode()
{
Node node = null;
Node node;
try (Transaction transaction = dbRule.beginTx())
{
node = dbRule.createNode( Label.label( "testLabel" ));
Expand Down Expand Up @@ -132,11 +132,7 @@ private NeoStoreDataSource getDataSource()
return dataSourceManager.getDataSource();
}

private LabelScanStore getLabelScanStore()
{
DependencyResolver dependencyResolver = dbRule.getDependencyResolver();
return dependencyResolver.resolveDependency( LabelScanStore.class );
}
protected abstract LabelScanStore getLabelScanStore( DatabaseRule dbRule );

private void checkLabelScanStoreAccessible( LabelScanStore labelScanStore ) throws IOException
{
Expand Down
Expand Up @@ -43,7 +43,7 @@
import static org.neo4j.helpers.collection.Iterators.emptySetOf;
import static org.neo4j.helpers.collection.Iterators.single;

public class LabelScanStoreIT
public class LabelScanStoreUpdateIT
{
@ClassRule
public static final DatabaseRule dbRule = new ImpermanentDatabaseRule();
Expand Down
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2002-2016 "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 <http://www.gnu.org/licenses/>.
*/
package org.neo4j.graphdb;

import org.neo4j.kernel.api.impl.labelscan.LuceneLabelScanStore;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.test.rule.DatabaseRule;

import static org.hamcrest.Matchers.instanceOf;
import static org.junit.Assert.assertThat;

public class LuceneLabelScanStoreStartupIT extends LabelScanStoreStartupIT
{
@Override
protected LabelScanStore getLabelScanStore( DatabaseRule dbRule )
{
DependencyResolver dependencyResolver = dbRule.getDependencyResolver();
LabelScanStore labelScanStore = dependencyResolver.resolveDependency( LabelScanStore.class );
assertThat( labelScanStore, instanceOf( LuceneLabelScanStore.class ) );
return labelScanStore;
}
}

0 comments on commit b98ec8d

Please sign in to comment.