Example #1
0
  // @Test(timeout=120000)
  public void checkForIDRepeats() throws Exception {
    final int iterations = 2500;
    long repeats = 0;
    logTestStart();
    // Run a few thousand iterations and check for repeats
    Set<Long> observed = new HashSet<Long>(iterations * 2);
    BOSHClientConfig cfg = session.getBOSHClientConfig();
    for (int i = 0; i < iterations; i++) {
      // Initiate a new session
      BOSHClient sess = BOSHClient.create(cfg);
      sess.send(ComposableBody.builder().build());
      StubConnection conn = cm.awaitConnection();
      AbstractBody req = conn.getRequest().getBody();
      String rid = req.getAttribute(Attributes.RID);
      if (!observed.add(Long.valueOf(rid))) {
        repeats++;
      }

      conn.closeConnection();
      sess.close();
    }
    LOG.info("Repeated initial RID " + repeats + " time(s)");
    if (repeats >= 2) {
      fail("Initial RID repeated " + repeats + " times in " + iterations + " iterations");
    }
  }