LightstreamerDetector extends AbstractServerDetector { public ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor) { String serverVersion = getSingleStringAttribute(pMBeanServerExecutor, "com.lightstreamer:type=Server", "LSVersion"); if (serverVersion != null) { return new ServerHandle("LightStreamer", "LightStreamer", serverVersion, null); } return null; }  ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor); @Override void jvmAgentStartup(Instrumentation instrumentation);  }
@Test public void testDetect() throws MalformedObjectNameException, AttributeNotFoundException, MBeanException, ReflectionException, InstanceNotFoundException { String version = "6.0.1"; MBeanServer mockServer = createMock(MBeanServer.class); ObjectName oName = new ObjectName("com.lightstreamer:type=Server"); expect(mockServer.queryNames(new ObjectName("com.lightstreamer:type=Server"), null)). andReturn(new HashSet<ObjectName>(Arrays.asList(oName))).anyTimes(); expect(mockServer.isRegistered(oName)).andStubReturn(true); expect(mockServer.getAttribute(oName,"LSVersion")).andStubReturn(version); replay(mockServer); ServerHandle handle = detector.detect(getMBeanServerManager(mockServer)); assertNotNull(handle); assertEquals(handle.getVersion(),version); }