Created
June 26, 2017 14:46
-
-
Save clebertsuconic/2a8a4723a326ea0575329730c08ff35c to your computer and use it in GitHub Desktop.
Test for Network Pinger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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