Skip to content

Commit

Permalink
Minor fixes for hard coded things in some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint committed Mar 1, 2016
1 parent 1229da1 commit 795ce2f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
Expand Up @@ -34,6 +34,7 @@
import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.graphdb.factory.GraphDatabaseBuilder;
import org.neo4j.graphdb.factory.GraphDatabaseSettings;
import org.neo4j.index.lucene.LuceneLabelScanStoreBuilder;
import org.neo4j.io.fs.DefaultFileSystemAbstraction;
import org.neo4j.io.fs.FileSystemAbstraction;
Expand Down Expand Up @@ -432,7 +433,12 @@ protected void applyTransaction( Transaction transaction ) throws TransactionFai
private void generateInitialData()
{
GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( directory );
GraphDatabaseAPI graphDb = (GraphDatabaseAPI) builder.newGraphDatabase();
GraphDatabaseAPI graphDb = (GraphDatabaseAPI) builder
// Some tests using this fixture were written when the label_block_size was 60 and so hardcoded
// tests and records around that. Those tests could change, but the simpler option is to just
// keep the block size to 60 and let them be.
.setConfig( GraphDatabaseSettings.label_block_size, "60" )
.newGraphDatabase();
try
{
generateInitialData( graphDb );
Expand Down
Expand Up @@ -152,7 +152,6 @@ private NodeRecord withDynamicLabels( RecordAccessStub recordAccess, NodeRecord
return nodeRecord;
}

@SuppressWarnings("unchecked")
private Engine engineFor( ConsistencyReport.LabelScanConsistencyReport report )
{
Engine engine = mock( Engine.class );
Expand All @@ -162,7 +161,7 @@ private Engine engineFor( ConsistencyReport.LabelScanConsistencyReport report )

private NodeInUseWithCorrectLabelsCheck<LabelScanDocument, ConsistencyReport.LabelScanConsistencyReport> checker( long[] expectedLabels )
{
return new NodeInUseWithCorrectLabelsCheck<LabelScanDocument, ConsistencyReport.LabelScanConsistencyReport>( expectedLabels );
return new NodeInUseWithCorrectLabelsCheck<>( expectedLabels );
}

interface Engine extends CheckerEngine<LabelScanDocument, ConsistencyReport.LabelScanConsistencyReport>
Expand Down
7 changes: 4 additions & 3 deletions community/neo4j/src/test/java/db/DatabaseStartupTest.java
Expand Up @@ -101,10 +101,11 @@ public void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed()
db.shutdown();

// mess up the version in the metadatastore
try ( PageCache pageCache = StandalonePageCacheFactory.createPageCache( new DefaultFileSystemAbstraction() ))
String badStoreVersion = "bad";
try ( PageCache pageCache = StandalonePageCacheFactory.createPageCache( new DefaultFileSystemAbstraction() ) )
{
MetaDataStore.setRecord( pageCache, new File(storeDir, MetaDataStore.DEFAULT_NAME ),
MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( "bad" ));
MetaDataStore.Position.STORE_VERSION, MetaDataStore.versionStringToLong( badStoreVersion ) );
}

// when
Expand All @@ -120,7 +121,7 @@ public void startTheDatabaseWithWrongVersionShouldFailAlsoWhenUpgradeIsAllowed()
assertTrue( ex.getCause() instanceof LifecycleException );
assertTrue( ex.getCause().getCause() instanceof StoreUpgrader.UnexpectedUpgradingStoreVersionException );
assertThat( ex.getCause().getCause().getMessage(),
containsString( "has a store version number that we cannot upgrade from." ) );
containsString( "has a store version '" + badStoreVersion + "' that we cannot upgrade from." ) );
}
}
}
Expand Up @@ -77,7 +77,7 @@ public class CommunityServerBuilder

protected Clock clock = null;
private String[] autoIndexedNodeKeys = null;
private String[] autoIndexedRelationshipKeys = null;
private final String[] autoIndexedRelationshipKeys = null;
private String host = null;
private String[] securityRuleClassNames;
public boolean persistent;
Expand Down Expand Up @@ -117,7 +117,7 @@ protected CommunityNeoServer build( File configFile, Config config,
public File createConfigFiles() throws IOException
{
File temporaryConfigFile = ServerTestUtils.createTempConfigFile();
File temporaryFolder = temporaryConfigFile.getParentFile();
File temporaryFolder = ServerTestUtils.createTempDir();

ServerTestUtils.writeConfigToFile( createConfiguration( temporaryFolder ), temporaryConfigFile );

Expand Down

0 comments on commit 795ce2f

Please sign in to comment.