Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package io.airlift.jmx;
 
 
import static java.lang.String.format;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertTrue;
public class TestJmxAgent
    @Test
    public void testSanity()
            throws Exception
    {
        HostAndPort address = JmxAgent.getRunningAgentAddress(nullnull);
        JmxAgent agent = new JmxAgent(new JmxConfig());
        if (address == null) {
            // if agent wasn't running, it must have been started by the instantiation of JmxAgent
            address = JmxAgent.getRunningAgentAddress(nullnull);
            assertNotNull(address);
        }
        JMXServiceURL url = agent.getUrl();
        assertEquals(url.toString(), format("service:jmx:rmi:///jndi/rmi://%s:%s/jmxrmi"address.getHostText(), address.getPort()));
        JMXConnector connector = JMXConnectorFactory.connect(url);
        connector.connect();
        MBeanServerConnection connection = connector.getMBeanServerConnection();
        assertTrue(connection.getMBeanCount() > 0);
    }
New to GrepCode? Check out our FAQ X