@Test public void testListEquals() { List<String> s = new ArrayList<String>(); s.add("GMethod"); s.add("ClassCast"); s.add("RawType"); List<String> r = new InstrumentedList<String>(s); List<String> q = new InstrumentedList<String>(r); assertTrue(r.equals(q)); }
@Override public void verify() throws TransformException { for (Pair<Node, List<Node>> pair : siblingsByTarget) { Node target = pair.first; List<Node> storedSiblings = pair.second; for (Node sibling : storedSiblings) { if (!target.query().single(".. is $_1/..", sibling).booleanValue()) throw new TransformException( "previously selected node is no longer a sibling: " + sibling); } List<Node> actualSiblings = query.runOn(mod.scope(target.query().single("..").query())).nodes().asList(); if (!actualSiblings.equals(storedSiblings)) throw new TransformException( "sibling list changed for target " + target.query().single("@xml:id").value()); // No need to check sibling order, since any change in the node's document will trigger a // sort. } }
@Test public void testMultiHost() throws Exception { HostMessenger hm1 = createHostMessenger(0); final HostMessenger hm2 = createHostMessenger(1, false); final HostMessenger hm3 = createHostMessenger(2, false); final AtomicReference<Exception> exception = new AtomicReference<Exception>(); Thread hm2Start = new Thread() { @Override public void run() { try { hm2.start(); } catch (Exception e) { e.printStackTrace(); exception.set(e); } } }; Thread hm3Start = new Thread() { @Override public void run() { try { hm3.start(); } catch (Exception e) { e.printStackTrace(); exception.set(e); } } }; hm2Start.start(); hm3Start.start(); hm2Start.join(); System.out.println(hm2.getZK().getChildren(CoreZK.hostids, false)); hm3Start.join(); if (exception.get() != null) { fail(exception.get().toString()); } List<String> root1 = hm1.getZK().getChildren("/", false); List<String> root2 = hm2.getZK().getChildren("/", false); List<String> root3 = hm3.getZK().getChildren("/", false); System.out.println(root1); System.out.println(root2); System.out.println(root3); assertTrue(root1.equals(root2)); assertTrue(root2.equals(root3)); List<String> hostids1 = hm1.getZK().getChildren(CoreZK.hostids, false); List<String> hostids2 = hm2.getZK().getChildren(CoreZK.hostids, false); List<String> hostids3 = hm3.getZK().getChildren(CoreZK.hostids, false); System.out.println(hostids1); System.out.println(hostids2); System.out.println(hostids3); assertTrue(hostids1.equals(hostids2)); assertTrue(hostids2.equals(hostids3)); List<String> hosts3; List<String> hosts1; hm2.shutdown(); boolean success = false; for (int ii = 0; ii < (200 / 5); ii++) { hosts3 = hm3.getZK().getChildren(CoreZK.hosts, false); hosts1 = hm1.getZK().getChildren(CoreZK.hosts, false); if (hosts3.size() == 2 && hosts1.size() == 2 && hosts1.equals(hosts3)) { success = true; break; } Thread.sleep(5); } assertTrue(success); hm1.waitForGroupJoin(2); hm3.waitForGroupJoin(2); }