mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Jean-Noel Rouvignac
14.05.2015 4ef05575b54278d501c7cd3877b48bffa952ca51
Fix randomness in JmxPrivilegeTestCase.
Many thanks Fabio for finding the problem!!



JmxTestCase.java:
In getJmxConnectionHandler(), also wait for the rmiConnector to be available before proceeding.
1 files modified
20 ■■■■ changed files
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxTestCase.java 20 ●●●● patch | view | raw | blame | history
opendj-server-legacy/src/test/java/org/opends/server/protocols/jmx/JmxTestCase.java
@@ -82,17 +82,31 @@
      jmxConnectionHandler = getJmxConnectionHandler(handlers);
    }
    assertNotNull(jmxConnectionHandler);
    final RmiConnector rmiConnector = jmxConnectionHandler.getRMIConnector();
    int cnt = 0;
    while (cnt <= 30 && jmxConnectionHandler.getRMIConnector().jmxRmiConnectorNoClientCertificate == null)
    while (cnt <= 30 && !isReady(rmiConnector))
    {
      Thread.sleep(200);
      cnt++;
    }
    assertNotNull(jmxConnectionHandler.getRMIConnector().jmxRmiConnectorNoClientCertificate,
        "jmxRmiConnectorNoClientCertificate should not be null");
    if (!isReady(rmiConnector))
    {
      assertNotNull(rmiConnector.jmxRmiConnectorNoClientCertificate,
          "jmxRmiConnectorNoClientCertificate should not be null");
      assertTrue(rmiConnector.jmxRmiConnectorNoClientCertificate.isActive(),
          "jmxRmiConnectorNoClientCertificate should be active");
    }
    return jmxConnectionHandler;
  }
  private boolean isReady(RmiConnector rmiConnector)
  {
    return rmiConnector.jmxRmiConnectorNoClientCertificate != null
        && rmiConnector.jmxRmiConnectorNoClientCertificate.isActive();
  }
  private JmxConnectionHandler getJmxConnectionHandler(List<ConnectionHandler> handlers)
  {
    for (ConnectionHandler<?> handler : handlers)