Skip to content

Commit

Permalink
Improve expected exception assertions in SlaveLocksClientTest
Browse files Browse the repository at this point in the history
  • Loading branch information
lutovich committed Jul 13, 2016
1 parent 7da6d6c commit 3a03f89
Showing 1 changed file with 101 additions and 21 deletions.
Expand Up @@ -317,64 +317,144 @@ public void shouldFailWithTransientErrorOnDbUnavailable() throws Exception
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void acquireSharedFailsWhenClientStopped()
{
stoppedClient().acquireShared( NODE, 1 );
SlaveLocksClient client = stoppedClient();
try
{
client.acquireShared( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void releaseSharedFailsWhenClientStopped()
{
stoppedClient().releaseShared( NODE, 1 );
SlaveLocksClient client = stoppedClient();
try
{
client.releaseShared( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void acquireExclusiveFailsWhenClientStopped()
{
stoppedClient().acquireExclusive( NODE, 1 );
SlaveLocksClient client = stoppedClient();
try
{
client.acquireExclusive( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void releaseExclusiveFailsWhenClientStopped()
{
stoppedClient().releaseExclusive( NODE, 1 );
SlaveLocksClient client = stoppedClient();
try
{
client.releaseExclusive( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void getLockSessionIdWhenClientStopped()
{
stoppedClient().getLockSessionId();
SlaveLocksClient client = stoppedClient();
try
{
client.getLockSessionId();
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void acquireSharedFailsWhenClientClosed()
{
closedClient().acquireShared( NODE, 1 );
SlaveLocksClient client = closedClient();
try
{
client.acquireShared( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void releaseSharedFailsWhenClientClosed()
{
closedClient().releaseShared( NODE, 1 );
SlaveLocksClient client = closedClient();
try
{
client.releaseShared( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void acquireExclusiveFailsWhenClientClosed()
{
closedClient().acquireExclusive( NODE, 1 );
SlaveLocksClient client = closedClient();
try
{
client.acquireExclusive( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void releaseExclusiveFailsWhenClientClosed()
{
closedClient().releaseExclusive( NODE, 1 );
SlaveLocksClient client = closedClient();
try
{
client.releaseExclusive( NODE, 1 );
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test( expected = LockClientStoppedException.class )
@Test
public void getLockSessionIdWhenClientClosed()
{
closedClient().getLockSessionId();
SlaveLocksClient client = closedClient();
try
{
client.getLockSessionId();
}
catch ( Exception e )
{
assertThat( e, instanceOf( LockClientStoppedException.class ) );
}
}

@Test
Expand Down Expand Up @@ -480,8 +560,8 @@ private SlaveLocksClient stoppedClient()

private SlaveLocksClient closedClient()
{
client.close();
client.acquireShared( NODE, 1 ); // trigger new lock session initialization
client.close();
return client;
}
}

0 comments on commit 3a03f89

Please sign in to comment.