Lines 278-283
Link Here
|
278 |
ch = Children.create(b, true); |
278 |
ch = Children.create(b, true); |
279 |
assertEquals(4, ch.getNodesCount(true)); |
279 |
assertEquals(4, ch.getNodesCount(true)); |
280 |
} |
280 |
} |
|
|
281 |
|
282 |
public void testDestroyNodesSynch() throws Exception { |
283 |
DestroyableImpl r = new DestroyableImpl(); |
284 |
Children ch = Children.create(r, false); |
285 |
new AbstractNode (ch); |
286 |
Node[] n = ch.getNodes(true); |
287 |
assertEquals (2, n.length); |
288 |
assertEquals ("foo", n[0].getDisplayName()); |
289 |
assertEquals ("bar", n[1].getDisplayName()); |
290 |
r.refresh(true); |
291 |
n = ch.getNodes(true); |
292 |
assertEquals (0, n.length); |
293 |
Set<Node> destroyed = r.getDestroyed(); |
294 |
Set<String> expected = new HashSet<String>(); |
295 |
Collections.addAll(expected, "foo", "bar"); |
296 |
for (Node node : destroyed) { |
297 |
assertTrue(node.getDisplayName(), expected.contains(node.getDisplayName())); |
298 |
} |
299 |
} |
300 |
|
301 |
public void testDestroyNodesAsynch() throws Exception { |
302 |
DestroyableImpl r = new DestroyableImpl(); |
303 |
Children ch = Children.create(r, true); |
304 |
new AbstractNode (ch); |
305 |
Node[] n = ch.getNodes(true); |
306 |
assertEquals (2, n.length); |
307 |
assertEquals ("foo", n[0].getDisplayName()); |
308 |
assertEquals ("bar", n[1].getDisplayName()); |
309 |
r.refresh(false); |
310 |
synchronized(r) { |
311 |
r.wait(1000); |
312 |
} |
313 |
n = ch.getNodes(true); |
314 |
assertEquals (0, n.length); |
315 |
Set<Node> destroyed = r.getDestroyed(); |
316 |
Set<String> expected = new HashSet<String>(); |
317 |
Collections.addAll(expected, r.createWaitNode().getDisplayName(), "foo", "bar"); |
318 |
for (Node node : destroyed) { |
319 |
assertTrue(node.getDisplayName(), expected.contains(node.getDisplayName())); |
320 |
} |
321 |
} |
281 |
|
322 |
|
282 |
public void testIncrementalDisplay() throws Exception { // #206556 |
323 |
public void testIncrementalDisplay() throws Exception { // #206556 |
283 |
final Semaphore s1 = new Semaphore(0); |
324 |
final Semaphore s1 = new Semaphore(0); |
Lines 674-677
Link Here
|
674 |
assertTrue (removed); |
715 |
assertTrue (removed); |
675 |
} |
716 |
} |
676 |
} |
717 |
} |
|
|
718 |
|
719 |
private static final class DestroyableImpl extends ChildFactory.DestroyableNodes<String> { |
720 |
|
721 |
private boolean empty; |
722 |
|
723 |
private final Set<Node> destroyed = Collections.synchronizedSet(new HashSet<Node>()); |
724 |
|
725 |
@Override |
726 |
protected boolean createKeys(List<String> toPopulate) { |
727 |
if (empty) { |
728 |
return true; |
729 |
} |
730 |
|
731 |
toPopulate.add("foo"); |
732 |
toPopulate.add("bar"); |
733 |
synchronized (this) { |
734 |
notifyAll(); |
735 |
} |
736 |
empty = true; |
737 |
return true; |
738 |
} |
739 |
|
740 |
@Override |
741 |
protected Node createNodeForKey(String key) { |
742 |
AbstractNode nd = new AbstractNode(Children.LEAF); |
743 |
nd.setDisplayName(key); |
744 |
return nd; |
745 |
} |
746 |
|
747 |
@Override |
748 |
protected void destroyNodes(Node[] arr) { |
749 |
synchronized (destroyed) { |
750 |
Collections.addAll(destroyed, arr); |
751 |
} |
752 |
} |
753 |
|
754 |
public Set<Node> getDestroyed() { |
755 |
synchronized (destroyed) { |
756 |
return new HashSet<Node>(destroyed); |
757 |
} |
758 |
} |
759 |
} |
677 |
} |
760 |
} |