Author: markt Date: Mon Nov 25 23:30:47 2013 New Revision: 1545455 URL: http://svn.apache.org/r1545455 Log: Backport automatic deployment changes part 17 Add test cases for failed start when anti-resource locking is in use
Added: tomcat/tc7.0.x/trunk/test/deployment/broken.war - copied, changed from r1484786, tomcat/trunk/test/deployment/broken.war Modified: tomcat/tc7.0.x/trunk/ (props changed) tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Propchange: tomcat/tc7.0.x/trunk/ ------------------------------------------------------------------------------ Merged /tomcat/trunk:r1484786,1484861 Copied: tomcat/tc7.0.x/trunk/test/deployment/broken.war (from r1484786, tomcat/trunk/test/deployment/broken.war) URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/deployment/broken.war?p2=tomcat/tc7.0.x/trunk/test/deployment/broken.war&p1=tomcat/trunk/test/deployment/broken.war&r1=1484786&r2=1545455&rev=1545455&view=diff ============================================================================== Binary files - no diff available. Modified: tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java URL: http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java?rev=1545455&r1=1545454&r2=1545455&view=diff ============================================================================== --- tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java (original) +++ tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java Mon Nov 25 23:30:47 2013 @@ -56,6 +56,8 @@ public class TestHostConfigAutomaticDepl new File("test/deployment/contextUnpackWARTrue.war"); private static final File WAR_SOURCE = new File("test/deployment/noContext.war"); + private static final File WAR_BROKEN_SOURCE = + new File("test/deployment/broken.war"); private static final File DIR_XML_SOURCE = new File("test/deployment/dirContext"); private static final File DIR_SOURCE = @@ -1567,6 +1569,41 @@ public class TestHostConfigAutomaticDepl } + @Test + public void testBrokenAppWithAntiLockingF() throws Exception { + testBrokenAppWithAntiLocking(false); + } + + @Test + public void testBrokenAppWithAntiLockingT() throws Exception { + testBrokenAppWithAntiLocking(true); + } + + private void testBrokenAppWithAntiLocking(boolean unpackWARs) + throws Exception { + + Tomcat tomcat = getTomcatInstance(); + StandardHost host = (StandardHost) tomcat.getHost(); + + host.setUnpackWARs(unpackWARs); + + File war = createWar(WAR_BROKEN_SOURCE, false); + createXmlInConfigBaseForExternal(war, true); + + File dir = new File(getAppBaseFile(host), APP_NAME.getBaseName()); + + tomcat.start(); + + // Simulate deploy on start-up + tomcat.getHost().backgroundProcess(); + + Assert.assertTrue(war.isFile()); + if (unpackWARs) { + Assert.assertTrue(dir.isDirectory()); + } + } + + private File createDirInAppbase(boolean withXml) throws IOException { File dir = new File(getAppBaseFile(getTomcatInstance().getHost()), APP_NAME.getBaseName()); @@ -1616,6 +1653,11 @@ public class TestHostConfigAutomaticDepl private File createXmlInConfigBaseForExternal(File ext) throws IOException { + return createXmlInConfigBaseForExternal(ext, false); + } + + private File createXmlInConfigBaseForExternal(File ext, boolean antiLocking) + throws IOException { File xml = new File(getConfigBaseFile(getTomcatInstance().getHost()), APP_NAME + ".xml"); File parent = xml.getParentFile(); @@ -1626,9 +1668,16 @@ public class TestHostConfigAutomaticDepl FileOutputStream fos = null; try { fos = new FileOutputStream(xml); - fos.write(("<Context sessionCookieName=\"" + XML_COOKIE_NAME + - "\" docBase=\"" + ext.getAbsolutePath() + - "\" />").getBytes(B2CConverter.ISO_8859_1)); + StringBuilder context = new StringBuilder(); + context.append("<Context sessionCookieName=\""); + context.append(XML_COOKIE_NAME); + context.append("\" docBase=\""); + context.append(ext.getAbsolutePath()); + if (antiLocking) { + context.append("\" antiResourceLocking=\"true"); + } + context.append("\" />"); + fos.write(context.toString().getBytes(B2CConverter.ISO_8859_1)); } finally { if (fos != null) { fos.close(); --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org