done = 0;
new DBCloser(0).start();
new DBCloser(1).start();
while (done < 2) Execute.sleep(100);
PageDB db = new PageDB(dbNames[0]);
db.open(DPageDB.READ);
Iterator<Page> pages = db.iterator();
assertTrue("The first distributed pagedb should have two pages, yet it has none.", pages.hasNext());
Page page1 = pages.next();
assertTrue("One of the pages in the first distributed pagedb is not expected: "+page1.getUrl(), page1.equals(page00) || page1.equals(page10));
assertTrue("The first distributed pagedb should have two pages, yet it has one.", pages.hasNext());
Page page2 = pages.next();
assertTrue("One of the pages in the first distributed pagedb is not expected: "+page2.getUrl(), page2.equals(page00) || page2.equals(page10));
assertFalse("One of the pages in the first distributed pagedb has been cloned:"+page1.getUrl(), page1.equals(page2));
assertFalse("The first distributed pagedb should have two pages, yet it has more.", pages.hasNext());
db.close();
db = new PageDB(dbNames[1]);
db.open(DPageDB.READ);
pages = db.iterator();
assertTrue("The second distributed pagedb should have two pages, yet it has none.", pages.hasNext());
page1 = pages.next();
assertTrue("One of the pages in the second distributed pagedb is not expected: "+page1.getUrl(), page1.equals(page01) || page1.equals(page11));
assertTrue("The second distributed pagedb should have two pages, yet it has one.", pages.hasNext());
page2 = pages.next();
assertTrue("One of the pages in the second distributed pagedb is not expected: "+page2.getUrl(), page2.equals(page01) || page2.equals(page11));
assertFalse("One of the pages in the second distributed pagedb has been cloned:"+page1.getUrl(), page1.equals(page2));
assertFalse("The second pagedb should have two pages, yet it has more.", pages.hasNext());
db.close();
}
}