use of org.apache.activemq.artemis.core.server.NetworkHealthCheck in project activemq-artemis by apache.
the class NetworkHealthTest method testParseLogger.
@Test
public void testParseLogger() throws Exception {
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100));
// using two addresses for URI and localhost
check.parseAddressList("localhost, , 127.0.0.2").parseURIList("http://www.redhat.com, , http://www.apache.org");
Assert.assertEquals(2, check.getAddresses().size());
Assert.assertEquals(2, check.getUrls().size());
}
use of org.apache.activemq.artemis.core.server.NetworkHealthCheck in project activemq-artemis by apache.
the class NetworkHealthTest method doCheck.
private void doCheck(String localaddress) throws Exception {
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100));
check.addComponent(component);
// Any external IP, to make sure we would use a PING
InetAddress address = InetAddress.getByName(localaddress);
Assert.assertTrue(check.check(address));
Assert.assertTrue(check.purePing(address));
Assert.assertFalse(check.purePing(INVALID_ADDRESS));
}
use of org.apache.activemq.artemis.core.server.NetworkHealthCheck in project activemq-artemis by apache.
the class NetworkHealthTest method testCheck6.
@Test
public void testCheck6() throws Exception {
assumeTrue(purePingWorks(IPV6_LOCAL));
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100));
check.addComponent(component);
InetAddress address = InetAddress.getByName(IPV6_LOCAL);
Assert.assertTrue(address instanceof Inet6Address);
Assert.assertTrue(check.purePing(address));
Assert.assertTrue(check.check(address));
}
use of org.apache.activemq.artemis.core.server.NetworkHealthCheck in project activemq-artemis by apache.
the class NetworkHealthTest method testCheckUsingHTTP.
@Test
public void testCheckUsingHTTP() throws Exception {
startHTTPServer();
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 1000));
Assert.assertTrue(check.check(new URL("http://localhost:8787")));
stopHTTPServer();
Assert.assertFalse(check.check(new URL("http://localhost:8787")));
check.addComponent(component);
URL url = new URL("http://localhost:8787");
Assert.assertFalse(check.check(url));
startHTTPServer();
Assert.assertTrue(check.check(url));
check.addURL(url);
Assert.assertFalse(latch.await(500, TimeUnit.MILLISECONDS));
Assert.assertTrue(component.isStarted());
// stopping the web server should stop the component
stopHTTPServer();
Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
Assert.assertFalse(component.isStarted());
latch.setCount(1);
startHTTPServer();
Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
Assert.assertTrue(component.isStarted());
}
use of org.apache.activemq.artemis.core.server.NetworkHealthCheck in project activemq-artemis by apache.
the class NetworkHealthTest method testParseSpaces.
@Test
public void testParseSpaces() throws Exception {
NetworkHealthCheck check = addCheck(new NetworkHealthCheck(null, 100, 100));
// using two addresses for URI and localhost
check.parseAddressList("localhost, , 127.0.0.2").parseURIList("http://www.redhat.com, , http://www.apache.org");
Assert.assertEquals(2, check.getAddresses().size());
Assert.assertEquals(2, check.getUrls().size());
}
Aggregations