in src/main/java/org/apache/openejb/cts/deploy/DeployTestUtil.java [727:776]
public boolean testUndeployModule(ModuleType moduleType, File moduleArchive,
File deploymentPlan, String archiveType) throws Exception {
DeploymentManager dm = getDeploymentManager();
Target[] targets = dm.getTargets();
if (targets.length == 0)
return false;
Target targetToDeploy = targets[0];
TargetModuleID distributedModuleID = null;
TargetModuleID[] moduleIDsBeforeDistribute = dm
.getAvailableModules(moduleType, new Target[] { targetToDeploy });
if (archiveType.equals(FILE_ARCHIVE)) {
distributedModuleID = distributeModuleArchive(
new Target[] { targetToDeploy }, moduleArchive, deploymentPlan);
} else {
distributedModuleID = distributeModuleStream(
new Target[] { targetToDeploy }, moduleType,
new FileInputStream(moduleArchive),
new FileInputStream(deploymentPlan), true);
}
// If the distributedModuleID == null, the test is failed
if (distributedModuleID == null)
return false;
// Check if distriburtedModuleID has the same target as deployed target
if (!distributedModuleID.getTarget().getName()
.equals(targetToDeploy.getName()))
return false;
TargetModuleID[] moduleIDsAfterDistribute = dm
.getAvailableModules(moduleType, new Target[] { targetToDeploy });
boolean moduleExistsBeforeDistribute = checkIfModuleExists(
distributedModuleID, moduleIDsBeforeDistribute);
boolean moduleExistsAfterDistribute = checkIfModuleExists(
distributedModuleID, moduleIDsAfterDistribute);
if (!((!moduleExistsBeforeDistribute) && moduleExistsAfterDistribute))
return false;
// start the module
TargetModuleID undeployedModuleID = null;
undeployedModuleID = undeployModule(distributedModuleID);
if (undeployedModuleID == null)
return false;
// Check that the startedModuleID is same as deployed module id
if (!undeployedModuleID.getModuleID()
.equals(distributedModuleID.getModuleID()))
return false;
if (checkIfModuleExists(undeployedModuleID,
dm.getAvailableModules(moduleType, new Target[] { targetToDeploy })))
return false;
else
return true;
}