Exemple #1
0
  private void roundtrip(String pConfig, boolean pDoRequest) throws IOException {
    int port = EnvTestUtil.getFreePort();
    String c = pConfig != null ? pConfig + "," : "";
    ServerConfig config = new ServerConfig(c + "host=localhost,port=" + port);
    JolokiaServer server = new JolokiaServer(config);
    server.start();
    // Thread.sleep(2000);
    try {
      if (pDoRequest) {
        URL url = new URL(server.getUrl());
        String resp = EnvTestUtil.readToString(url.openStream());
        assertTrue(resp.matches(".*type.*version.*" + Version.getAgentVersion() + ".*"));
      }
    } finally {
      server.stop();
      try {
        Thread.sleep(10);
      } catch (InterruptedException e) {

      }
    }
  }
Exemple #2
0
 @Test
 public void ssl() throws IOException {
   int port = EnvTestUtil.getFreePort();
   String keystorePath = getKeystorePath();
   String keystorePassword = "******";
   roundtrip(
       "host=localhost,port="
           + port
           + ",keystore="
           + keystorePath
           + ",keystorePassword="******",protocol=https"
           + ",user=roland,password=s!cr!t",
       false);
 }
Exemple #3
0
 // @Test(expectedExceptions = SecurityException.class,expectedExceptionsMessageRegExp = ".*No
 // password.*")
 public void invalidConfig() throws IOException, InterruptedException {
   ServerConfig cfg = new ServerConfig("user=roland,port=" + EnvTestUtil.getFreePort());
   Thread.sleep(1000);
   new JolokiaServer(cfg);
 }