JBossDetector extends AbstractServerDetector { @Override public void jvmAgentStartup(Instrumentation instrumentation) { jvmAgentStartup(instrumentation, this.getClass().getClassLoader()); }  ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor); @Override void jvmAgentStartup(Instrumentation instrumentation); @Override /** {@inheritDoc} */ void addMBeanServers(Set<MBeanServerConnection> servers); static final String JBOSS_AS_MANAGEMENT_ROOT_SERVER; static final int LOGGING_DETECT_TIMEOUT; static final int LOGGING_DETECT_INTERVAL; }
@Test public void verifyJvmAgentStartup() throws MalformedURLException { Instrumentation inst = createMock(Instrumentation.class); expect(inst.getAllLoadedClasses()).andReturn(new Class[] {}).times(3); expect(inst.getAllLoadedClasses()).andReturn(new Class[] {JBossDetectorTest.class}).atLeastOnce(); ClassLoader cl = createMock(ClassLoader.class); expect(cl.getResource("org/jboss/modules/Main.class")).andReturn(new URL("http", "dummy", "")).anyTimes(); String prevPkgValue = System.setProperty("jboss.modules.system.pkgs", "blah"); String prevLogValue = System.setProperty("java.util.logging.manager", JBossDetectorTest.class.getName()); replay(inst,cl); try { detector.jvmAgentStartup(inst, cl); } finally { resetSysProp(prevLogValue, "java.util.logging.manager"); resetSysProp(prevPkgValue, "jboss.modules.system.pkgs"); } verify(inst); }