JBossDetector extends AbstractServerDetector { public ServerHandle detect(MBeanServerExecutor pMBeanServerExecutor) { ServerHandle handle = checkFromJSR77(pMBeanServerExecutor); if (handle == null) { handle = checkFor5viaJMX(pMBeanServerExecutor); if (handle == null) { handle = checkForManagementRootServerViaJMX(pMBeanServerExecutor); } if (handle == null) { handle = checkForWildflySwarm(); } if (handle == null) { handle = fallbackForVersion7Check(pMBeanServerExecutor); } } return handle; }  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 simpleNotFound() throws MalformedObjectNameException { for (String name : new String[]{ "jboss.system:type=Server", "jboss.as:*", "jboss.modules:*" }) { expect(server.queryNames(new ObjectName(name), null)).andReturn(Collections.<ObjectName>emptySet()).anyTimes(); } replay(server); assertNull(detector.detect(servers)); verify(server); }
@Test public void simpleFound() throws MalformedObjectNameException, InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException, IntrospectionException { expect(server.queryNames(new ObjectName("jboss.as:management-root=server"),null)).andReturn(Collections.EMPTY_SET); ObjectName oName = prepareQuery("jboss.system:type=Server"); expect(server.isRegistered(oName)).andStubReturn(true); expect(server.getAttribute(oName, "Version")).andReturn("5.1.0"); replay(server); ServerHandle handle = detector.detect(servers); assertEquals(handle.getVersion(),"5.1.0"); assertEquals(handle.getVendor(),"RedHat"); assertEquals(handle.getProduct(),"jboss"); reset(server); ObjectName memoryBean = new ObjectName("java.lang:type=Memory"); expect(server.isRegistered(memoryBean)).andStubReturn(true); replay(server); handle.preDispatch(servers, new JmxRequestBuilder(RequestType.READ, memoryBean).attribute("HeapMemoryUsage").<JmxRequest>build()); verify(server); }
@Test public void version71() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException { expect(server.queryNames(new ObjectName("jboss.system:type=Server"),null)).andReturn(Collections.<ObjectName>emptySet()); prepareQuery("jboss.as:*"); ObjectName oName = new ObjectName("jboss.as:management-root=server"); expect(server.getAttribute(oName,"productVersion")).andReturn(null); expect(server.getAttribute(oName,"releaseVersion")).andReturn("7.1.1.Final"); expect(server.getAttribute(oName,"productName")).andReturn(null); replay(server); ServerHandle handle = detector.detect(servers); assertEquals(handle.getVersion(),"7.1.1.Final"); assertEquals(handle.getVendor(),"RedHat"); assertEquals(handle.getProduct(),"jboss"); verifyNoWorkaround(handle); }
@Test public void version101() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException, AttributeNotFoundException, MBeanException { expect(server.queryNames(new ObjectName("jboss.system:type=Server"),null)).andReturn(Collections.<ObjectName>emptySet()); prepareQuery("jboss.as:*"); ObjectName oName = new ObjectName("jboss.as:management-root=server"); expect(server.getAttribute(oName,"productVersion")).andReturn("10.1.0.Final"); expect(server.getAttribute(oName,"productName")).andReturn("WildFly Full"); replay(server); ServerHandle handle = detector.detect(servers); assertEquals(handle.getVersion(),"10.1.0.Final"); assertEquals(handle.getVendor(),"RedHat"); assertEquals(handle.getProduct(),"WildFly Full"); verifyNoWorkaround(handle); }
@Test public void version7() throws MalformedObjectNameException, IntrospectionException, InstanceNotFoundException, ReflectionException { expect(server.queryNames(new ObjectName("jboss.system:type=Server"),null)).andReturn(Collections.<ObjectName>emptySet()); expect(server.queryNames(new ObjectName("jboss.as:*"),null)).andReturn(Collections.<ObjectName>emptySet()); prepareQuery("jboss.modules:*"); replay(server); ServerHandle handle = detector.detect(servers); assertEquals(handle.getVersion(),"7"); assertEquals(handle.getVendor(),"RedHat"); assertEquals(handle.getProduct(),"jboss"); verifyNoWorkaround(handle); }