throws Exception {
final String name =
"list" + Long.toString(System.currentTimeMillis());
// create list
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
ScalableList<Integer> d = new ScalableList<Integer>();
AppContext.getDataManager().setBinding(name, d);
}
}, taskOwner);
int countAfterCreate = getObjectCount();
System.err.println("countAfterCreate: " + countAfterCreate);
// add some objects
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
ScalableList<Integer> d =
uncheckedCast(AppContext.getDataManager().getBinding(
name));
for (int i = 0; i < elementsToAdd; i++) {
d.add(i);
}
}
}, taskOwner);
int countAfterAdds = getObjectCount();
System.err.println("countAfterAdds: " + countAfterAdds);
// clear the list
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
DataManager dm = AppContext.getDataManager();
ScalableList<Integer> d = uncheckedCast(dm.getBinding(name));
d.clear();
}
}, taskOwner);
// removal is asynchronous, so wait. When we compare, there should
// be as many objects as there were immediately after the list
// was created.
Thread.sleep(50 * elementsToAdd);
int countAfterClear = getObjectCount();
System.err.println("countAfterClear: " + countAfterClear);
assertEquals(countAfterCreate, countAfterClear);
// delete object
txnScheduler.runTask(new TestAbstractKernelRunnable() {
public void run() {
DataManager dm = AppContext.getDataManager();
ScalableList<Integer> d = uncheckedCast(dm.getBinding(name));
dm.removeObject(d);
dm.removeBinding(name);