@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);
}