### Question:
BarrierIdentityGenerator implements BarrierIdentity.Factory { @Override public BarrierIdentity next() { return new BarrierIdentityImplementation(m_scope, m_next.getAndIncrement()); } BarrierIdentityGenerator(Serializable scope); @Override BarrierIdentity next();  }### Answer:
@Test public void testIdentityGeneration() { final BarrierIdentityGenerator generator = new BarrierIdentityGenerator(new Integer(1)); final BarrierIdentity one = generator.next(); final BarrierIdentity two = generator.next(); assertNotEquals(one, two); }
@Test public void testIdentityIsSerializable() throws Exception { final BarrierIdentityGenerator generator = new BarrierIdentityGenerator(new Integer(1)); final BarrierIdentity id = generator.next(); final BarrierIdentity serializedID = serialize(id); assertEquals(id, serializedID); }
@Test public void testIdentityEquality() throws Exception { final BarrierIdentityGenerator generator = new BarrierIdentityGenerator(new Integer(1)); final BarrierIdentity one = generator.next(); final BarrierIdentity two = generator.next(); assertEquals(one, one); assertEquals(one.hashCode(), one.hashCode()); assertNotEquals(one, two); assertNotEquals(one, this); assertNotEquals(one, null); }