Author: jsong
Date: Thu Mar 3 11:30:04 2005
New Revision: 156066
URL: http://svn.apache.org/viewcvs?view=rev&rev=156066
Log:
* adding support to dynamically set webapp name and code generation directories
to milton client generation
* moved some properties into path.properties so they are available in test and
webapp level build.xml's
Modified:
incubator/beehive/trunk/controls/test/build.xml
incubator/beehive/trunk/controls/test/common/path.properties
incubator/beehive/trunk/controls/test/infra/milton/milton.jar
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfAccesser.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfClient.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsAccesser.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsClient.java
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/MiltonTestClient.java
incubator/beehive/trunk/controls/test/webapps/build.xml
Modified: incubator/beehive/trunk/controls/test/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/build.xml?view=diff&r1=156065&r2=156066
==============================================================================
--- incubator/beehive/trunk/controls/test/build.xml (original)
+++ incubator/beehive/trunk/controls/test/build.xml Thu Mar 3 11:30:04 2005
@@ -19,7 +19,7 @@
<taskdef name="mantis"
classname="org.apache.beehive.test.tools.mantis.MantisTask"
classpathref="mantis.classpath"/>
-
+
<property name="test.logs" location="${controls.test.root}/logs"/>
<property name="derby.data" location="${controls.test.root}/test"/>
@@ -210,7 +210,7 @@
debug="on"
compileByExtension="true"
classpathref="test.classpath"
- srcExtensions="*.java,*.jcx,*.jcs" >
+ srcExtensions="*.java,*.jcx,*.jcs">
</apt>
<!-- Do control assembly. -->
@@ -300,7 +300,7 @@
</apt>
<!-- compile junits generated by mantis-drivers -->
- <apt srcdir="${mantis.milton.control.test.units}"
+ <apt srcdir="${mantis.milton.control.test.accessers}"
destdir="${build.tests}"
gendir="${build.beansrc}"
classpathref="test.classpath"
@@ -497,7 +497,7 @@
config="${mantis.config}"
timeout="10000"
aptcommand="${os.JAVA_HOME}/bin/apt">
- <include name="build/testsrcgen/**/*.java"/>
+ <include name="${mantis.milton.control.test.accessers}/**/*.java"/>
<include name="src/units/**/*.java"/>
</mantis>
</target>
@@ -515,8 +515,8 @@
config="${mantis.config}"
timeout="10000"
processor="org.apache.beehive.test.tools.milton.mantis.MiltonProcessor"
- aptcommand="${os.JAVA_HOME}/bin/apt">
- </mantis>
+
processorArgs="webapp.name=${controls.test.webapp.name},accesser.src.gendir=${milton.accesser.src.gendir},webapp.gen.dir=${controls.webapp.dir.name}"
+ aptcommand="${os.JAVA_HOME}/bin/apt"/>
</target>
</project>
Modified: incubator/beehive/trunk/controls/test/common/path.properties
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/common/path.properties?view=diff&r1=156065&r2=156066
==============================================================================
--- incubator/beehive/trunk/controls/test/common/path.properties (original)
+++ incubator/beehive/trunk/controls/test/common/path.properties Thu Mar 3
11:30:04 2005
@@ -14,6 +14,8 @@
controls.test.auxilaries=${controls.test.src}/auxilaries
controls.test.webapp.root=${controls.test.root}/webapps
+controls.test.webapp.name=controlsWeb
+controls.webapp.dir.name=webapps
build.dir=${controls.test.root}/build
build.classes=${build.dir}/classes
@@ -53,13 +55,12 @@
mantis.xbean.jar=${mantis.home}/xbean-1.0.2.jar
mantis.config=${mantis.home}/mantis.properties
-
mantis.runtime.basedir=${controls.test.root}
-
+milton.accesser.src.gendir=testsrcgen
mantis.milton.srcgen.dir=${build.dir}
mantis.milton.bingen.dir=${build.dir}
mantis.milton.log.dir=${build.dir}/mantis.milton.logs
-mantis.milton.control.test.units=${mantis.milton.srcgen.dir}/testsrcgen
+mantis.milton.control.test.accessers=${mantis.milton.srcgen.dir}/${milton.accesser.src.gendir}
mantis.tch.srcgen.dir=${build.dir}/mantis.tch.cases
mantis.tch.bingen.dir=${build.dir}/mantis.tch.bingen
Modified: incubator/beehive/trunk/controls/test/infra/milton/milton.jar
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/infra/milton/milton.jar?view=diff&r1=156065&r2=156066
==============================================================================
Binary files - no diff available.
Modified:
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfAccesser.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfAccesser.java?view=diff&r1=156065&r2=156066
==============================================================================
---
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfAccesser.java
(original)
+++
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfAccesser.java
Thu Mar 3 11:30:04 2005
@@ -18,10 +18,8 @@
public class JpfAccesser extends JpfClient
{
protected final String JPF_ACCESSER_TEMPLATE_NAME =
"org/apache/beehive/test/tools/milton/mantis/generator/MiltonJpfAccesser.vm";
- protected final String JPF_ACCESSER_DIR = "testsrcgen"; // this should
be dynamic!
-
protected String _jpfAccesserPackage = "tests.jpf.";
- protected String _jpfAccesserLocation = JPF_ACCESSER_DIR;
+ protected String _jpfAccesserLocation = null;
protected String _jpfAccesserName = "";
/*
@@ -33,9 +31,9 @@
public JpfAccesser(MiltonTestSuite p_mts,
AnnotationProcessorEnvironment p_env)
{
super(p_mts, p_env);
-
this._templateName = JPF_ACCESSER_TEMPLATE_NAME;
-
+ this._jpfAccesserLocation = super._accesserDir;
+
// Create a client accessor package
String packageReWriter = "(.*)\\.(.+)$";
Pattern packagePattern = Pattern.compile(packageReWriter);
@@ -51,10 +49,10 @@
this._jpfAccesserName = p_mts.getName().startsWith("Test") ?
p_mts.getName() :
"Test" + p_mts.getName();
- this._jpfAccesserLocation += "/" +
this._jpfAccesserPackage.replace(".", "/") +
+ this._jpfAccesserLocation +=
this._jpfAccesserPackage.replace(".", "/") +
"/" + _jpfAccesserName
+ ".java";
- this._context.put("jpf_webapp_name", super.WEBAPP_NAME);
+ this._context.put("jpf_webapp_name", super._webappName);
this._context.put("jpf_accesser_package",
this._jpfAccesserPackage);
this._context.put("jpf_accesser_name", _jpfAccesserName);
this._context.put("jpf_action_call_prefix",
super._jpfActionPath);
Modified:
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfClient.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfClient.java?view=diff&r1=156065&r2=156066
==============================================================================
---
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfClient.java
(original)
+++
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JpfClient.java
Thu Mar 3 11:30:04 2005
@@ -19,8 +19,6 @@
public class JpfClient extends MiltonTestClient
{
protected final String JPF_TEMPLATE_NAME =
"org/apache/beehive/test/tools/milton/mantis/generator/MiltonJpf.vm";
- protected final String WEBAPP_NAME = "controlsWeb"; //TODO: should be
dynamic
- protected final String WEBAPP_DIR = "webapps/" + WEBAPP_NAME; //TODO:
this should be dynamic - waiting for Mantis support for -A
protected String _jpfPackage;
protected String _jpfLocation;
@@ -36,14 +34,14 @@
{
super(p_mts, p_env);
this._templateName = JPF_TEMPLATE_NAME;
-
+
String[] pkg = p_mts.getPackageName().split("\\.");
//TODO: should i handle the 'noPackage' case or error out?
this._jpfPackage = pkg.length >= 1 ? pkg[pkg.length-1] :
"noPackage";
//TODO: make some of these values into externally overridable
properties
this._jpfPackage = "milton.pageflows." + this._jpfPackage + "."
+ p_mts.getName();
- this._jpfActionPath = this.WEBAPP_NAME + "/" +
this._jpfPackage.replace(".", "/");
- this._jpfLocation = WEBAPP_DIR + "/WEB-INF/src/" +
this._jpfPackage.replace(".", "/") +
+ this._jpfActionPath = super._webappDir + super._webappName +
"/" + this._jpfPackage.replace(".", "/");
+ this._jpfLocation = super._webappDir + super._webappName +
"/WEB-INF/src/" + this._jpfPackage.replace(".", "/") +
"/Controller.jpf";
this._context.put("jpf_package", this._jpfPackage);
Modified:
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsAccesser.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsAccesser.java?view=diff&r1=156065&r2=156066
==============================================================================
---
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsAccesser.java
(original)
+++
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsAccesser.java
Thu Mar 3 11:30:04 2005
@@ -18,10 +18,8 @@
public class JwsAccesser extends JwsClient
{
protected final String JWS_ACCESSER_TEMPLATE_NAME =
"org/apache/beehive/test/tools/milton/mantis/generator/MiltonJwsAccesser.vm";
- protected final String JWS_ACCESSER_DIR = "testsrcgen"; // this should
be dynamic - waiting on Mantis support for -A!
-
protected String _jwsAccesserPackage = "tests.jws.";
- protected String _jwsAccesserLocation = JWS_ACCESSER_DIR;
+ protected String _jwsAccesserLocation = null;
protected String _jwsAccesserName = "";
/*
@@ -34,7 +32,8 @@
{
super(p_mts, p_env);
this._templateName = JWS_ACCESSER_TEMPLATE_NAME;
-
+ this._jwsAccesserLocation = super._accesserDir;
+
// Create a client accessor package
String packageReWriter = "(.*)\\.(.+)$";
Pattern packagePattern = Pattern.compile(packageReWriter);
@@ -51,9 +50,9 @@
this._jwsAccesserName = p_mts.getName().startsWith("Test") ?
p_mts.getName() :
"Test" + p_mts.getName();
- this._jwsAccesserLocation += "/" +
this._jwsAccesserPackage.replace(".", "/") +
+ this._jwsAccesserLocation +=
this._jwsAccesserPackage.replace(".", "/") +
"/" + _jwsAccesserName
+ ".java";
-
+
this._context.put("jws_accesser_package",
this._jwsAccesserPackage);
this._context.put("jws_accesser_name", _jwsAccesserName);
this._context.put("jws_accesser_call_path", super._jwsCallPath);
Modified:
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsClient.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsClient.java?view=diff&r1=156065&r2=156066
==============================================================================
---
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsClient.java
(original)
+++
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/JwsClient.java
Thu Mar 3 11:30:04 2005
@@ -19,8 +19,6 @@
public class JwsClient extends MiltonTestClient
{
protected final String TEMPLATE_NAME =
"org/apache/beehive/test/tools/milton/mantis/generator/MiltonJws.vm";
- protected final String WEBAPP_NAME = "controlsWeb"; //TODO: should be
dynamic
- protected final String WEBAPP_DIR = "webapps/" + WEBAPP_NAME; //TODO:
this should be dynamic - waiting for Mantis support for -A
protected final String PKGPREFIX = "milton.webservices.";
protected String _jwsPackage = PKGPREFIX;
@@ -45,8 +43,8 @@
this._jwsPackage += pkg.length >= 1 ? pkg[pkg.length-1] :
"noPackage";
this._jwsPath = this._jwsPackage.replace(".", "/") +
"/" +
p_mts.getName()+"WebService.jws";
- this._jwsCallPath = "/" + this.WEBAPP_NAME + "/" +
this._jwsPath;
- this._jwsLocation = WEBAPP_DIR + "/WEB-INF/src/" +
this._jwsPath;
+ this._jwsCallPath = "/" + super._webappName + "/" +
this._jwsPath;
+ this._jwsLocation = super._webappDir + super._webappName +
"/WEB-INF/src/" + this._jwsPath;
this._context.put("jws_package", this._jwsPackage);
}
Modified:
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/MiltonTestClient.java
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/MiltonTestClient.java?view=diff&r1=156065&r2=156066
==============================================================================
---
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/MiltonTestClient.java
(original)
+++
incubator/beehive/trunk/controls/test/tools/milton/src/org/apache/beehive/test/tools/milton/mantis/generator/MiltonTestClient.java
Thu Mar 3 11:30:04 2005
@@ -2,7 +2,9 @@
import java.io.IOException;
import java.io.Writer;
+import java.util.Map;
import java.util.HashMap;
+import java.util.Set;
import org.apache.beehive.test.tools.milton.mantis.MiltonTestSuite;
@@ -15,12 +17,19 @@
*/
public abstract class MiltonTestClient
{
+ protected final String DEFAULT_WEBAPP_DIR = "webapps/";
+ protected final String DEFAULT_ACCESSER_SRC_DIR = "testsrcgen/";
+
protected String _templateName = null;
protected Writer _writer = null;
protected Filer _filer = null;
protected MiltonTestSuite _mts = null;
protected HashMap<String, Object> _context = new HashMap<String,
Object>();
-
+ protected Map<String, String> _options;
+ protected String _webappName = null;
+ protected String _webappDir = null;
+ protected String _accesserDir = null;
+
/*
* Construct a MiltonTestClient
*
@@ -34,6 +43,27 @@
{
this._mts = p_mts;
this._filer = p_env.getFiler();
+ this._options = p_env.getOptions();
+
+ // Get settings from apt environment
+ _webappName = getOption("webapp.name");
+
+ if (null == _webappName)
+ throw new IllegalStateException("You must supply a
-Awebapp.name to APT via Mantis");
+
+ _webappDir = getOption("webapp.gen.dir");
+
+ if (null == _webappDir)
+ _webappDir = DEFAULT_WEBAPP_DIR;
+ else if (! _webappDir.endsWith("/"))
+ _webappDir += "/";
+
+ _accesserDir = getOption("accesser.src.gendir");
+
+ if (null == _accesserDir)
+ _accesserDir = DEFAULT_ACCESSER_SRC_DIR;
+ else if (! _accesserDir.endsWith("/"))
+ _accesserDir += "/";
}
/*
@@ -70,5 +100,28 @@
public HashMap getContext()
{
return this._context;
+ }
+
+
+ /*
+ * there is a bug in apt AnnotationProcesserEnvironment.getOptions()
+ * in that the Map that is returned has the key and the value stored
in the key.
+ * for example -Afoo=bar will actually have a key of: -Afoo=bar and no
value.
+ */
+ protected String getOption(String p_key)
+ {
+ if (null == p_key)
+ throw new IllegalArgumentException("Key cannot be null");
+
+ Set<String> keys = this._options.keySet();
+ for (String key : keys) {
+ String[] option = key.split("=");
+ if (option.length != 2)
+ continue;
+ if (option[0].equalsIgnoreCase("-A" + p_key))
+ return option[1];
+ }
+
+ return null; // return null if no matches are found
}
}
Modified: incubator/beehive/trunk/controls/test/webapps/build.xml
URL:
http://svn.apache.org/viewcvs/incubator/beehive/trunk/controls/test/webapps/build.xml?view=diff&r1=156065&r2=156066
==============================================================================
--- incubator/beehive/trunk/controls/test/webapps/build.xml (original)
+++ incubator/beehive/trunk/controls/test/webapps/build.xml Thu Mar 3 11:30:04
2005
@@ -13,9 +13,8 @@
<import file="../../../beehive-imports.xml"/>
<property file="../common/path.properties"/>
- <property name="webapp.name" value="controlsWeb"/>
<property name="server.root.url" value="http://localhost:8080"/>
- <property name="webapp.waitfor.url"
value="${server.root.url}/${webapp.name}"/>
+ <property name="webapp.waitfor.url"
value="${server.root.url}/${controls.test.webapp.name}"/>
<property name="dbControl.jar"
location="${beehive.home}/samples/controls-db/build/dbControl.jar"/>
<property name="derby.jar"
location="${beehive.home}/external/derby/derby_46005.jar"/>
@@ -41,15 +40,14 @@
</target>
<target name="-init">
-
- <property name="webapp.build.dir" location="${build.dir}/webapps"/>
- <property name="webapp.dir"
location="${webapp.build.dir}/${webapp.name}"/>
+ <property name="webapp.build.dir"
value="${build.dir}/${controls.webapp.dir.name}"/>
+ <property name="webapp.dir"
location="${webapp.build.dir}/${controls.test.webapp.name}"/>
<available file="${webapp.dir}" property="webapp.dir.present"/>
<mkdir dir="${webapp.build.dir}"/>
- <property
file="${controls.test.webapp.root}/${webapp.name}/app.properties"/>
+ <property
file="${controls.test.webapp.root}/${controls.test.webapp.name}/app.properties"/>
<condition property="do.inject.netui">
<istrue value="${app.inject.netui}"/>
@@ -86,7 +84,7 @@
<!-- webapps are copied into a staging directory where additional build
steps can be performed -->
<target name="stage.webapp" depends="-init">
<copy todir="${webapp.dir}" overwrite="true">
- <fileset dir="${controls.test.webapp.root}/${webapp.name}"/>
+ <fileset
dir="${controls.test.webapp.root}/${controls.test.webapp.name}"/>
</copy>
</target>
@@ -123,17 +121,17 @@
</target>
<target name="-inject.netui" if="do.inject.netui">
- <echo message="Injecting NetUI in ${webapp.name}"/>
+ <echo message="Injecting NetUI in ${controls.test.webapp.name}"/>
<deploy-netui webappDir="${webapp.dir}"/>
</target>
<target name="-inject.wsm" if="do.inject.wsm">
- <echo message="Injecting WSM in ${webapp.name}"/>
+ <echo message="Injecting WSM in ${controls.test.webapp.name}"/>
<deploy-wsm webappDir="${webapp.dir}"/>
</target>
<target name="-inject.milton" if="do.inject.milton">
- <echo message="Injecting ${milton.jar} to ${webapp.name}"/>
+ <echo message="Injecting ${milton.jar} to
${controls.test.webapp.name}"/>
<mkdir dir="${webapp.dir}/WEB-INF/lib"/>
<copy file="${milton.jar}" todir="${webapp.dir}/WEB-INF/lib"
@@ -153,14 +151,14 @@
</target>
<target name="-inject.derby" if="do.inject.derby">
- <echo message="Injecting ${derby.jar} to ${webapp.name}"/>
+ <echo message="Injecting ${derby.jar} to
${controls.test.webapp.name}"/>
<copy todir="${webapp.dir}/WEB-INF/lib"
file="${derby.jar}" verbose="true"
overwrite="true" failonerror="true"/>
</target>
<target name="-inject.dbControl" if="do.inject.dbControl">
- <echo message="Injecting ${dbControl.jar} to ${webapp.name}"/>
+ <echo message="Injecting ${dbControl.jar} to
${controls.test.webapp.name}"/>
<copy todir="${webapp.dir}/WEB-INF/lib"
file="${dbControl.jar}" verbose="true"
overwrite="true" failonerror="true"/>
@@ -222,7 +220,7 @@
<target name="clean" description="Clean webapp" depends="-init"
if="webapp.dir.present">
<echo message="----------------------------------------------"/>
- <echo message="| Controls ${webapp.name} clean starting |"/>
+ <echo message="| Controls ${controls.test.webapp.name} clean
starting |"/>
<echo message="----------------------------------------------"/>
<undeploy-netui webappDir="${webapp.dir}"/>
@@ -231,13 +229,13 @@
<delete file="velocity.log"/>
<echo message="----------------------------------------------"/>
- <echo message="| Controls ${webapp.name} clean ending |"/>
+ <echo message="| Controls ${controls.test.webapp.name} clean
ending |"/>
<echo message="----------------------------------------------"/>
</target>
<target name="scrub" depends="clean" description="Scrub webapp">
- <delete dir="${tomcat.dir}/work/Catalina/localhost/${webapp.name}"
includeEmptyDirs="true"/>
- <delete
file="${tomcat.dir}/conf/Catalina/localhost/${webapp.name}.xml"/>
+ <delete
dir="${tomcat.dir}/work/Catalina/localhost/${controls.test.webapp.name}"
includeEmptyDirs="true"/>
+ <delete
file="${tomcat.dir}/conf/Catalina/localhost/${controls.test.webapp.name}.xml"/>
</target>
<!-- ================================================================ -->
@@ -246,15 +244,15 @@
<!-- -->
<!-- ================================================================ -->
<target name="deploy" description="Deploy webapp" depends="-init">
- <deploy-webapp webappDir="${webapp.dir}" contextPath="${webapp.name}"/>
+ <deploy-webapp webappDir="${webapp.dir}"
contextPath="${controls.test.webapp.name}"/>
</target>
<target name="undeploy" description="Undeploy webapp">
- <undeploy-webapp contextPath="${webapp.name}"/>
+ <undeploy-webapp contextPath="${controls.test.webapp.name}"/>
</target>
<target name="redeploy" description="Redeploy webapp">
- <undeploy-webapp contextPath="${webapp.name}"/>
+ <undeploy-webapp contextPath="${controls.test.webapp.name}"/>
</target>
<!-- ================================================================ -->
@@ -283,7 +281,7 @@
</target>
<target name="ensure.deployed" description="Deploy webapp for the test
recorder">
- <echo>Ensuring that the webapp ${webapp.name} is deployed on a running
server at the url ${webapp.waitfor.url}</echo>
+ <echo>Ensuring that the webapp ${controls.test.webapp.name} is
deployed on a running server at the url ${webapp.waitfor.url}</echo>
<waitfor maxwait="5" maxwaitunit="second"
timeoutproperty="unavailable">
<http url="${webapp.waitfor.url}"/>