Author: markt
Date: Mon Nov 25 20:42:08 2013
New Revision: 1545398
URL: http://svn.apache.org/r1545398
Log:
Backport automatic deployment changes part 2
Initial test cases
Added:
tomcat/tc7.0.x/trunk/test/deployment/context.xml
- copied unchanged from r1545256, tomcat/trunk/test/deployment/context.xml
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
- copied, changed from r1481835,
tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1481835
Copied:
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
(from r1481835,
tomcat/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?p2=tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java&p1=tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java&r1=1481835&r2=1545398&rev=1545398&view=diff
==============================================================================
---
tomcat/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
(original)
+++
tomcat/tc7.0.x/trunk/test/org/apache/catalina/startup/TestHostConfigAutomaticDeployment.java
Mon Nov 25 20:42:08 2013
@@ -24,6 +24,9 @@ import org.junit.Assert;
import org.junit.Test;
import org.apache.catalina.Container;
+import org.apache.catalina.Engine;
+import org.apache.catalina.Globals;
+import org.apache.catalina.Host;
import org.apache.catalina.LifecycleState;
import org.apache.catalina.core.StandardHost;
import org.apache.catalina.util.ContextName;
@@ -122,7 +125,7 @@ public class TestHostConfigAutomaticDepl
}
private void initTestDeploymentXml() throws IOException {
- File dest = new File(getTomcatInstance().getHost().getConfigBaseFile(),
+ File dest = new File(getConfigBaseFile(getTomcatInstance().getHost()),
APP_NAME + ".xml");
File parent = dest.getParentFile();
if (!parent.isDirectory()) {
@@ -160,12 +163,12 @@ public class TestHostConfigAutomaticDepl
}
File xml = new File(
- host.getConfigBaseFile(), APP_NAME.getBaseName() + ".xml");
+ getConfigBaseFile(host), APP_NAME.getBaseName() + ".xml");
Assert.assertEquals(
Boolean.valueOf(resultXml), Boolean.valueOf(xml.isFile()));
File war = new File(
- host.getAppBaseFile(), APP_NAME.getBaseName() + ".war");
+ getAppBaseFile(host), APP_NAME.getBaseName() + ".war");
Assert.assertEquals(
Boolean.valueOf(resultWar), Boolean.valueOf(war.isFile()));
@@ -174,4 +177,43 @@ public class TestHostConfigAutomaticDepl
Boolean.valueOf(resultDir),
Boolean.valueOf(dir.isDirectory()));
}
+
+
+ // Static methods to compensate for methods that are present in 8.0.x but
+ // not in 7.0.x
+
+ private static File getConfigBaseFile(Host host) {
+ String path = null;
+ if (host.getXmlBase() != null) {
+ path = host.getXmlBase();
+ } else {
+ StringBuilder xmlDir = new StringBuilder("conf");
+ Container parent = host.getParent();
+ if (parent instanceof Engine) {
+ xmlDir.append('/');
+ xmlDir.append(parent.getName());
+ }
+ xmlDir.append('/');
+ xmlDir.append(host.getName());
+ path = xmlDir.toString();
+ }
+
+ return getCanonicalPath(path);
+ }
+
+ private static File getAppBaseFile(Host host) {
+ return getCanonicalPath(host.getAppBase());
+ }
+
+ private static File getCanonicalPath(String path) {
+ File file = new File(path);
+ File base = new File(System.getProperty(Globals.CATALINA_BASE_PROP));
+ if (!file.isAbsolute())
+ file = new File(base,path);
+ try {
+ return file.getCanonicalFile();
+ } catch (IOException e) {
+ return file;
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]