Exemple #1
0
  private void stop() {
    org.testng.Assert.assertTrue(eventReceived);

    thriftDataReceiver.stop();

    log.info("Test Server Stopped");
  }
Exemple #2
0
  public void start(int receiverPort) throws DataBridgeException {
    KeyStoreUtil.setKeyStoreParams();
    DataBridge databridge =
        new DataBridge(
            new AuthenticationHandler() {
              @Override
              public boolean authenticate(String userName, String password) {
                return true; // allays authenticate to true
              }

              @Override
              public String getTenantDomain(String userName) {
                return "admin";
              }
            },
            new InMemoryStreamDefinitionStore());
    thriftDataReceiver = new ThriftDataReceiver(receiverPort, databridge);

    databridge.subscribe(
        new AgentCallback() {
          int totalSize = 0;

          public void definedStream(StreamDefinition streamDefinition, Credentials credentials) {
            log.info("Added StreamDefinition " + streamDefinition);
          }

          @Override
          public void removeStream(StreamDefinition streamDefinition, Credentials credentials) {
            log.info("Removed StreamDefinition " + streamDefinition);
          }

          @Override
          public void receive(List<Event> eventList, Credentials credentials) {
            log.info(
                "eventListSize="
                    + eventList.size()
                    + " eventList "
                    + eventList
                    + " for username "
                    + credentials.getUsername());
            eventReceived = true;
            stop();
          }
        });

    try {
      String address = HostAddressFinder.findAddress("localhost");
      log.info("Test Server starting on " + address);
      thriftDataReceiver.start(address);
      log.info("Test Server Started");
    } catch (SocketException e) {
      log.error("Test Server not started !", e);
    }
  }