Beispiel #1
0
  @Test
  public void testStatus() throws Exception {
    log.info("starting testStatus ... ");

    SmppConfiguration configuration = new SmppConfiguration();
    configuration.setHost("localhost");
    configuration.setPort(SERVER_PORT);
    configuration.setSystemId("test");
    configuration.setPassword("test");

    SmppConnector connector = new SmppConnector(configuration);
    injectResource(new MockProcessorContext(), connector);
    Assert.assertEquals(connector.getStatus(), Status.UNKNOWN);

    connector.doStart();
    waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

    try {
      stopSimulator();
      waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.FAILED);

      startSimulator();
      waitUntilStatus(connector, DEFAULT_TIMEOUT, Status.OK);

      Assert.assertEquals(connector.getStatus(), Status.OK);
    } finally {
      connector.doStop();
    }
  }
Beispiel #2
0
  private void waitUntilStatus(SmppConnector connector, long timeout, Status status) {
    boolean isValid = false;

    long startTime = new Date().getTime();
    long actualTime = new Date().getTime();
    while (!isValid && (actualTime - startTime) <= timeout) {
      if (connector.getStatus() == status) {
        isValid = true;
      } else {
        synchronized (this) {
          try {
            this.wait(200);
          } catch (Exception e) {
          }
        }
      }

      actualTime = new Date().getTime();
    }

    Assert.assertEquals(connector.getStatus(), status);
  }