public void testExtent(Class clazz, boolean withSubclass, Collection ids) {
logger.log(BasicLevel.DEBUG, "testExtent_" + clazz.getName() + "_sc=" + withSubclass);
PersistenceManager pm = pmf.getPersistenceManager();
try {
Extent e = pm.getExtent(clazz, withSubclass);
Assert.assertEquals("Bad candidate class on the extent",
clazz, e.getCandidateClass());
Assert.assertEquals("Bad sub class value on the extent",
withSubclass, e.hasSubclasses());
Iterator it = e.iterator();
ArrayList found = new ArrayList(ids.size());
while(it.hasNext()) {
Object o = it.next();
if (o == null) {
fail("Null object returned by the extent iterator of the class "
+ clazz.getName());
} else if (o instanceof AMMB) {
AMMB a = (AMMB) o;
found.add(new Long(a.getIda()));
} else if (o instanceof BMMB) {
BMMB b = (BMMB) o;
found.add(new Long(b.getIdb()));
} else {
fail("the test does not manage the class " + o.getClass().getName());
}
}
try {
it.remove();
fail("the remove operation does not throw an exception");
} catch (UnsupportedOperationException e1) {
}
assertSameCollection("Bad extent of the class " + clazz.getName(), ids, found);
e.close(it);
try {
it.hasNext();
fail("the iterator does not throw an exception on the use of " +
"the 'hasNext' method whereas it has been closed");
} catch (NoSuchElementException e1) {
}
try {
it.next();
fail("the iterator does not throw an exception on the use of " +
"the 'next' method whereas it has been closed");
} catch (NoSuchElementException e1) {
}
e = pm.getExtent(clazz, withSubclass);
Iterator[] its = new Iterator[5];
for(int i=0; i<its.length; i++) {
its[i] = e.iterator();
}
e.closeAll();
for(int i=0; i<its.length; i++) {
try {
its[i].next();
fail("the iterator " + i +" does not throw an exception on "
+ "the use of the 'next' method whereas all"
+ " iterator have been closed");
} catch (NoSuchElementException e1) {
}
}
it = e.iterator();
for(int i=0; i<ids.size(); i++) {
try {
it.next();
} catch (NoSuchElementException e1) {
Assert.assertEquals("Bad size: ", ids.size(), i);
}
}
e.close(it);
} catch (Exception e) {
Exception ie = ExceptionHelper.getNested(e);
logger.log(BasicLevel.ERROR, "", ie);
fail(ie.getMessage());
} finally {