You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2013/05/19 11:59:11 UTC
svn commit: r1484253 - in /tomcat/trunk/test:
deployment/contextUnpackWARFalse.war deployment/contextUnpackWARTrue.war
org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
Author: markt
Date: Sun May 19 09:59:11 2013
New Revision: 1484253
URL: http://svn.apache.org/r1484253
Log:
Add test cases for setting unpackWAR on the context
Added:
tomcat/trunk/test/deployment/contextUnpackWARFalse.war (with props)
tomcat/trunk/test/deployment/contextUnpackWARTrue.war (with props)
Modified:
tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
Added: tomcat/trunk/test/deployment/contextUnpackWARFalse.war
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/deployment/contextUnpackWARFalse.war?rev=1484253&view=auto
==============================================================================
Binary file - no diff available.
Propchange: tomcat/trunk/test/deployment/contextUnpackWARFalse.war
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: tomcat/trunk/test/deployment/contextUnpackWARTrue.war
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/deployment/contextUnpackWARTrue.war?rev=1484253&view=auto
==============================================================================
Binary file - no diff available.
Propchange: tomcat/trunk/test/deployment/contextUnpackWARTrue.war
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Modified: tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java?rev=1484253&r1=1484252&r2=1484253&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java (original)
+++ tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Sun May 19 09:59:11 2013
@@ -49,6 +49,10 @@ public class TestHostConfigAutomaticDepl
new File("test/deployment/context.xml");
private static final File WAR_XML_SOURCE =
new File("test/deployment/context.war");
+ private static final File WAR_XML_UNPACKWAR_FALSE_SOURCE =
+ new File("test/deployment/contextUnpackWARFalse.war");
+ private static final File WAR_XML_UNPACKWAR_TRUE_SOURCE =
+ new File("test/deployment/contextUnpackWARTrue.war");
private static final File WAR_SOURCE =
new File("test/deployment/noContext.war");
private static final File DIR_XML_SOURCE =
@@ -175,7 +179,7 @@ public class TestHostConfigAutomaticDepl
*/
@Test
public void testDeploymentXmlExternalWarXmlFFF() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(false, false, false,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false);
@@ -183,7 +187,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlFFT() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(false, false, true,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, true);
@@ -191,7 +195,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlFTF() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(false, true, false,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false);
@@ -199,7 +203,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlFTT() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(false, true, true,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, true);
@@ -207,7 +211,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlTFF() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(true, false, false,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false);
@@ -215,7 +219,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlTFT() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(true, false, true,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, true);
@@ -223,7 +227,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlTTF() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(true, true, false,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, false);
@@ -231,7 +235,7 @@ public class TestHostConfigAutomaticDepl
@Test
public void testDeploymentXmlExternalWarXmlTTT() throws Exception {
- File war = createWarInExternal(true);
+ File war = createWar(WAR_XML_SOURCE, false);
createXmlInConfigBaseForExternal(war);
doTestDeployment(true, true, true,
LifecycleState.STARTED, XML_COOKIE_NAME, true, false, true);
@@ -323,56 +327,56 @@ public class TestHostConfigAutomaticDepl
*/
@Test
public void testDeploymentWarXmlFFF() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(false, false, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarXmlFFT() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(false, false, true,
LifecycleState.STARTED, null, false, true, true);
}
@Test
public void testDeploymentWarXmlFTF() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(false, true, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarXmlFTT() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(false, true, true,
LifecycleState.STARTED, null, false, true, true);
}
@Test
public void testDeploymentWarXmlTFF() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(true, false, false,
LifecycleState.STARTED, WAR_COOKIE_NAME, false, true, false);
}
@Test
public void testDeploymentWarXmlTFT() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(true, false, true,
LifecycleState.STARTED, WAR_COOKIE_NAME, false, true, true);
}
@Test
public void testDeploymentWarXmlTTF() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(true, true, false,
LifecycleState.STARTED, WAR_COOKIE_NAME, true, true, false);
}
@Test
public void testDeploymentWarXmlTTT() throws Exception {
- createWarInAppbase(true);
+ createWar(WAR_XML_SOURCE, true);
doTestDeployment(true, true, true,
LifecycleState.STARTED, WAR_COOKIE_NAME, true, true, true);
}
@@ -386,56 +390,56 @@ public class TestHostConfigAutomaticDepl
*/
@Test
public void testDeploymentWarFFF() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(false, false, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarFFT() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(false, false, true,
LifecycleState.STARTED, null, false, true, true);
}
@Test
public void testDeploymentWarFTF() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(false, true, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarFTT() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(false, true, true,
LifecycleState.STARTED, null, false, true, true);
}
@Test
public void testDeploymentWarTFF() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(true, false, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarTFT() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(true, false, true,
LifecycleState.STARTED, null, false, true, true);
}
@Test
public void testDeploymentWarTTF() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(true, true, false,
LifecycleState.STARTED, null, false, true, false);
}
@Test
public void testDeploymentWarTTT() throws Exception {
- createWarInAppbase(false);
+ createWar(WAR_SOURCE, true);
doTestDeployment(true, true, true,
LifecycleState.STARTED, null, false, true, true);
}
@@ -805,7 +809,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForAppbase();
}
if (startExternalWar) {
- ext = createWarInExternal(true);
+ ext = createWar(WAR_XML_SOURCE, false);
xml = createXmlInConfigBaseForExternal(ext);
}
if (startExternalDir) {
@@ -813,7 +817,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForExternal(ext);
}
if (startWar) {
- war = createWarInAppbase(true);
+ war = createWar(WAR_XML_SOURCE, true);
}
if (startDir) {
dir = createDirInAppbase(true);
@@ -1083,7 +1087,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForAppbase();
}
if (startExternalWar) {
- ext = createWarInExternal(true);
+ ext = createWar(WAR_XML_SOURCE, false);
xml = createXmlInConfigBaseForExternal(ext);
}
if (startExternalDir) {
@@ -1091,7 +1095,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForExternal(ext);
}
if (startWar) {
- war = createWarInAppbase(true);
+ war = createWar(WAR_XML_SOURCE, true);
}
if (startDir) {
dir = createDirInAppbase(true);
@@ -1353,7 +1357,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForAppbase();
}
if (startExternalWar) {
- ext = createWarInExternal(true);
+ ext = createWar(WAR_XML_SOURCE, false);
xml = createXmlInConfigBaseForExternal(ext);
}
if (startExternalDir) {
@@ -1361,7 +1365,7 @@ public class TestHostConfigAutomaticDepl
xml = createXmlInConfigBaseForExternal(ext);
}
if (startWar) {
- war = createWarInAppbase(true);
+ war = createWar(WAR_XML_SOURCE, true);
}
if (startDir) {
dir = createDirInAppbase(true);
@@ -1386,7 +1390,7 @@ public class TestHostConfigAutomaticDepl
break;
case EXT:
if (ext == null && xml == null) {
- ext = createWarInExternal(true);
+ ext = createWar(WAR_XML_SOURCE, false);
xml = createXmlInConfigBaseForExternal(ext);
} else {
Assert.fail();
@@ -1394,7 +1398,7 @@ public class TestHostConfigAutomaticDepl
break;
case WAR:
if (war == null) {
- war = createWarInAppbase(true);
+ war = createWar(WAR_XML_SOURCE, true);
} else {
Assert.fail();
}
@@ -1486,6 +1490,68 @@ public class TestHostConfigAutomaticDepl
}
+ /*
+ * Test context unpackWAR setting.
+ * If context.getUnpackWAR != Host.getUnpackWARs the Host wins.
+ */
+ @Test
+ public void testUnpackWARFFF() throws Exception {
+ doTestUnpackWAR(false, false, false, false);
+ }
+
+ @Test
+ public void testUnpackWARFFT() throws Exception {
+ doTestUnpackWAR(false, false, true, false);
+ }
+
+ public void testUnpackWARFTF() throws Exception {
+ doTestUnpackWAR(false, true, false, false);
+ }
+
+ public void testUnpackWARFTT() throws Exception {
+ doTestUnpackWAR(false, true, true, false);
+ }
+
+ public void testUnpackWARTFF() throws Exception {
+ doTestUnpackWAR(true, false, false, false);
+ }
+
+ public void testUnpackWARTFT() throws Exception {
+ doTestUnpackWAR(true, false, true, false);
+ }
+
+ public void testUnpackWARTTF() throws Exception {
+ doTestUnpackWAR(true, true, false, true);
+ }
+
+ public void testUnpackWARTTT() throws Exception {
+ doTestUnpackWAR(true, true, true, true);
+ }
+
+ private void doTestUnpackWAR(boolean unpackWARs, boolean unpackWAR,
+ boolean external, boolean resultDir) throws Exception {
+
+ Tomcat tomcat = getTomcatInstance();
+ StandardHost host = (StandardHost) tomcat.getHost();
+
+ host.setUnpackWARs(unpackWARs);
+
+ tomcat.start();
+
+ if (unpackWAR) {
+ createWar(WAR_XML_UNPACKWAR_TRUE_SOURCE, external);
+ } else {
+ createWar(WAR_XML_UNPACKWAR_FALSE_SOURCE, external);
+ }
+
+ host.backgroundProcess();
+
+ File dir = new File(host.getAppBase(), APP_NAME.getBaseName());
+ Assert.assertEquals(
+ Boolean.valueOf(resultDir), Boolean.valueOf(dir.isDirectory()));
+ }
+
+
private File createDirInAppbase(boolean withXml) throws IOException {
File dir = new File(getTomcatInstance().getHost().getAppBaseFile(),
APP_NAME.getBaseName());
@@ -1507,25 +1573,16 @@ public class TestHostConfigAutomaticDepl
return ext;
}
- private File createWarInAppbase(boolean withXml) throws IOException {
- File war = new File(getTomcatInstance().getHost().getAppBaseFile(),
+ private File createWar(File src, boolean useAppbase) throws IOException {
+ File dest;
+ if (useAppbase) {
+ dest = new File(getTomcatInstance().getHost().getAppBaseFile(),
APP_NAME.getBaseName() + ".war");
- if (withXml) {
- Files.copy(WAR_XML_SOURCE.toPath(), war.toPath());
} else {
- Files.copy(WAR_SOURCE.toPath(), war.toPath());
+ dest = new File(external, "external" + ".war");
}
- return war;
- }
-
- private File createWarInExternal(boolean withXml) throws IOException {
- File ext = new File(external, "external" + ".war");
- if (withXml) {
- Files.copy(WAR_XML_SOURCE.toPath(), ext.toPath());
- } else {
- Files.copy(WAR_SOURCE.toPath(), ext.toPath());
- }
- return ext;
+ Files.copy(src.toPath(), dest.toPath());
+ return dest;
}
private File createXmlInConfigBaseForAppbase() throws IOException {
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org