Inventory { public void add(long record) { long stamp = lock.writeLock(); try { if(bitSet.set(record)) { dirty.add(record); } } finally { lock.unlockWrite(stamp); } } private  Inventory(String backingStore); static Inventory create(String backingStore); void add(long record); boolean contains(long record); Set<Long> getAll(); void sync();  }
@Test public void testAdd() { int count = TestData.getScaleCount() * TestData.getScaleCount(); Set<Long> longs = Sets.newHashSet(); while (longs.size() < count) { longs.add(TestData.getLong()); } for (long l : longs) { inventory.add(l); Assert.assertTrue(inventory.contains(l)); } }