in src/main/java/org/apache/openejb/cts/deploy/DeployTestUtil.java [575:645]
public boolean testStopModule(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 startedModuleID = null;
startedModuleID = startModule(distributedModuleID);
if (startedModuleID == null)
return false;
// Check that the startedModuleID is same as deployed module id
if (!startedModuleID.getModuleID()
.equals(distributedModuleID.getModuleID()))
return false;
TargetModuleID[] runningModules = dm.getRunningModules(moduleType,
new Target[] { targetToDeploy });
if (!checkIfModuleExists(startedModuleID, runningModules))
return false;
// stop the module
TargetModuleID stoppedModuleID = null;
stoppedModuleID = stopModule(startedModuleID);
if (stoppedModuleID == null)
return false;
// Check that the startedModuleID is same as redeployed module id
if (!startedModuleID.getModuleID().equals(stoppedModuleID.getModuleID()))
return false;
boolean modExistsInRunningMods = checkIfModuleExists(stoppedModuleID,
dm.getRunningModules(moduleType, new Target[] { targetToDeploy }));
boolean modExistsInNonRunningMods = checkIfModuleExists(stoppedModuleID,
dm.getNonRunningModules(moduleType, new Target[] { targetToDeploy }));
// Clean up....
// undeploy the module
undeployModule(stoppedModuleID);
if ((!modExistsInRunningMods) && modExistsInNonRunningMods)
return true;
else
return false;
}