Skip to content

Commit

Permalink
More clean database shutdown in DefaultDatabaseManager
Browse files Browse the repository at this point in the history
  • Loading branch information
MishaDemianenko committed Aug 9, 2018
1 parent 532d8cb commit 86717ab
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
Expand Up @@ -75,17 +75,22 @@ public GraphDatabaseFacade createDatabase( String name )
}

@Override
public synchronized void shutdownDatabase( String name )
public synchronized void shutdownDatabase( String ignore )
{
if ( database != null )
{
database.shutdown();
}
shutdownDatabase();
}

@Override
public void stop()
{
shutdownDatabase( DatabaseManager.DEFAULT_DATABASE_NAME );
shutdownDatabase();
}

private void shutdownDatabase()
{
if ( database != null )
{
database.shutdown();
}
}
}
Expand Up @@ -19,6 +19,7 @@
*/
package org.neo4j.dmbs.database;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -34,6 +35,7 @@
import org.neo4j.test.extension.TestDirectoryExtension;
import org.neo4j.test.rule.TestDirectory;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;

Expand All @@ -50,6 +52,12 @@ void setUp()
database = new GraphDatabaseFactory().newEmbeddedDatabase( testDirectory.storeDir() );
}

@AfterEach
void tearDown()
{
database.shutdown();
}

@Test
void createDatabase()
{
Expand All @@ -65,6 +73,14 @@ void lookupExistingDatabase()
assertTrue( database.isPresent() );
}

@Test
void shutdownDatabaseOnStop() throws Throwable
{
DatabaseManager databaseManager = getDatabaseManager();
databaseManager.stop();
assertFalse( database.isAvailable( 0 ) );
}

private DatabaseManager getDatabaseManager()
{
return ((GraphDatabaseAPI)database).getDependencyResolver().resolveDependency( DatabaseManager.class );
Expand Down

0 comments on commit 86717ab

Please sign in to comment.