1 package test; 2 3 import org.testng.Assert; 4 5 import java.util.HashMap; 6 import java.util.Iterator; 7 import java.util.Map; 8 9 public class BaseDistributedTest { 10 private boolean m_verbose = false; 11 verifyTests(String title, String[] exp, Map found)12 protected void verifyTests(String title, String[] exp, Map found) { 13 Map expected = new HashMap(); 14 for (String element : exp) { 15 expected.put(element, element); 16 } 17 18 Assert.assertEquals(found.size(), expected.size(), 19 "Verification for " + title + " tests failed:"); 20 21 for (Object o : expected.values()) { 22 String name = (String) o; 23 if (null == found.get(name)) { 24 dumpMap("Expected", expected); 25 dumpMap("Found", found); 26 } 27 28 Assert.assertNotNull(found.get(name), 29 "Expected to find method " + name + " in " + title 30 + " but didn't find it."); 31 } 32 } 33 dumpMap(String title, Map<?, ?> m)34 protected void dumpMap(String title, Map<?, ?> m) { 35 if (m_verbose) { 36 System.out.println("==== " + title); 37 for (Map.Entry<?, ?> entry : m.entrySet()) { 38 ppp(entry.getKey() + " => " + entry.getValue()); 39 } 40 } 41 } ppp(String s)42 private void ppp(String s) { 43 if (m_verbose) { 44 System.out.println("[BaseDistributedTest] " + s); 45 } 46 } 47 48 49 } 50