JvmAgent { public static void agentmain(String agentArgs, Instrumentation instrumentation) { JvmAgentConfig config = new JvmAgentConfig(agentArgs); if (!config.isModeStop()) { startAgent(config,false, instrumentation); } else { stopAgent(); } } private  JvmAgent(); static void premain(String agentArgs, Instrumentation inst); static void agentmain(String agentArgs, Instrumentation instrumentation); static final String JOLOKIA_AGENT_URL; }
@Test public void agentmain() throws IOException { JvmAgent.agentmain("mode=start,port=" + EnvTestUtil.getFreePort(), null); JvmAgent.agentmain("mode=stop", null); }
@Test public void startException() throws IOException { int port = EnvTestUtil.getFreePort(); JvmAgent.agentmain("port=" + port, null); try { JvmAgent.agentmain("port=" + port, null); } finally { JvmAgent.agentmain("mode=stop", null); } }