public void testSetInitialPollTime() throws Exception {

    Date start = new Date(1200000000000L);

    setRegistered();

    anticipateAfterPropertiesSet();

    int polledServiceId = pollConfig().getFirstId();

    anticipateSetInitialPollTime();

    anticipateGetServicePollState();

    //      expect(m_settings.getMonitorId()).andReturn(1).atLeastOnce();

    //      anticipateNewConfig(pollConfig());

    //      expect(m_backEnd.pollerStarting(1, getPollerDetails())).andReturn(true);

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_frontEnd.setInitialPollTime(polledServiceId, start);

    assertEquals(start, m_frontEnd.getServicePollState(polledServiceId).getNextPollTime());

    m_mock.verifyAll();
  }
  private void testAfterPropertiesSetWithRegisteredId(Integer registeredId) throws Exception {
    setRegisteredId(registeredId);

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_mock.verifyAll();
  }
  public void testNotYetRegistered() throws Exception {
    setRegisteredId(null);

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertFalse(m_frontEnd.isRegistered());

    m_mock.verifyAll();
  }
  public void testAlreadyRegistered() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertTrue(m_frontEnd.isRegistered());

    m_mock.verifyAll();
  }
  public void testConfigCheck() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    anticipateCheckConfig();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_frontEnd.checkConfig();

    m_mock.verifyAll();
  }
  public void testRegisterNewMonitor() throws Exception {

    anticipateAfterPropertiesSet();

    anticiapateRegister();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertFalse(m_frontEnd.isRegistered());

    m_frontEnd.register("OAK");

    assertTrue(m_frontEnd.isRegistered());

    m_mock.verifyAll();
  }
  public void testStop() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    anticipateStop();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertTrue(m_frontEnd.isStarted());

    m_frontEnd.stop();

    assertFalse(m_frontEnd.isStarted());

    m_mock.verifyAll();
  }
  public void testPoll() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    anticipatePollService();

    anticipateGetServicePollState();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_frontEnd.pollService(pollConfig().getFirstId());

    ServicePollState pollState = m_frontEnd.getServicePollState(pollConfig().getFirstId());

    m_mock.verifyAll();

    assertEquals(PollStatus.SERVICE_AVAILABLE, pollState.getLastPoll().getStatusCode());
  }
  public void testDisconnect() throws Exception {
    setRegistered();

    anticipateAfterPropertiesSet();

    setMonitorStatus(MonitorStatus.DISCONNECTED);

    anticipateCheckConfig();

    setMonitorStatus(MonitorStatus.STARTED);

    anticipateCheckConfig();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_frontEnd.checkConfig();

    m_frontEnd.checkConfig();

    m_mock.verifyAll();
  }