@SuppressWarnings("unchecked")
 @Test
 public void testIteratorCollectionNotFound() throws Exception {
   set.add(one);
   Iterator<Object> iter = set.iterator();
   dataService.setBinding("iter", new ManagedSerializable(iter));
   newTransaction();
   DoneRemoving.init();
   dataService.removeObject(set);
   endTransaction();
   DoneRemoving.await(1);
   startTransaction();
   iter = (Iterator<Object>) dataService.getBinding("iter", ManagedSerializable.class).get();
   try {
     iter.next();
     fail("Expected ObjectNotFoundException");
   } catch (ObjectNotFoundException e) {
     System.err.println(e);
   }
   try {
     iter.hasNext();
     fail("Expected ObjectNotFoundException");
   } catch (ObjectNotFoundException e) {
     System.err.println(e);
   }
   try {
     iter.remove();
     fail("Expected an exception");
   } catch (ObjectNotFoundException e) {
     System.err.println(e);
   } catch (IllegalStateException e) {
     System.err.println(e);
   }
 }
 @Test
 public void testSize() throws Exception {
   assertEquals(0, set.size());
   set.add(1);
   assertEquals(1, set.size());
   set.add(2);
   assertEquals(2, set.size());
   set.add(2);
   assertEquals(2, set.size());
   DoneRemoving.init();
   set.clear();
   assertEquals(0, set.size());
   endTransaction();
   DoneRemoving.await(1);
 }
 @Test
 public void testClear() throws Exception {
   set.add(1);
   set.add(null);
   DoneRemoving.init();
   set.clear();
   assertTrue(set.isEmpty());
   endTransaction();
   DoneRemoving.await(1);
   startTransaction();
   set.clear();
   assertTrue(set.isEmpty());
   endTransaction();
   DoneRemoving.await(1);
 }
 @Test
 public void testContainsAll() throws Exception {
   try {
     set.containsAll(null);
     fail("Expected NullPointerException");
   } catch (NullPointerException e) {
   }
   Set<Object> other = new HashSet<Object>();
   assertTrue(set.containsAll(other));
   other.add(1);
   assertFalse(set.containsAll(other));
   set.add(null);
   set.add(1);
   assertTrue(set.containsAll(other));
   DoneRemoving.init();
   set.clear();
   assertFalse(set.containsAll(other));
   endTransaction();
   DoneRemoving.await(1);
 }
 @Test
 public void testClearObjectNotFound() throws Exception {
   set.add(one);
   newTransaction();
   dataService.removeObject(one);
   DoneRemoving.init();
   set.clear();
   assertTrue(set.isEmpty());
   one = new Int(1);
   set.add(one);
   endTransaction();
   DoneRemoving.await(1);
   startTransaction();
   dataService.removeObject(one);
   newTransaction();
   set.clear();
   assertTrue(set.isEmpty());
   endTransaction();
   DoneRemoving.await(1);
 }
 @Test
 public void testRemoveObjectSet() throws Exception {
   DoneRemoving.init();
   dataService.removeObject(set);
   set = null;
   endTransaction();
   DoneRemoving.await(1);
   startTransaction();
   int count = getObjectCount();
   set = new ScalableHashSet<Object>();
   newTransaction();
   for (int i = 0; i < 50; i++) {
     set.add(random.nextInt());
   }
   newTransaction();
   dataService.removeObject(set);
   set = null;
   endTransaction();
   DoneRemoving.await(1);
   startTransaction();
   assertEquals(count, getObjectCount());
 }