boolean startExternalDir, boolean startWar, boolean startDir,
int toDelete, boolean resultXml, boolean resultWar,
boolean resultDir, String resultCookieName) throws Exception {
Tomcat tomcat = getTomcatInstance();
StandardHost host = (StandardHost) tomcat.getHost();
// Init
File xml = null;
File ext = null;
File war = null;
File dir = null;
if (startXml && !startExternalWar && !startExternalDir) {
xml = createXmlInConfigBaseForAppbase();
}
if (startExternalWar) {
ext = createWar(WAR_XML_SOURCE, false);
xml = createXmlInConfigBaseForExternal(ext);
}
if (startExternalDir) {
ext = createDirInExternal(true);
xml = createXmlInConfigBaseForExternal(ext);
}
if (startWar) {
war = createWar(WAR_XML_SOURCE, true);
}
if (startDir) {
dir = createDirInAppbase(true);
}
if ((startWar || startExternalWar) && !startDir) {
host.setUnpackWARs(false);
}
// Deploy the files we copied
tomcat.start();
host.backgroundProcess();
// Remove the specified file
switch (toDelete) {
case XML:
ExpandWar.delete(xml);
break;
case EXT:
ExpandWar.delete(ext);
break;
case WAR:
ExpandWar.delete(war);
break;
case DIR:
ExpandWar.delete(dir);
break;
default:
Assert.fail();
}
// Trigger an auto-deployment cycle
host.backgroundProcess();
Context ctxt = (Context) host.findChild(APP_NAME.getName());
// Check the results
// External WAR and DIR should only be deleted if the test is testing
// behaviour when the external resource is deleted
if (toDelete == EXT) {