Esempio n. 1
0
 /**
  * Test that an iterator created with the specified prefix on a service with the specified names,
  * which should result in an iteration that returns two names, responds properly to the remove
  * method.
  */
 private void testRemoveTwoElements(String prefix, String... names) {
   List<String> list = Arrays.asList(names);
   service.clear();
   service.addAll(list);
   List<String> matchingNames = new ArrayList<String>();
   for (String name : BoundNamesUtil.getServiceBoundNamesIterable(service, prefix)) {
     matchingNames.add(name);
   }
   Iterator<String> iter = BoundNamesUtil.getServiceBoundNamesIterator(service, prefix);
   assertRemoveFails(iter);
   /* Remove first */
   iter.next();
   iter.remove();
   assertRemoveFails(iter);
   assertContents(
       BoundNamesUtil.getServiceBoundNamesIterator(service, prefix), matchingNames.get(1));
   /* Also remove second */
   iter.next();
   iter.remove();
   assertRemoveFails(iter);
   assertContents(BoundNamesUtil.getServiceBoundNamesIterator(service, prefix));
   service.clear();
   service.addAll(list);
   iter = BoundNamesUtil.getServiceBoundNamesIterator(service, prefix);
   /* Just remove second */
   iter.next();
   iter.next();
   assertNextFails(iter);
   iter.remove();
   assertRemoveFails(iter);
   assertContents(
       BoundNamesUtil.getServiceBoundNamesIterator(service, prefix), matchingNames.get(0));
 }
Esempio n. 2
0
 /**
  * Test that an iterator created with the specified prefix on a service with the specified names,
  * which should result in an iteration that returns no names, responds properly to the remove
  * method.
  */
 private void testRemoveEmpty(String prefix, String... names) {
   List<String> list = Arrays.asList(names);
   service.clear();
   service.addAll(list);
   Iterator<String> iter = BoundNamesUtil.getServiceBoundNamesIterator(service, prefix);
   assertRemoveFails(iter);
   assertNextFails(iter);
   assertRemoveFails(iter);
 }
Esempio n. 3
0
 /**
  * Test that an iterator created with the specified prefix on a service with the specified names,
  * which should result in an iteration that returns one name, responds properly to the remove
  * method.
  */
 private void testRemoveOneElement(String prefix, String... names) {
   List<String> list = Arrays.asList(names);
   service.clear();
   service.addAll(list);
   Iterator<String> iter = BoundNamesUtil.getServiceBoundNamesIterator(service, prefix);
   assertRemoveFails(iter);
   iter.next();
   assertNextFails(iter);
   iter.remove();
   assertRemoveFails(iter);
   assertNextFails(iter);
   assertContents(BoundNamesUtil.getServiceBoundNamesIterator(service, prefix));
 }