Skip to content

Commit

Permalink
Fixes unit test for shutdown check change
Browse files Browse the repository at this point in the history
  • Loading branch information
tinwelint authored and ragadeeshu committed Jun 14, 2017
1 parent d9591bd commit 8d2efa7
Showing 1 changed file with 14 additions and 6 deletions.
Expand Up @@ -34,7 +34,6 @@
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReferenceArray; import java.util.concurrent.atomic.AtomicReferenceArray;


import org.neo4j.graphdb.DatabaseShutdownException;
import org.neo4j.graphdb.security.AuthorizationExpiredException; import org.neo4j.graphdb.security.AuthorizationExpiredException;
import org.neo4j.kernel.AvailabilityGuard; import org.neo4j.kernel.AvailabilityGuard;
import org.neo4j.kernel.api.KernelTransaction; import org.neo4j.kernel.api.KernelTransaction;
Expand Down Expand Up @@ -73,8 +72,6 @@
import org.neo4j.test.Race; import org.neo4j.test.Race;
import org.neo4j.test.rule.concurrent.OtherThreadRule; import org.neo4j.test.rule.concurrent.OtherThreadRule;


import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.locks.LockSupport.parkNanos;
import static org.hamcrest.CoreMatchers.equalTo; import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.instanceOf; import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is; import static org.hamcrest.CoreMatchers.is;
Expand All @@ -94,6 +91,10 @@
import static org.mockito.Mockito.mock; import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify; import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when; import static org.mockito.Mockito.when;

import static java.util.concurrent.TimeUnit.MILLISECONDS;
import static java.util.concurrent.locks.LockSupport.parkNanos;

import static org.neo4j.helpers.collection.Iterators.asSet; import static org.neo4j.helpers.collection.Iterators.asSet;
import static org.neo4j.kernel.api.KernelTransaction.Type.explicit; import static org.neo4j.kernel.api.KernelTransaction.Type.explicit;
import static org.neo4j.kernel.api.security.SecurityContext.AUTH_DISABLED; import static org.neo4j.kernel.api.security.SecurityContext.AUTH_DISABLED;
Expand Down Expand Up @@ -410,15 +411,22 @@ public void shouldNotLeakTransactionOnSecurityContextFreezeFailure() throws Thro
} }


@Test @Test
public void exceptionWhenStartingNewTransactionOnShutdownInstance() throws Throwable public void shouldStartNewTransactionAfterGuardMarkedAsShutdown() throws Throwable
{ {
// This is because the first thing thast happens when shutting down is that AvailabilityGuard gets
// marked as shut down. After that, transactions that just made it passed some layers in db.beginTx()
// or similar will have time to complete (other parts of shutdown will take care of that).

KernelTransactions kernelTransactions = newKernelTransactions(); KernelTransactions kernelTransactions = newKernelTransactions();
SecurityContext securityContext = mock( SecurityContext.class ); SecurityContext securityContext = mock( SecurityContext.class );


availabilityGuard.shutdown(); availabilityGuard.shutdown();


expectedException.expect( DatabaseShutdownException.class ); try ( KernelTransaction transaction =
kernelTransactions.newInstance( KernelTransaction.Type.explicit, securityContext, 0L ); kernelTransactions.newInstance( KernelTransaction.Type.explicit, securityContext, 0L ) )
{
assertNotNull( transaction );
}
} }


@Test @Test
Expand Down

0 comments on commit 8d2efa7

Please sign in to comment.