System.setProperty("org.jboss.logging.provider", "slf4j");
System.setProperty("jboss.server.config.dir", "target/test-classes/wildfly80-config");
final ModelControllerClient client = ModelControllerClient.Factory
.create("localhost", 19990);
ServerDeploymentManager deploymentManager = ServerDeploymentManager.Factory.create(client);
InitialDeploymentPlanBuilder builder = deploymentManager.newDeploymentPlan();
String applName = "wicket-examples.war";
URL applUrl = new URL("mvn:org.apache.wicket/wicket-examples/1.5.3/war");
DeploymentPlan plan = builder.add(applName, applUrl).andDeploy().build();
ServerDeploymentPlanResult result = deploymentManager.execute(plan).get();
UUID actionId = plan.getDeploymentActions().get(0).getId();
ServerDeploymentActionResult actionResult = result.getDeploymentActionResult(actionId);
assertThat(actionResult.getResult(), is(Result.EXECUTED));
plan = deploymentManager.newDeploymentPlan().undeploy(applName).andRemoveUndeployed()
.build();
deploymentManager.execute(plan).get();
actionResult = result.getDeploymentActionResult(actionId);
assertThat(actionResult.getResult(), is(Result.EXECUTED));
}