Ejemplo n.º 1
0
  /** 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);
  }
Ejemplo n.º 2
0
  /** Test of stopTemporarily method, of class ISPController. */
  @Test
  public void testStopTemporarily() {
    System.out.println("testStopTemporarily");

    List<String> hosts = new ArrayList();
    hosts.add("uva.nl");

    instance.doInBackground(hosts);
    sleepMillis(120);
    assertTrue(
        "The controller is NOT checking connections now", instance.isBusyCheckingConnections());
    instance.stopTemporarily();
    sleepMillis(1_100);
    assertFalse(instance.isBusyCheckingConnections());
  }
Ejemplo n.º 3
0
  /** Test if a record is registered when service is restarted. */
  @Test
  public void testServiceInterruptedRegistration() {
    System.out.println("testServiceInterruptedRegistration");
    List<String> hosts = new ArrayList();
    hosts.add("uva.nl");

    instance.doInBackground(hosts);
    sleepMillis(120);
    assertTrue(
        "The controller is NOT checking connections now", instance.isBusyCheckingConnections());
    OutageListItem lastOutage = instance.getLastOutage();
    LOGGER.info("Outage = {}", lastOutage);
    assertTrue("No outages were registered", null != lastOutage);
    assertTrue(
        "The actual last outage is " + lastOutage, lastOutage.getOutageCause() == SERVICEDOWN);
  }
Ejemplo n.º 4
0
  /**
   * Test if a record is registered when the ISP can not be reached due to an internal network
   * failure and a false router address is entered.
   */
  @Test
  public void testInternalInterruptedRegistrationWithFalseRouterAddress() {
    System.out.println("testInternalInterruptedRegistrationWithFalseRouterAddress");
    List<String> hosts = new ArrayList();
    hosts.add("uva.nl");
    instance.setRouterAddress("false router address");

    instance.doInBackground(hosts);
    sleepMillis(120);
    assertTrue(
        "The controller is NOT checking connections now", instance.isBusyCheckingConnections());
    instance.simulateFailure(true);
    sleepMillis(6_000);
    instance.simulateFailure(false);
    sleepMillis(6_000);
    OutageListItem lastOutage = instance.getLastOutage();
    LOGGER.info("Outage = {}", lastOutage);
    assertTrue("No outages were registered", null != lastOutage);
    assertTrue("The actual last outage is " + lastOutage, lastOutage.getOutageCause() == ISP);
  }