JmxEndpointComponent extends AbstractEndpointComponent { @Override protected Endpoint createEndpoint(String resourcePath, Map<String, String> parameters, TestContext context) { JmxClient client = new JmxClient(); if (resourcePath.contains("platform")) { client.getEndpointConfiguration().setServerUrl("platform"); } else { client.getEndpointConfiguration().setServerUrl("service:jmx:" + resourcePath); } enrichEndpointConfiguration(client.getEndpointConfiguration(), getEndpointConfigurationParameters(parameters, JmxEndpointConfiguration.class), context); return client; } JmxEndpointComponent();   }
@Test public void testCreateClientEndpoint() throws Exception { JmxEndpointComponent component = new JmxEndpointComponent(); Endpoint endpoint = component.createEndpoint("jmx:rmi: Assert.assertEquals(endpoint.getClass(), JmxClient.class); Assert.assertEquals(((JmxClient)endpoint).getEndpointConfiguration().getServerUrl(), "service:jmx:rmi: endpoint = component.createEndpoint("jmx:platform", context); Assert.assertEquals(endpoint.getClass(), JmxClient.class); Assert.assertEquals(((JmxClient)endpoint).getEndpointConfiguration().getServerUrl(), "platform"); Assert.assertEquals(((JmxClient) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }
@Test public void testCreateClientEndpointWithParameters() throws Exception { JmxEndpointComponent component = new JmxEndpointComponent(); Endpoint endpoint = component.createEndpoint("jmx:rmi: Assert.assertEquals(endpoint.getClass(), JmxClient.class); Assert.assertEquals(((JmxClient)endpoint).getEndpointConfiguration().getServerUrl(), "service:jmx:rmi: Assert.assertFalse(((JmxClient) endpoint).getEndpointConfiguration().isAutoReconnect()); Assert.assertEquals(((JmxClient) endpoint).getEndpointConfiguration().getTimeout(), 10000L); endpoint = component.createEndpoint("jmx:platform?autoReconnect=true", context); Assert.assertEquals(endpoint.getClass(), JmxClient.class); Assert.assertEquals(((JmxClient)endpoint).getEndpointConfiguration().getServerUrl(), "platform"); Assert.assertTrue(((JmxClient) endpoint).getEndpointConfiguration().isAutoReconnect()); Assert.assertEquals(((JmxClient) endpoint).getEndpointConfiguration().getTimeout(), 5000L); }