Ejemplo n.º 1
0
  @Test
  public void testUnDeployArchive() throws Exception {

    final CommandContext ctx = CommandContextFactory.getInstance().newCommandContext();
    try {
      ctx.connectController();
      ctx.handle("deploy " + cliArchiveFile.getAbsolutePath() + " --script=install.scr");

      // check that now both wars are deployed
      String response =
          HttpRequest.get(getBaseURL(url) + "deployment0/SimpleServlet", 10, TimeUnit.SECONDS);
      assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);
      response =
          HttpRequest.get(getBaseURL(url) + "deployment1/SimpleServlet", 10, TimeUnit.SECONDS);
      assertTrue("Invalid response: " + response, response.indexOf("SimpleServlet") >= 0);

      ctx.handle(
          "undeploy " + "--path=" + cliArchiveFile.getAbsolutePath() + " --script=uninstall.scr");

      // check that both wars are undeployed
      assertTrue(checkUndeployed(getBaseURL(url) + "deployment0/SimpleServlet"));
      assertTrue(checkUndeployed(getBaseURL(url) + "deployment1/SimpleServlet"));
    } finally {
      ctx.terminateSession();
    }
  }
 public static void reloadServer() throws Exception {
   final CommandContext ctx =
       CLITestUtil.getCommandContext(
           "remoting", TestSuiteEnvironment.getServerAddress(), MANAGEMENT_NATIVE_PORT);
   try {
     ctx.connectController();
     ctx.handle("reload");
   } finally {
     ctx.terminateSession();
   }
 }
 @Test
 public void testGreaterThan() throws Exception {
   final CommandContext ctx = CLITestUtil.getCommandContext(cliOut);
   try {
     ctx.connectController();
     ctx.handle(this.getAddPropertyReq("\"5\""));
     assertEquals("5", runIf(ctx, ">", "&&", "\"1\""));
     assertEquals("true", runIf(ctx, ">", "||", "\"1\""));
   } finally {
     ctx.handleSafe(this.getRemovePropertyReq());
     ctx.terminateSession();
     cliOut.reset();
   }
 }
  @After
  public void afterTest() throws Exception {

    StringBuilder buf = undeploy(null, cliTestApp1War.getName(), sgOne);
    buf = undeploy(buf, cliTestAnotherWar.getName(), sgOne);
    buf = undeploy(buf, cliTestApp2War.getName(), sgTwo);
    buf = undeploy(buf, cliTestAppEar.getName(), sgOne + ',' + sgTwo);

    ctx.terminateSession();
    if (buf != null) {
      fail(buf.toString());
    }
    if (afterTestDeployments.size() > 0) {
      fail("Expected to undeploy but failed to: " + afterTestDeployments);
    }
  }
  @Test
  @InSequence(1)
  public void testModClusterAdd() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();

    try {
      ctx.connectController();

      // Add the mod_cluster extension first (not in this profile by default)
      ModelNode request = ctx.buildRequest("/extension=org.wildfly.extension.mod_cluster:add");
      ModelNode response = controllerClient.execute(request);
      String outcome = response.get("outcome").asString();
      Assert.assertEquals(
          "Adding mod_cluster extension failed! " + request.toJSONString(false),
          "success",
          outcome);

      // Now lets execute subsystem add operation but we need to specify a connector
      ctx.getBatchManager().activateNewBatch();
      Batch b = ctx.getBatchManager().getActiveBatch();
      b.add(
          ctx.toBatchedCommand(
              "/socket-binding-group=standard-sockets/socket-binding=mod_cluster:add(multicast-port=23364, multicast-address=224.0.1.105)"));
      b.add(ctx.toBatchedCommand("/subsystem=modcluster:add"));
      b.add(
          ctx.toBatchedCommand(
              "/subsystem=modcluster/mod-cluster-config=configuration:add(connector=http,advertise-socket=mod_cluster)"));
      request = b.toRequest();
      b.clear();
      ctx.getBatchManager().discardActiveBatch();

      response = controllerClient.execute(request);
      outcome = response.get("outcome").asString();
      Assert.assertEquals(
          "Adding mod_cluster subsystem failed! " + request.toJSONString(false),
          "success",
          outcome);
    } finally {
      ctx.terminateSession();
    }
  }
  @Test
  @InSequence(2)
  public void testModClusterRemove() throws Exception {
    final CommandContext ctx = CLITestUtil.getCommandContext();
    final ModelControllerClient controllerClient = managementClient.getControllerClient();

    try {
      ctx.connectController();

      // Test subsystem remove
      ModelNode request = ctx.buildRequest("/subsystem=modcluster:remove");
      ModelNode response = controllerClient.execute(request);
      String outcome = response.get("outcome").asString();
      Assert.assertEquals(
          "Removing mod_cluster subsystem failed! " + request.toJSONString(false),
          "success",
          outcome);

      // Cleanup socket binding
      request =
          ctx.buildRequest(
              "/socket-binding-group=standard-sockets/socket-binding=mod_cluster:remove");
      response = controllerClient.execute(request);
      outcome = response.get("outcome").asString();
      Assert.assertEquals(
          "Removing socket binding failed! " + request.toJSONString(false), "success", outcome);

      // Cleanup and remove the extension
      request = ctx.buildRequest("/extension=org.wildfly.extension.mod_cluster:remove");
      response = controllerClient.execute(request);
      outcome = response.get("outcome").asString();
      Assert.assertEquals(
          "Removing mod_cluster extension failed! " + request.toJSONString(false),
          "success",
          outcome);
    } finally {
      ctx.terminateSession();
    }
  }
Ejemplo n.º 7
0
 public void exit() {
   log.info("exit server");
   ctx.terminateSession();
 }