}
public void test_createCoordination()
{
final String name = "test";
final Coordination c1 = coordinator.create(name, 0);
assertNotNull(c1);
assertEquals(name, c1.getName());
assertNull(coordinator.peek());
assertNull(c1.getFailure());
assertFalse(c1.isTerminated());
assertTrue(c1.getParticipants().isEmpty());
Exception cause = new Exception();
assertTrue(c1.fail(cause));
assertSame(cause, c1.getFailure());
assertTrue(c1.isTerminated());
assertNull(coordinator.peek());
assertFalse(c1.fail(new Exception()));
try
{
c1.end();
fail("Expected CoordinationException.FAILED on end() after fail()");
}
catch (CoordinationException ce)
{
// expected failed
assertEquals(CoordinationException.FAILED, ce.getType());
}
final Coordination c2 = coordinator.create(name, 0);
assertNotNull(c2);
assertEquals(name, c2.getName());
assertNull(coordinator.peek());
assertNull(c2.getFailure());
assertFalse(c2.isTerminated());
assertTrue(c2.getParticipants().isEmpty());
c2.end();
assertNull(c2.getFailure());
assertTrue(c2.isTerminated());
assertNull(coordinator.peek());
assertFalse(c2.fail(new Exception()));
try
{
c2.end();
fail("Expected CoordinationException.ALREADY_ENDED on second end()");
}
catch (CoordinationException ce)
{
// expected already terminated