public void testSizeCalc() throws Exception { SimpleBinarySemaphore sem = new SimpleBinarySemaphore(); mgr.setSem(sem); RepositoryNode node1 = new RepositoryNodeImpl("url1", "testDir", null); RepositoryNode node2 = new RepositoryNodeImpl("url2", "testDir", null); RepositoryNode node3 = new RepositoryNodeImpl("url3", "testDir", null); mgr.queueSizeCalc(node1); assertTrue(sem.take(TIMEOUT_SHOULDNT)); assertEquals(ListUtil.list(node1), mgr.getNodes()); mgr.queueSizeCalc(node2); mgr.queueSizeCalc(node3); assertTrue(sem.take(TIMEOUT_SHOULDNT)); if (mgr.getNodes().size() < 3) { assertTrue(sem.take(TIMEOUT_SHOULDNT)); } assertSameElements(ListUtil.list(node1, node2, node3), mgr.getNodes()); }
void doSizeCalc(RepositoryNode node) { TimerUtil.guaranteedSleep(10); nodes.add(node); sem.give(); }