/** Test if a record is registered when the controller is temporarily down. */ @Test public void testControllerDownRegistration() { System.out.println("testControllerDownRegistration"); List<String> hosts = new ArrayList(); hosts.add("uva.nl"); instance.doInBackground(hosts); sleepMillis(120); instance.stopTemporarily(); sleepMillis(1_500); assertFalse(instance.isBusyCheckingConnections()); instance.restart(hosts); sleepMillis(1_500); assertTrue( "The controller is NOT checking connections now", instance.isBusyCheckingConnections()); OutageListItem lastOutage = instance.getLastOutage(); assertTrue("No outages were registered", null != lastOutage); assertTrue( "The actual last outage is " + lastOutage, lastOutage.getOutageCause() == CONTROLLERDOWN); instance.exit(); sleepMillis(1_500); if (instance.getSessionData().saveData()) { LOGGER.info("Session data is saved at exiting the application."); } else { LOGGER.error("Session data is NOT saved at exiting the application."); } LOGGER.info("Load data"); instance.initWithPreviousSessionData(); assertTrue( "The actual last outage is " + lastOutage, lastOutage.getOutageCause() == CONTROLLERDOWN); }
/** Test of run method, of class ISPController. */ @Test public void testRun() { System.out.println("testRun"); instance.start(); assert (instance.isAlive()); instance.exit(); sleepMillis(1_500); assert (!instance.isAlive()); }
@After public void tearDown() { System.out.println("tearDown"); instance.exit(); sleepMillis(1_500); if (instance.isAlive()) { LOGGER.warn("The controller thread is still running!"); } else { LOGGER.info("The controller thread has exited."); } }
/** Test of exit method, of class ISPController. */ @Test public void testExit() { System.out.println("testExit"); List<String> hosts = new ArrayList(); hosts.add("uva.nl"); instance.doInBackground(hosts); sleepMillis(120); instance.exit(); sleepMillis(1_500); assertFalse(instance.isRunning()); assertFalse(instance.isAlive()); }