Skip to content

Commit

Permalink
Fix and expand on unavailable test
Browse files Browse the repository at this point in the history
  • Loading branch information
martinfurmanski committed Jul 8, 2017
1 parent dc0f25b commit 9bb465b
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
Expand Up @@ -54,7 +54,7 @@ public void assertDatabaseAvailable()
{ {
throw new DatabaseShutdownException(); throw new DatabaseShutdownException();
} }
throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage() ); throw new org.neo4j.graphdb.TransactionFailureException( e.getMessage(), e );
} }
} }
} }
Expand Up @@ -28,6 +28,7 @@
import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.AvailabilityGuard; import org.neo4j.kernel.AvailabilityGuard;
import org.neo4j.kernel.api.exceptions.Status; import org.neo4j.kernel.api.exceptions.Status;
import org.neo4j.kernel.internal.GraphDatabaseAPI;
import org.neo4j.test.causalclustering.ClusterRule; import org.neo4j.test.causalclustering.ClusterRule;


import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
Expand All @@ -47,7 +48,7 @@ public void setup() throws Exception
} }


@Test @Test
public void shouldReturnUnavailableStatus() throws Exception public void shouldReturnUnavailableStatusWhenDoingLongOperation() throws Exception
{ {
// given // given
ClusterMember member = cluster.getCoreMemberById( 1 ); ClusterMember member = cluster.getCoreMemberById( 1 );
Expand All @@ -68,6 +69,28 @@ public void shouldReturnUnavailableStatus() throws Exception
} }
} }


@Test
public void shouldReturnUnavailableStatusWhenShutdown() throws Exception
{
// given
ClusterMember member = cluster.getCoreMemberById( 1 );

// when
GraphDatabaseAPI db = member.database();
member.shutdown();

// then
try ( Transaction tx = db.beginTx() )
{
tx.success();
fail();
}
catch ( Exception e )
{
assertEquals( Status.General.DatabaseUnavailable, statusCodeOf( e ) );
}
}

private Status statusCodeOf( Throwable e ) private Status statusCodeOf( Throwable e )
{ {
do do
Expand Down

0 comments on commit 9bb465b

Please sign in to comment.