GlassfishDetector extends AbstractServerDetector { public ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor) { String version = detectVersion(pMBeanServerExecutor); if (version!= null) { return new GlassfishServerHandle(version, new HashMap<String, String>()); } else { return null; } }  ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor);  }
@Test public void detectFallback() throws InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException, MalformedObjectNameException { ObjectName serverMbean = new ObjectName(SERVER_MBEAN); MBeanServer mockServer = createMock(MBeanServer.class); expect(mockServer.queryNames(new ObjectName("com.sun.appserv:j2eeType=J2EEServer,*"),null)). andReturn(new HashSet<ObjectName>(Arrays.asList(serverMbean))).anyTimes(); expect(mockServer.isRegistered(serverMbean)).andStubReturn(true); expect(mockServer.getAttribute(serverMbean, "serverVersion")).andReturn("GlassFish 3x"); expect(mockServer.queryNames(new ObjectName("com.sun.appserver:type=Host,*"),null)). andReturn(new HashSet<ObjectName>(Arrays.asList(serverMbean))).anyTimes(); replay(mockServer); ServerHandle info = detector.detect(getMBeanServerManager(mockServer)); assertEquals(info.getVersion(), "3"); assertEquals(info.getProduct(),"glassfish"); }
@Test public void detect() throws MalformedObjectNameException, InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException { doPlainDetect(); }