[gwt-maven commit] r976 - Fix test mojo so that it creates catalina base if needed, and adds catalina base property ...

1 view
Skip to first unread message

codesite...@google.com

unread,
Mar 30, 2009, 11:32:33 AM3/30/09
to gwt-ma...@googlegroups.com
Author: charlie.collins
Date: Mon Mar 30 08:30:19 2009
New Revision: 976

Modified:

trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/AbstractGWTMojo.java

trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTMojo.java

trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTTestMojo.java

trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterUnix.java

trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterWindows.java

Log:
Fix test mojo so that it creates catalina base if needed, and adds catalina
base property to test scripts.

Modified:
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/AbstractGWTMojo.java
==============================================================================
---
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/AbstractGWTMojo.java
(original)
+++
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/AbstractGWTMojo.java
Mon Mar 30 08:30:19 2009
@@ -32,6 +32,7 @@
import org.codehaus.classworlds.ClassWorld;
import org.codehaus.plexus.util.FileUtils;

+import com.totsp.mavenplugin.gwt.support.MakeCatalinaBase;
import com.totsp.mavenplugin.gwt.util.BuildClasspathUtil;
import com.totsp.mavenplugin.gwt.util.DependencyScope;

@@ -418,6 +419,30 @@
throw new RuntimeException(e);
}
}
+
+ /**
+ * Create embedded GWT tomcat base dir based on properties.
+ *
+ * @throws Exception
+ */
+ public void makeCatalinaBase() throws Exception {
+ getLog().debug("make catalina base for embedded Tomcat");
+
+ if (this.getWebXml() != null && this.getWebXml().exists()) {
+ this.getLog().info("source web.xml present - " +
this.getWebXml() + " - using it with embedded Tomcat");
+ } else {
+ this.getLog().info("source web.xml NOT present, using default
empty web.xml for shell");
+ }
+
+ // note that MakeCatalinaBase (support jar) will use emptyWeb.xml
if webXml does not exist
+ String[] args = { this.getTomcat().getAbsolutePath(),
this.getWebXml().getAbsolutePath(), this.getShellServletMappingURL() };
+ MakeCatalinaBase.main(args);
+
+ if ((this.getContextXml() != null) &&
this.getContextXml().exists()) {
+ this.getLog().info("contextXml parameter present - " +
this.getContextXml() + " - using it for embedded Tomcat ROOT.xml");
+ FileUtils.copyFile(this.getContextXml(), new
File(this.getTomcat(), "conf/gwt/localhost/ROOT.xml"));
+ }
+ }

//
// accessors/mutators
@@ -452,7 +477,7 @@
}

public String getJvm() {
- return jvm;
+ return this.jvm;
}

public void setExtraJvmArgs(String extraJvmArgs) {
@@ -652,7 +677,7 @@
}

public boolean getResourcesOnPath() {
- return resourcesOnPath;
+ return this.resourcesOnPath;
}

public void setResourcesOnPath(boolean resourcesOnPath) {
@@ -760,28 +785,28 @@
}

public boolean isCompileSkip() {
- return compileSkip;
+ return this.compileSkip;
}

/**
* @return the whitelist
*/
public String getWhitelist() {
- return whitelist;
+ return this.whitelist;
}

/**
* @return the blacklist
*/
public String getBlacklist() {
- return blacklist;
+ return this.blacklist;
}

/**
* @return the showTreeLogger
*/
public boolean isShowTreeLogger() {
- return showTreeLogger;
+ return this.showTreeLogger;
}

/**
@@ -795,7 +820,7 @@
* @return the localWorkers
*/
public int getLocalWorkers() {
- return localWorkers;
+ return this.localWorkers;
}

/**
@@ -809,7 +834,7 @@
* @return the workDir
*/
public File getWorkDir() {
- return workDir;
+ return this.workDir;
}

/**
@@ -823,7 +848,7 @@
* @return the extraDir
*/
public File getExtraDir() {
- return extraDir;
+ return this.extraDir;
}

/**
@@ -831,6 +856,5 @@
*/
public void setExtraDir(File extraDir) {
this.extraDir = extraDir;
- }
-
+ }
}

Modified:
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTMojo.java
==============================================================================
---
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTMojo.java
(original)
+++
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTMojo.java
Mon Mar 30 08:30:19 2009
@@ -24,12 +24,10 @@

import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.FileUtils;

import com.totsp.mavenplugin.gwt.scripting.ScriptUtil;
import com.totsp.mavenplugin.gwt.scripting.ScriptWriter;
import com.totsp.mavenplugin.gwt.scripting.ScriptWriterFactory;
-import com.totsp.mavenplugin.gwt.support.MakeCatalinaBase;

/**
* Runs the the project in the GWTShell for development.
@@ -70,29 +68,5 @@

// run it
ScriptUtil.runScript(exec);
- }
-
- /**
- * Create embedded GWT tomcat base dir based on properties.
- *
- * @throws Exception
- */
- public void makeCatalinaBase() throws Exception {
- getLog().debug("make catalina base for embedded Tomcat");
-
- if (this.getWebXml() != null && this.getWebXml().exists()) {
- this.getLog().info("source web.xml present - " +
this.getWebXml() + " - using it with embedded Tomcat");
- } else {
- this.getLog().info("source web.xml NOT present, using default
empty web.xml for shell");
- }
-
- // note that MakeCatalinaBase (support jar) will use emptyWeb.xml
if webXml does not exist
- String[] args = { this.getTomcat().getAbsolutePath(),
this.getWebXml().getAbsolutePath(), this.getShellServletMappingURL() };
- MakeCatalinaBase.main(args);
-
- if ((this.getContextXml() != null) &&
this.getContextXml().exists()) {
- this.getLog().info("contextXml parameter present - " +
this.getContextXml() + " - using it for embedded Tomcat ROOT.xml");
- FileUtils.copyFile(this.getContextXml(), new
File(this.getTomcat(), "conf/gwt/localhost/ROOT.xml"));
- }
- }
+ }
}

Modified:
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTTestMojo.java
==============================================================================
---
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTTestMojo.java
(original)
+++
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/GWTTestMojo.java
Mon Mar 30 08:30:19 2009
@@ -29,39 +29,48 @@
*/
public class GWTTestMojo extends AbstractGWTMojo {

-/*
- * This is based on the clever work Will Pugh did in the
original "gwtTest" stuff.
- * This has been refactored to make it a bit more robust, and to use the
same write
- * script approach all the other GWT-Maven mojos use (and those are used
because
- * they are easier to tweak and debug than the Maven classpath -
unfortunately).
- *
- * Disclaimer: this is a giant hack because Surefire has some issues with
GWTTestCase.
- *
- * Surefire states that it offers multiple ways to load the classpath
- *
(http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html),
- * but it doesn't seem to work for the plain java class path case.
Manifest class path works,
- * and isolated classpath also works, but just getting to a plain java
class path does not seem to work
- * (surefire still refers to /tmp/surefireX). Without a plain java class
path GWTTestCase
- * won't work - because GWTTestCase inspects the classpath and sets itself
up, and it
- * doesn't like anything other than a plain java classpath (doesn't like a
manifest jar, or isolated).
- * Also, presuming surefire did work, in plain java class path mode, we
would then still be
- * susceptible to the line too long on Windows issue surefire works around
with the other modes.
- *
- * A lot of research into just using surefire was done (we don't want to
have to offer this special class for GWTTestCase) - after
- * RTFM and trying the useSystemClassLoader and useManifestOnlyJar
settings, various ways, we still
- * could never get it to work. These issues are similar to our experiences
- *: http://www.mail-archive.com/us...@maven.apache.org/msg87660.html - and
- * http://jira.codehaus.org/browse/SUREFIRE-508.
- *
- * Hopefully we can kill this someday, it's a hack, but for now, this is
the ONLY way
- * to run GWTTestCase based tests from an automated Maven build.
- */
-
+ /*
+ * This is based on the clever work Will Pugh did in the
original "gwtTest" stuff.
+ * This has been refactored to make it a bit more robust, and to use
the same write
+ * script approach all the other GWT-Maven mojos use (and those are
used because
+ * they are easier to tweak and debug than the Maven classpath -
unfortunately).
+ *
+ * Disclaimer: this is a giant hack because Surefire has some issues
with GWTTestCase.
+ *
+ * Surefire states that it offers multiple ways to load the classpath
+ *
(http://maven.apache.org/plugins/maven-surefire-plugin/examples/class-loading.html),
+ * but it doesn't seem to work for the plain java class path case.
Manifest class path works,
+ * and isolated classpath also works, but just getting to a plain java
class path does not seem to work
+ * (surefire still refers to /tmp/surefireX). Without a plain java
class path GWTTestCase
+ * won't work - because GWTTestCase inspects the classpath and sets
itself up, and it
+ * doesn't like anything other than a plain java classpath (doesn't
like a manifest jar, or isolated).
+ * Also, presuming surefire did work, in plain java class path mode, we
would then still be
+ * susceptible to the line too long on Windows issue surefire works
around with the other modes.
+ *
+ * A lot of research into just using surefire was done (we don't want
to have to offer this special class for GWTTestCase) - after
+ * RTFM and trying the useSystemClassLoader and useManifestOnlyJar
settings, various ways, we still
+ * could never get it to work. These issues are similar to our
experiences
+ *: http://www.mail-archive.com/us...@maven.apache.org/msg87660.html -
and
+ * http://jira.codehaus.org/browse/SUREFIRE-508.
+ *
+ * Hopefully we can kill this someday, it's a hack, but for now, this
is the ONLY way
+ * to run GWTTestCase based tests from an automated Maven build.
+ */
+
public void execute() throws MojoExecutionException,
MojoFailureException {
if (isTestSkip()) {
return;
}

+ try {
+ this.makeCatalinaBase();
+ } catch (Exception e) {
+ throw new MojoExecutionException("Unable to build catalina.base",
e);
+ }
+ if (!this.getOutput().exists()) {
+ this.getOutput().mkdirs();
+ }
+
this.getLog().info("running GWTTestCase tests (using test name
filter - " + this.getTestFilter() + ")");

FileWriter testResultsWriter = null;
@@ -77,7 +86,7 @@
FileFilter fileFilter = new WildcardFileFilter("gwtTest-*");
File[] files = testDir.listFiles(fileFilter);
for (int i = 0; i < files.length; i++) {
- File test = files[i];
+ File test = files[i];

// create results writer
try {
@@ -99,10 +108,9 @@
testResultsWriter.write("Test Output: \n" + testResult.message
+ "\n");
testResultsWriter.flush();
testResultsWriter.close();
-
+
this.getLog().info(outTestName + " completed, GWTTestCase
result: " + testResult.lastLine);
- }
- catch (IOException e) {
+ } catch (IOException e) {
throw new MojoExecutionException("unable to create test
results output file", e);
}
}

Modified:
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterUnix.java
==============================================================================
---
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterUnix.java
(original)
+++
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterUnix.java
Mon Mar 30 08:30:19 2009
@@ -268,8 +268,12 @@
}
if (testExtra.length() > 0) {
writer.print(" " + testExtra + " ");
- }
- writer.print(" -cp $CLASSPATH ");
+ }
+
+ writer.print("-cp $CLASSPATH ");
+
+ writer.print("-Dcatalina.base=\"" +
mojo.getTomcat().getAbsolutePath() + "\" ");
+
writer.print("junit.textui.TestRunner ");
writer.print(testName);


Modified:
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterWindows.java
==============================================================================
---
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterWindows.java
(original)
+++
trunk/maven-googlewebtoolkit2-plugin/src/main/java/com/totsp/mavenplugin/gwt/scripting/ScriptWriterWindows.java
Mon Mar 30 08:30:19 2009
@@ -239,8 +239,12 @@
}
if (testExtra.length() > 0) {
writer.print(" " + testExtra + " ");
- }
- writer.print(" -cp %CLASSPATH% ");
+ }
+
+ writer.print("-cp %CLASSPATH% ");
+
+ writer.print("-Dcatalina.base=\"" +
mojo.getTomcat().getAbsolutePath() + "\" ");
+
writer.print("junit.textui.TestRunner ");
writer.print(testName);

Reply all
Reply to author
Forward
0 new messages