Skip to content

Instantly share code, notes, and snippets.

@clebertsuconic
Created June 26, 2017 14:46
Show Gist options
  • Save clebertsuconic/2a8a4723a326ea0575329730c08ff35c to your computer and use it in GitHub Desktop.
Save clebertsuconic/2a8a4723a326ea0575329730c08ff35c to your computer and use it in GitHub Desktop.
Test for Network Pinger
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Assert;
import org.junit.Test;
public class MyTest extends ActiveMQTestBase {
@Test
public void testNetworkPinger() throws Exception {
Configuration configuration = createBasicConfig();
configuration.setNetworkCheckPeriod(10);
configuration.setNetworkCheckTimeout(10);
ActiveMQServerImpl activeMQServer = new ActiveMQServerImpl(configuration);
addServer(activeMQServer);
activeMQServer.start();
NetworkHealthCheck networkHealthCheck = activeMQServer.getNetworkHealthCheck();
Thread.sleep(100);
//Make ensure health check is ok
Assert.assertTrue(networkHealthCheck.check());
Assert.assertTrue(activeMQServer.isStarted());
//Make health check fail
System.out.println("Adding don't exist");
networkHealthCheck.parseURIList("http://i.dont.exist");
Thread.sleep(100);
Assert.assertFalse(networkHealthCheck.check());
Assert.assertFalse(activeMQServer.isStarted());
//Make health check is ok again
System.out.println("Clearing....");
networkHealthCheck.clearURL();
Thread.sleep(200);
Assert.assertTrue(networkHealthCheck.check());
Assert.assertTrue(activeMQServer.isStarted());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment