Ejemplo n.º 1
0
  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();
  }
Ejemplo n.º 2
0
  public void testNotYetRegistered() throws Exception {
    setRegisteredId(null);

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertFalse(m_frontEnd.isRegistered());

    m_mock.verifyAll();
  }
Ejemplo n.º 3
0
  public void testAlreadyRegistered() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    assertTrue(m_frontEnd.isRegistered());

    m_mock.verifyAll();
  }
Ejemplo n.º 4
0
  public void testConfigCheck() throws Exception {

    setRegistered();

    anticipateAfterPropertiesSet();

    anticipateCheckConfig();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_frontEnd.checkConfig();

    m_mock.verifyAll();
  }
Ejemplo n.º 5
0
  @Override
  protected void setUp() throws Exception {

    m_backEnd = m_mock.createMock(PollerBackEnd.class);
    m_settings = m_mock.createMock(PollerSettings.class);
    m_pollService = m_mock.createMock(PollService.class);
    m_registrationListener = m_mock.createMock(PropertyChangeListener.class);
    m_polledServiceListener = m_mock.createMock(ServicePollStateChangedListener.class);
    m_configChangeListener = m_mock.createMock(ConfigurationChangedListener.class);

    setPollConfig(new DemoPollerConfiguration());
    m_oldPollerConfiguration = null;

    m_frontEnd = new DefaultPollerFrontEnd();

    m_frontEnd.setTimeAdjustment(new DefaultTimeAdjustment());

    //        ServerUnreachableAdaptor adaptor = new ServerUnreachableAdaptor();
    //        adaptor.setRemoteBackEnd(m_backEnd);
    //        m_frontEnd.setPollerBackEnd(adaptor);

    m_frontEnd.setPollerBackEnd(m_backEnd);

    m_frontEnd.setPollerSettings(m_settings);
    m_frontEnd.setPollService(m_pollService);

    m_frontEnd.addConfigurationChangedListener(m_configChangeListener);
    m_frontEnd.addPropertyChangeListener(m_registrationListener);
    m_frontEnd.addServicePollStateChangedListener(m_polledServiceListener);

    m_serviceStatus = PollStatus.available(1234.0);
  }
Ejemplo n.º 6
0
  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();
  }
Ejemplo n.º 7
0
  private void testAfterPropertiesSetWithRegisteredId(Integer registeredId) throws Exception {
    setRegisteredId(registeredId);

    anticipateAfterPropertiesSet();

    m_mock.replayAll();

    m_frontEnd.afterPropertiesSet();

    m_mock.verifyAll();
  }
Ejemplo n.º 8
0
  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();
  }
Ejemplo n.º 9
0
  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());
  }
Ejemplo n.º 10
0
  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();
  }
Ejemplo n.º 11
0
 private Map<String, String> getPollerDetails() {
   return m_frontEnd.getDetails();
 }
Ejemplo n.º 12
0
 public void testDetails() {
   Map<String, String> details = m_frontEnd.getDetails();
   assertPropertyEquals("os.name", details);
   assertPropertyEquals("os.version", details);
 }