@Test
 public void testDeploymentManager() throws Exception {
   DeploymentManager manager = getDeploymentManager();
   assertNotNull("DeploymentManager not null", manager);
   Target target = manager.getTargets()[0];
   assertEquals("ServerDeploymentManager target", target.getDescription());
 }
  private ProgressObject jsr88Undeploy(TargetModuleID[] resultTargetModuleIDs) throws Exception {
    DeploymentManager manager = getDeploymentManager();
    Target[] targets = manager.getTargets();
    assertEquals(1, targets.length);

    ProgressObject progress = manager.stop(resultTargetModuleIDs);
    awaitCompletion(progress, 5000);

    progress = manager.undeploy(resultTargetModuleIDs);
    awaitCompletion(progress, 5000);

    return progress;
  }
  private ProgressObject jsr88Deploy(Archive<?> archive) throws Exception {
    // Get the deployment manager and the distribution targets
    DeploymentManager manager = getDeploymentManager();
    Target[] targets = manager.getTargets();
    assertEquals(1, targets.length);

    InputStream deploymentPlan = createDeploymentPlan(archive.getName());

    // Deploy the test archive
    InputStream inputStream = archive.as(ZipExporter.class).exportAsInputStream();
    ProgressObject progress = manager.distribute(targets, inputStream, deploymentPlan);
    StateType state = awaitCompletion(progress, 5000);

    if (state == StateType.COMPLETED) {
      progress = manager.start(progress.getResultTargetModuleIDs());
      awaitCompletion(progress, 5000);
    }

    return progress;
  }
  @Test
  public void testListAvailableModules() throws Exception {
    DeploymentManager manager = getDeploymentManager();
    Target[] targets = manager.getTargets();
    TargetModuleID[] availableModules = manager.getAvailableModules(ModuleType.EAR, targets);
    assertNull(availableModules);

    ProgressObject progress = jsr88Deploy(getEarArchive());
    TargetModuleID[] targetModules = progress.getResultTargetModuleIDs();
    try {
      availableModules = manager.getAvailableModules(ModuleType.EAR, targets);
      assertNotNull(availableModules);
      assertEquals(1, availableModules.length);

      TargetModuleID targetModuleID = availableModules[0];
      String moduleID = targetModuleID.getModuleID();
      assertTrue("Ends with deployment-app.ear", moduleID.endsWith("deployment-app.ear"));

      // [TODO] verify child modules

    } finally {
      jsr88Undeploy(targetModules);
    }
  }