// Create a scattered web application.
//ScatteredArchive archive = new ScatteredArchive("testapp", ScatteredArchive.Type.WAR);
//use global variable
//warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+ SRC_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
warArchive = new ScatteredArchive(BASE_URI.getRawPath(), ScatteredArchive.Type.WAR);
// required if exist already //The name for this metadata will be obtained by doing metadata.getName()
try {
warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
} catch (java.io.IOException ioe) {
LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/" + WEB_XML + "]");
throw new TestContainerException(ioe);
}
//The name for this metadata will be obtained by doing metadata.getName()
//scatteredArchiveBuilder.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/" + SUN_WEB_XML));
// resources/sun-web.xml is my WEB-INF/sun-web.xml
//archive.addMetadata(new File("resources", "sun-web.xml"));
try {
warArchive.addMetadata(new File(SRC_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", SUN_WEB_XML));
} catch (java.io.IOException ioe) {
LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addMetadata [" + SUN_WEB_XML + "]");
throw new TestContainerException(ioe);
}
// target/classes directory contains my complied servlets
//archive.addClassPath(new File("target", "classes"));
try {
warArchive.addClassPath(new File(TARGET_PATH, CLASSES_PATH));
} catch (java.io.IOException ioe) {
LOGGER.info("Encountered IOException [" + ioe.getMessage() + "] trying to addClassPath [" + TARGET_PATH + "/" + CLASSES_PATH + "]");
throw new TestContainerException(ioe);
}
// resources/MyLogFactory is my META-INF/services/org.apache.commons.logging.LogFactory
//archive.addMetadata(new File("resources", "MyLogFactory"),
//"META-INF/services/org.apache.commons.logging.LogFactory");
LOGGER.info("#1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
System.out.println("jsb, #1 inside method createArchive ==> webXmlGeneratedOnTheFly ==> just created scatteredArchive [" + SRC_WEBAPP_PATH + "] using WEB-INF/web.xml from [" + warArchive.toString() + "]");
} catch (Exception ex) {
throw new TestContainerException(ex);
}
} else {
try {
LOGGER.info("#2 inside method createArchive ==> webXmlGeneratedOnTheFly ==> Creating scatteredArchive [" + TARGET_WEBAPP_PATH + "]");
//use global variable
//warArchive = new ScatteredArchive(baseUri.getRawPath()+File.separator+TARGET_WEBAPP_PATH+File.separator+"myWarArchive", ScatteredArchive.Type.WAR);
warArchive = new ScatteredArchive(BASE_URI.getRawPath(), ScatteredArchive.Type.WAR);
//The name for this metadata will be obtained by doing metadata.getName()
try {
warArchive.addMetadata(new File(TARGET_WEBAPP_PATH + "/" + WEB_INF_PATH + "/", WEB_XML));
} catch (java.io.IOException ioe) {