public void run(CommandExecutor executor) throws ClassNotFoundException { // create a classloader and load our special class dummyloader = new DummyClassLoader(); Class<?> c = Class.forName("TestClass", true, dummyloader); if (c.getClassLoader() != dummyloader) { Assert.fail("TestClass defined by wrong classloader: " + c.getClassLoader()); } OutputAnalyzer output = executor.execute("VM.classloader_stats"); Iterator<String> lines = output.asLines().iterator(); while (lines.hasNext()) { String line = lines.next(); Matcher m = clLine.matcher(line); if (m.matches()) { // verify that DummyClassLoader has loaded 1 class and 1 anonymous class if (m.group(4).equals("ClassLoaderStatsTest$DummyClassLoader")) { System.out.println("line: " + line); if (!m.group(1).equals("1")) { Assert.fail("Should have loaded 1 class: " + line); } checkPositiveInt(m.group(2)); checkPositiveInt(m.group(3)); String next = lines.next(); System.out.println("next: " + next); Matcher m1 = anonLine.matcher(next); m1.matches(); if (!m1.group(1).equals("1")) { Assert.fail("Should have loaded 1 anonymous class, but found : " + m1.group(1)); } checkPositiveInt(m1.group(2)); checkPositiveInt(m1.group(3)); } } } }