Search in sources :

Example 1 with Await

use of org.apache.camel.itest.springboot.arquillian.container.util.Await in project camel by apache.

the class ManagedSEDeployableContainer method isJMXTestRunnerMBeanRegistered.

private boolean isJMXTestRunnerMBeanRegistered(final String host, final int port, int waitTime) throws DeploymentException {
    // Taken from org.jboss.arquillian.container.spi.client.protocol.metadata.JMXContext
    final String jmxServiceUrl = "service:jmx:rmi:///jndi/rmi://" + host + ":" + port + "/jmxrmi";
    try (JMXConnector jmxc = JMXConnectorFactory.connect(new JMXServiceURL(jmxServiceUrl), null)) {
        final MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
        return new Await(waitTime, new Callable<Boolean>() {

            @Override
            public Boolean call() throws Exception {
                mbsc.getObjectInstance(new ObjectName(JMXTestRunnerMBean.OBJECT_NAME));
                LOGGER.fine("JMXTestRunnerMBean registered with the remote MBean server at: " + jmxServiceUrl);
                return true;
            }
        }).start();
    } catch (IOException e) {
        throw new DeploymentException("Could not verify JMXTestRunnerMBean registration", e);
    }
}
Also used : JMXServiceURL(javax.management.remote.JMXServiceURL) JMXConnector(javax.management.remote.JMXConnector) DeploymentException(org.jboss.arquillian.container.spi.client.container.DeploymentException) IOException(java.io.IOException) Await(org.apache.camel.itest.springboot.arquillian.container.util.Await) MBeanServerConnection(javax.management.MBeanServerConnection) Callable(java.util.concurrent.Callable) ObjectName(javax.management.ObjectName)

Aggregations

IOException (java.io.IOException)1 Callable (java.util.concurrent.Callable)1 MBeanServerConnection (javax.management.MBeanServerConnection)1 ObjectName (javax.management.ObjectName)1 JMXConnector (javax.management.remote.JMXConnector)1 JMXServiceURL (javax.management.remote.JMXServiceURL)1 Await (org.apache.camel.itest.springboot.arquillian.container.util.Await)1 DeploymentException (org.jboss.arquillian.container.spi.client.container.DeploymentException)1