Search in sources :

Example 1 with NetworkHealthCheck

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());
}
Also used : NetworkHealthCheck(org.apache.activemq.artemis.core.server.NetworkHealthCheck) Test(org.junit.Test)

Example 2 with NetworkHealthCheck

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));
}
Also used : NetworkHealthCheck(org.apache.activemq.artemis.core.server.NetworkHealthCheck) InetAddress(java.net.InetAddress)

Example 3 with NetworkHealthCheck

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));
}
Also used : NetworkHealthCheck(org.apache.activemq.artemis.core.server.NetworkHealthCheck) Inet6Address(java.net.Inet6Address) InetAddress(java.net.InetAddress) Test(org.junit.Test)

Example 4 with NetworkHealthCheck

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());
}
Also used : NetworkHealthCheck(org.apache.activemq.artemis.core.server.NetworkHealthCheck) URL(java.net.URL) Test(org.junit.Test)

Example 5 with NetworkHealthCheck

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());
}
Also used : NetworkHealthCheck(org.apache.activemq.artemis.core.server.NetworkHealthCheck) Test(org.junit.Test)

Aggregations

NetworkHealthCheck (org.apache.activemq.artemis.core.server.NetworkHealthCheck)6 Test (org.junit.Test)5 InetAddress (java.net.InetAddress)2 Inet6Address (java.net.Inet6Address)1 URL (java.net.URL)1