Revision: 8107
Author: sco...@google.com
Date: Wed May 12 10:39:51 2010
Log: Reverting tr...@7971: "Re-rolling r7955: JUnitShell now subclasses
DevMode instead of GWTShell."
Review by: fabbott (desk)
http://code.google.com/p/google-web-toolkit/source/detail?r=8107
Deleted:
/branches/2.1/user/test/com/google/gwt/junit/DevModeOnCompiledScriptTest.gwt.xml
/branches/2.1/user/test/com/google/gwt/junit/JUnitBridge.java
/branches/2.1/user/test/com/google/gwt/junit/client/DevModeOnCompiledScriptTest.java
/branches/2.1/user/test-super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/DevModeOnCompiledScriptTest.java
Modified:
/branches/2.1/dev/core/src/com/google/gwt/dev/Compiler.java
/branches/2.1/dev/core/src/com/google/gwt/dev/DevMode.java
/branches/2.1/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
/branches/2.1/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerWarDir.java
/branches/2.1/eclipse/user/.classpath
/branches/2.1/user/src/com/google/gwt/junit/CompileStrategy.java
/branches/2.1/user/src/com/google/gwt/junit/JUnitShell.java
/branches/2.1/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
/branches/2.1/user/test/com/google/gwt/core/ext/test/XSLinkerTest.java
/branches/2.1/user/test/com/google/gwt/dev/jjs/RunAsyncFailure.gwt.xml
/branches/2.1/user/test/com/google/gwt/http/RequestBuilderTest.gwt.xml
/branches/2.1/user/test/com/google/gwt/http/ResponseTest.gwt.xml
/branches/2.1/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
/branches/2.1/user/test/com/google/gwt/junit/JUnitSuite.java
=======================================
---
/branches/2.1/user/test/com/google/gwt/junit/DevModeOnCompiledScriptTest.gwt.xml
Fri Apr 23 06:39:33 2010
+++ /dev/null
@@ -1,17 +0,0 @@
-<!--
-->
-<!-- Copyright 2010 Google
Inc. -->
-<!-- Licensed under the Apache License, Version 2.0 (the "License");
you -->
-<!-- may not use this file except in compliance with the License. You
may -->
-<!-- may obtain a copy of the License
at -->
-<!--
-->
-<!--
http://www.apache.org/licenses/LICENSE-2.0 -->
-<!--
-->
-<!-- Unless required by applicable law or agreed to in writing,
software -->
-<!-- distributed under the License is distributed on an "AS IS"
BASIS, -->
-<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
or -->
-<!-- implied. License for the specific language governing permissions
and -->
-<!-- limitations under the
License. -->
-
-<module>
- <inherits name='com.google.gwt.junit.JUnitTest' />
-</module>
=======================================
--- /branches/2.1/user/test/com/google/gwt/junit/JUnitBridge.java Fri Apr
23 06:39:33 2010
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.junit;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.cfg.ModuleDef;
-
-/**
- * Provides access to {...@link JUnitShell}.
- */
-public class JUnitBridge {
- public static void compileForWebMode(ModuleDef module)
- throws UnableToCompleteException {
- JUnitShell.getUnitTestShell().compileForWebMode(module,
- JUnitShell.getRemoteUserAgents());
- }
-
-}
=======================================
---
/branches/2.1/user/test/com/google/gwt/junit/client/DevModeOnCompiledScriptTest.java
Fri Apr 23 06:39:33 2010
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.junit.client;
-
-import com.google.gwt.core.ext.UnableToCompleteException;
-import com.google.gwt.dev.cfg.ModuleDef;
-import com.google.gwt.junit.DoNotRunWith;
-import com.google.gwt.junit.JUnitBridge;
-import com.google.gwt.junit.Platform;
-import com.google.gwt.junit.JUnitShell.Strategy;
-import com.google.gwt.junit.client.impl.JUnitResult;
-
-import junit.framework.TestCase;
-
-/**
- * Tests that we can run a test in dev mode even when the selection script
is
- * from a compile. Note that this is the VM-only version of the class;
there is
- * a translatable version for the client side.
- */
-...@donotrunwith(Platform.Prod)
-public class DevModeOnCompiledScriptTest extends GWTTestCase {
-
- @Override
- public String getModuleName() {
- return "com.google.gwt.junit.DevModeOnCompiledScriptTest";
- }
-
- /**
- * GWT-unfriendly, forcing us to use a translatable class.
- */
- @Override
- public Strategy getStrategy() {
- final Strategy impl = super.getStrategy();
- return new Strategy() {
- public String getModuleInherit() {
- return impl.getModuleInherit();
- }
-
- public String getSyntheticModuleExtension() {
- return impl.getSyntheticModuleExtension();
- }
-
- public void processModule(ModuleDef module) {
- impl.processModule(module);
- try {
- JUnitBridge.compileForWebMode(module);
- } catch (UnableToCompleteException e) {
- throw new RuntimeException("Failed to manually compile test
module",
- e);
- }
- }
-
- public void processResult(TestCase testCase, JUnitResult result) {
- impl.processResult(testCase, result);
- }
- };
- }
-
- public void testSomethingTrivial() {
- assertTrue(true);
- }
-}
=======================================
---
/branches/2.1/user/test-super/com/google/gwt/junit/translatable/com/google/gwt/junit/client/DevModeOnCompiledScriptTest.java
Fri Apr 23 06:39:33 2010
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2010 Google Inc.
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may
not
- * use this file except in compliance with the License. You may obtain a
copy of
- * the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT
- * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
- * License for the specific language governing permissions and limitations
under
- * the License.
- */
-package com.google.gwt.junit.client;
-
-import com.google.gwt.junit.DoNotRunWith;
-import com.google.gwt.junit.Platform;
-
-import junit.framework.TestCase;
-
-/**
- * Translatable trivial implementation.
- */
-...@donotrunwith(Platform.Prod)
-public class DevModeOnCompiledScriptTest extends GWTTestCase {
-
- @Override
- public String getModuleName() {
- return "com.google.gwt.junit.DevModeWithCompiledScriptTest";
- }
-
- public void testSomethingTrivial() {
- assertTrue(true);
- }
-}
=======================================
--- /branches/2.1/dev/core/src/com/google/gwt/dev/Compiler.java Fri Apr 23
06:39:33 2010
+++ /branches/2.1/dev/core/src/com/google/gwt/dev/Compiler.java Wed May 12
10:39:51 2010
@@ -165,16 +165,6 @@
}
public boolean run(TreeLogger logger) throws UnableToCompleteException {
- ModuleDef[] modules = new ModuleDef[options.getModuleNames().size()];
- int i = 0;
- for (String moduleName : options.getModuleNames()) {
- modules[i++] = ModuleDefLoader.loadFromClassPath(logger, moduleName,
true);
- }
- return run(logger, modules);
- }
-
- public boolean run(TreeLogger logger, ModuleDef... modules)
- throws UnableToCompleteException {
PerfLogger.start("compile");
boolean tempWorkDir = false;
try {
@@ -186,8 +176,10 @@
options.setExtraDir(new File("extras"));
}
- for (ModuleDef module : modules) {
- String moduleName = module.getCanonicalName();
+ for (String moduleName : options.getModuleNames()) {
+ ModuleDef module = ModuleDefLoader.loadFromClassPath(logger,
+ moduleName, true);
+
if (options.isValidateOnly()) {
if (!Precompile.validate(logger, options, module,
options.getGenDir(), options.getDumpSignatureFile())) {
=======================================
--- /branches/2.1/dev/core/src/com/google/gwt/dev/DevMode.java Fri Apr 23
06:39:33 2010
+++ /branches/2.1/dev/core/src/com/google/gwt/dev/DevMode.java Wed May 12
10:39:51 2010
@@ -155,10 +155,7 @@
}
}
- /**
- * The argument processor.
- */
- protected static class ArgProcessor extends DevModeBase.ArgProcessor {
+ static class ArgProcessor extends DevModeBase.ArgProcessor {
public ArgProcessor(HostedModeOptions options) {
super(options, false);
registerHandler(new ArgHandlerServer(options));
@@ -180,11 +177,7 @@
}
}
- /**
- * Options controlling dev mode.
- */
- protected interface HostedModeOptions extends HostedModeBaseOptions,
- CompilerOptions {
+ interface HostedModeOptions extends HostedModeBaseOptions,
CompilerOptions {
ServletContainerLauncher getServletContainerLauncher();
String getServletContainerLauncherArgs();
@@ -197,10 +190,11 @@
/**
* Concrete class to implement all hosted mode options.
*/
- protected static class HostedModeOptionsImpl extends
- HostedModeBaseOptionsImpl implements HostedModeOptions {
+ static class HostedModeOptionsImpl extends HostedModeBaseOptionsImpl
+ implements HostedModeOptions {
private File extraDir;
private int localWorkers;
+ private File outDir;
private ServletContainerLauncher scl;
private String sclArgs;
private File warDir;
@@ -215,7 +209,7 @@
@Deprecated
public File getOutDir() {
- return warDir;
+ return outDir;
}
public ServletContainerLauncher getServletContainerLauncher() {
@@ -240,7 +234,7 @@
@Deprecated
public void setOutDir(File outDir) {
- this.warDir = outDir;
+ this.outDir = outDir;
}
public void setServletContainerLauncher(ServletContainerLauncher scl) {
@@ -306,7 +300,7 @@
/**
* Default constructor for testing; no public API yet.
*/
- protected DevMode() {
+ DevMode() {
}
/**
=======================================
---
/branches/2.1/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
Fri Apr 23 06:39:33 2010
+++
/branches/2.1/dev/core/src/com/google/gwt/dev/shell/jetty/JettyLauncher.java
Wed May 12 10:39:51 2010
@@ -533,7 +533,8 @@
server.addConnector(connector);
// Create a new web app in the war directory.
- WebAppContext wac = createWebAppContext(logger, appRootDir);
+ WebAppContext wac = new WebAppContextWithReload(logger,
+ appRootDir.getAbsolutePath(), "/");
RequestLogHandler logHandler = new RequestLogHandler();
logHandler.setRequestLog(new JettyRequestLogger(logger,
getBaseLogLevel()));
@@ -545,18 +546,8 @@
// Now that we're started, log to the top level logger.
Log.setLog(new JettyTreeLogger(logger));
- return createServletContainer(logger, appRootDir, server, wac,
- connector.getLocalPort());
- }
-
- protected JettyServletContainer createServletContainer(TreeLogger logger,
- File appRootDir, Server server, WebAppContext wac, int localPort) {
- return new JettyServletContainer(logger, server, wac, localPort,
appRootDir);
- }
-
- protected WebAppContext createWebAppContext(TreeLogger logger, File
appRootDir) {
- return new WebAppContextWithReload(logger,
appRootDir.getAbsolutePath(),
- "/");
+ return new JettyServletContainer(logger, server, wac,
+ connector.getLocalPort(), appRootDir);
}
protected AbstractConnector getConnector() {
=======================================
---
/branches/2.1/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerWarDir.java
Fri Apr 23 06:39:33 2010
+++
/branches/2.1/dev/core/src/com/google/gwt/dev/util/arg/ArgHandlerWarDir.java
Wed May 12 10:39:51 2010
@@ -22,7 +22,7 @@
/**
* Argument handler for processing the output directory flag.
*/
-public class ArgHandlerWarDir extends ArgHandlerDir {
+public final class ArgHandlerWarDir extends ArgHandlerDir {
private final OptionWarDir option;
=======================================
--- /branches/2.1/eclipse/user/.classpath Fri Apr 23 06:39:33 2010
+++ /branches/2.1/eclipse/user/.classpath Wed May 12 10:39:51 2010
@@ -31,6 +31,5 @@
<classpathentry combineaccessrules="false" kind="src" path="/gwt-dev"/>
<classpathentry kind="var"
path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607.jar"
sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-r5607-sources.jar"/>
<classpathentry kind="var"
path="GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607.jar"
sourcepath="/GWT_TOOLS/lib/htmlunit/htmlunit-r5607/htmlunit-core-js-r5607-sources.jar"/>
- <classpathentry kind="var" path="GWT_TOOLS/lib/jetty/jetty-6.1.11.jar"
sourcepath="/GWT_TOOLS/lib/jetty/jetty-6.1.11-src.zip"/>
<classpathentry kind="output" path="bin"/>
</classpath>
=======================================
--- /branches/2.1/user/src/com/google/gwt/junit/CompileStrategy.java Fri
Apr 23 06:39:33 2010
+++ /branches/2.1/user/src/com/google/gwt/junit/CompileStrategy.java Wed
May 12 10:39:51 2010
@@ -181,7 +181,7 @@
strategy.processModule(moduleDef);
- junitShell.maybeCompileForWebMode(moduleDef,
+ junitShell.maybeCompileForWebMode(syntheticModuleName,
JUnitShell.getRemoteUserAgents());
return moduleDef;
=======================================
--- /branches/2.1/user/src/com/google/gwt/junit/JUnitShell.java Fri Apr 23
06:39:33 2010
+++ /branches/2.1/user/src/com/google/gwt/junit/JUnitShell.java Wed May 12
10:39:51 2010
@@ -20,31 +20,26 @@
import com.google.gwt.core.ext.TreeLogger.Type;
import com.google.gwt.core.ext.typeinfo.JClassType;
import com.google.gwt.core.ext.typeinfo.TypeOracle;
-import com.google.gwt.dev.ArgProcessorBase;
-import com.google.gwt.dev.Compiler;
-import com.google.gwt.dev.DevMode;
+import com.google.gwt.dev.GWTCompiler;
+import com.google.gwt.dev.GWTShell;
+import com.google.gwt.dev.LegacyCompilerOptions;
+import com.google.gwt.dev.GWTCompiler.GWTCompilerOptionsImpl;
import com.google.gwt.dev.cfg.BindingProperty;
import com.google.gwt.dev.cfg.ModuleDef;
+import com.google.gwt.dev.cfg.ModuleDefLoader;
import com.google.gwt.dev.cfg.Properties;
import com.google.gwt.dev.cfg.Property;
import com.google.gwt.dev.javac.CompilationState;
import com.google.gwt.dev.javac.CompilationUnit;
import com.google.gwt.dev.shell.CheckForUpdates;
-import com.google.gwt.dev.shell.jetty.JettyLauncher;
import com.google.gwt.dev.util.arg.ArgHandlerDisableAggressiveOptimization;
import com.google.gwt.dev.util.arg.ArgHandlerDisableCastChecking;
import com.google.gwt.dev.util.arg.ArgHandlerDisableClassMetadata;
-import com.google.gwt.dev.util.arg.ArgHandlerDisableRunAsync;
import com.google.gwt.dev.util.arg.ArgHandlerDraftCompile;
import com.google.gwt.dev.util.arg.ArgHandlerEnableAssertions;
-import com.google.gwt.dev.util.arg.ArgHandlerExtraDir;
-import com.google.gwt.dev.util.arg.ArgHandlerGenDir;
import com.google.gwt.dev.util.arg.ArgHandlerLocalWorkers;
import com.google.gwt.dev.util.arg.ArgHandlerLogLevel;
-import com.google.gwt.dev.util.arg.ArgHandlerMaxPermsPerPrecompile;
import com.google.gwt.dev.util.arg.ArgHandlerScriptStyle;
-import com.google.gwt.dev.util.arg.ArgHandlerWarDir;
-import com.google.gwt.dev.util.arg.ArgHandlerWorkDirOptional;
import com.google.gwt.junit.JUnitMessageQueue.ClientStatus;
import com.google.gwt.junit.client.GWTTestCase;
import com.google.gwt.junit.client.TimeoutException;
@@ -58,10 +53,6 @@
import junit.framework.TestCase;
import junit.framework.TestResult;
-import org.mortbay.jetty.Server;
-import org.mortbay.jetty.webapp.WebAppContext;
-
-import java.io.File;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
@@ -70,7 +61,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.Map.Entry;
@@ -106,7 +96,8 @@
* {...@link JUnitMessageQueue}, thus closing the loop.
* </p>
*/
-public class JUnitShell extends DevMode {
+...@suppresswarnings("deprecation")
+public class JUnitShell extends GWTShell {
/**
* A strategy for running the test.
@@ -121,73 +112,54 @@
void processResult(TestCase testCase, JUnitResult result);
}
- class ArgProcessor extends ArgProcessorBase {
-
- @SuppressWarnings("deprecation")
+ class ArgProcessor extends GWTShell.ArgProcessor {
+
public ArgProcessor() {
- /*
- * ----- Options from DevModeBase -------
- */
- // DISABLE: ArgHandlerNoServerFlag.
+ super(options, true, true);
+ registerHandler(new ArgHandlerScriptStyle(options));
+ registerHandler(new ArgHandlerEnableAssertions(options));
+ registerHandler(new
ArgHandlerDisableAggressiveOptimization(options));
+ registerHandler(new ArgHandlerDisableClassMetadata(options));
+ registerHandler(new ArgHandlerDisableCastChecking(options));
+ registerHandler(new ArgHandlerDraftCompile(options));
+ registerHandler(new ArgHandlerLocalWorkers(options));
+
+ // Override port to set auto by default.
registerHandler(new ArgHandlerPort(options) {
@Override
public String[] getDefaultArgs() {
- // Override port to auto by default.
return new String[]{"-port", "auto"};
}
});
- registerHandler(new ArgHandlerWhitelist());
- registerHandler(new ArgHandlerBlacklist());
- registerHandler(new ArgHandlerLogDir(options));
- registerHandler(new ArgHandlerLogLevel(options));
- registerHandler(new ArgHandlerGenDir(options));
- // DISABLE: ArgHandlerBindAddress.
+
+ // Override port to set auto by default.
registerHandler(new ArgHandlerCodeServerPort(options) {
@Override
public String[] getDefaultArgs() {
- // Override code server port to auto by default.
return new String[]{this.getTag(), "auto"};
}
});
- // DISABLE: ArgHandlerRemoteUI.
-
- /*
- * ----- Options from DevMode -------
- */
- // Hard code the server.
- options.setServletContainerLauncher(new MyJettyLauncher());
- // DISABLE: ArgHandlerStartupURLs
- registerHandler(new
com.google.gwt.dev.ArgHandlerOutDirDeprecated(options));
- registerHandler(new ArgHandlerWarDir(options) {
+
+ // Disable -bindAddress, fail if it is given
+ // TODO(jat): support -bindAddress in JUnitShell, which will probably
+ // require changes to the RunStyle API.
+ registerHandler(new ArgHandlerBindAddress(options) {
@Override
public String[] getDefaultArgs() {
- // If an outDir was already specified, don't clobber it.
- if (options.getOutDir() != null) {
- return null;
- }
- return super.getDefaultArgs();
- }
- });
- registerHandler(new ArgHandlerExtraDir(options));
- registerHandler(new ArgHandlerWorkDirOptional(options));
- // DISABLE: ArgHandlerModuleName
-
- /*
- * ----- Additional options from Compiler not already included
-------
- */
- registerHandler(new ArgHandlerScriptStyle(options));
- registerHandler(new ArgHandlerEnableAssertions(options));
- registerHandler(new
ArgHandlerDisableAggressiveOptimization(options));
- registerHandler(new ArgHandlerDisableClassMetadata(options));
- registerHandler(new ArgHandlerDisableCastChecking(options));
- registerHandler(new ArgHandlerDisableRunAsync(options));
- registerHandler(new ArgHandlerDraftCompile(options));
- registerHandler(new ArgHandlerMaxPermsPerPrecompile(options));
- registerHandler(new ArgHandlerLocalWorkers(options));
-
- /*
- * ----- Options specific to JUnitShell -----
- */
+ return null;
+ }
+
+ @Override
+ public boolean isUndocumented() {
+ return true;
+ }
+
+ @Override
+ public boolean setString(String value) {
+ System.err.println("-bindAddress is not supported for
JUnitShell");
+ return false;
+ }
+ });
// Override log level to set WARN by default..
registerHandler(new ArgHandlerLogLevel(options) {
@@ -197,6 +169,24 @@
}
});
+ registerHandler(new ArgHandlerFlag() {
+ @Override
+ public String getPurpose() {
+ return "Causes your test to run in -noserver development mode
(defaults to development mode)";
+ }
+
+ @Override
+ public String getTag() {
+ return "-noserver";
+ }
+
+ @Override
+ public boolean setFlag() {
+ shouldAutoGenerateResources = false;
+ return true;
+ }
+ });
+
registerHandler(new ArgHandlerFlag() {
@Override
public String getPurpose() {
@@ -384,7 +374,7 @@
@Override
public boolean setFlag() {
- JUnitShell.this.setHeadless(false);
+ setHeadlessAccessor(false);
return true;
}
});
@@ -502,49 +492,6 @@
}
});
}
-
- @Override
- protected String getName() {
- return JUnitShell.class.getName();
- }
- }
-
- private final class MyJettyLauncher extends JettyLauncher {
-
- /**
- * Adds in special JUnit stuff.
- */
- @Override
- protected JettyServletContainer createServletContainer(TreeLogger
logger,
- File appRootDir, Server server, WebAppContext wac, int localPort) {
- // Don't bother shutting down cleanly.
- server.setStopAtShutdown(false);
- // Save off the Context so we can add our own servlets later.
- JUnitShell.this.wac = wac;
- return super.createServletContainer(logger, appRootDir, server, wac,
- localPort);
- }
-
- /**
- * Ignore DevMode's normal WEB-INF classloader rules and just allow the
- * system classloader to dominate. This makes JUnitHostImpl live in the
- * right classloader (mine).
- */
- @SuppressWarnings("unchecked")
- @Override
- protected WebAppContext createWebAppContext(TreeLogger logger,
- File appRootDir) {
- return new WebAppContext(appRootDir.getAbsolutePath(), "/") {
- {
- // Prevent file locking on Windows; pick up file changes.
- getInitParams().put(
- "org.mortbay.jetty.servlet.Default.useFileMappedBuffer",
"false");
-
- // Prefer the parent class loader so that JUnit works.
- setParentLoaderPriority(true);
- }
- };
- }
}
/**
@@ -648,39 +595,6 @@
assert strategy.equals(gwtTestCase.getStrategy()) : "strategy does not
match GWTTestCase#getStrategy()";
runTest(gwtTestCase, testResult);
}
-
- /**
- * Retrieves the JUnitShell. This should only be invoked during
TestRunner
- * execution of JUnit tests.
- */
- static JUnitShell getUnitTestShell() {
- if (unitTestShell == null) {
- unitTestShell = new JUnitShell();
- unitTestShell.lastLaunchFailed = true;
- String[] args = unitTestShell.synthesizeArgs();
- ArgProcessor argProcessor = unitTestShell.new ArgProcessor();
- if (!argProcessor.processArgs(args)) {
- throw new JUnitFatalLaunchException("Error processing shell
arguments");
- }
- // Always bind to the wildcard address and substitute the host
address in
- // URLs. Note that connectAddress isn't actually used here, as we
- // override it from the runsStyle in getModuleUrl, but we set it to
match
- // what will actually be used anyway to avoid confusion.
- unitTestShell.options.setBindAddress("0.0.0.0");
- try {
-
unitTestShell.options.setConnectAddress(InetAddress.getLocalHost().getHostAddress());
- } catch (UnknownHostException e) {
- throw new JUnitFatalLaunchException("Unable to resolve my
address");
- }
- if (!unitTestShell.startUp()) {
- throw new JUnitFatalLaunchException("Shell failed to start");
- }
- // TODO: install a shutdown hook? Not necessary with GWTShell.
- unitTestShell.lastLaunchFailed = false;
- }
- unitTestShell.checkArgs();
- return unitTestShell;
- }
/**
* Sanity check; if the type we're trying to run did not actually wind
up in
@@ -746,9 +660,37 @@
}
/**
- * Our server's web app context; used to dynamically add servlets.
+ * Retrieves the JUnitShell. This should only be invoked during
TestRunner
+ * execution of JUnit tests.
*/
- WebAppContext wac;
+ private static JUnitShell getUnitTestShell() {
+ if (unitTestShell == null) {
+ unitTestShell = new JUnitShell();
+ unitTestShell.lastLaunchFailed = true;
+ String[] args = unitTestShell.synthesizeArgs();
+ ArgProcessor argProcessor = unitTestShell.new ArgProcessor();
+ if (!argProcessor.processArgs(args)) {
+ throw new JUnitFatalLaunchException("Error processing shell
arguments");
+ }
+ // Always bind to the wildcard address and substitute the host
address in
+ // URLs. Note that connectAddress isn't actually used here, as we
+ // override it from the runsStyle in getModuleUrl, but we set it to
match
+ // what will actually be used anyway to avoid confusion.
+ unitTestShell.options.setBindAddress("0.0.0.0");
+ try {
+
unitTestShell.options.setConnectAddress(InetAddress.getLocalHost().getHostAddress());
+ } catch (UnknownHostException e) {
+ throw new JUnitFatalLaunchException("Unable to resolve my
address");
+ }
+ if (!unitTestShell.startUp()) {
+ throw new JUnitFatalLaunchException("Shell failed to start");
+ }
+ // TODO: install a shutdown hook? Not necessary with GWTShell.
+ unitTestShell.lastLaunchFailed = false;
+ }
+ unitTestShell.checkArgs();
+ return unitTestShell;
+ }
/**
* The amount of time to wait for all clients to have contacted the
server and
@@ -815,11 +757,6 @@
@SuppressWarnings("unused")
private ModuleDef lastModule;
- /**
- * Records what servlets have been loaded at which paths.
- */
- private final Map<String, String> loadedServletsByPath = new
HashMap<String, String>();
-
/**
* Portal to interact with the servlet.
*/
@@ -848,6 +785,8 @@
*/
private String runStyleName = "HtmlUnit";
+ private boolean shouldAutoGenerateResources = true;
+
private boolean standardsMode = false;
/**
@@ -1046,14 +985,22 @@
}
return true;
}
+
+ @Override
+ protected boolean shouldAutoGenerateResources() {
+ return shouldAutoGenerateResources;
+ }
@Override
protected void warnAboutNoStartupUrls() {
// do nothing -- JUnitShell isn't expected to have startup URLs
}
- void compileForWebMode(ModuleDef module, String... userAgents)
+ void compileForWebMode(String moduleName, String... userAgents)
throws UnableToCompleteException {
+ // Never fresh during JUnit.
+ ModuleDef module = ModuleDefLoader.loadFromClassPath(getTopLogger(),
+ moduleName, false);
if (userAgents != null && userAgents.length > 0) {
Properties props = module.getProperties();
Property userAgent = props.find("user.agent");
@@ -1063,41 +1010,28 @@
userAgents);
}
}
- if (!new Compiler(options).run(getTopLogger(), module)) {
+ LegacyCompilerOptions newOptions = new GWTCompilerOptionsImpl(options);
+ if (!new GWTCompiler(newOptions).run(getTopLogger(), module)) {
throw new UnableToCompleteException();
}
// TODO(scottb): prepopulate currentCompilationState somehow?
}
- void maybeCompileForWebMode(ModuleDef module, String... userAgents)
+ void maybeCompileForWebMode(String moduleName, String... userAgents)
throws UnableToCompleteException {
- // Load any declared servlets.
- for (String path : module.getServletPaths()) {
- String servletClass = module.findServletForPath(path);
- path = '/' + module.getName() + path;
- if (!servletClass.equals(loadedServletsByPath.get(path))) {
- try {
- Class<?> clazz = wac.loadClass(servletClass);
- wac.addServlet(clazz, path);
- loadedServletsByPath.put(path, servletClass);
- } catch (ClassNotFoundException e) {
- getTopLogger().log(
- TreeLogger.WARN,
- "Failed to load servlet class '" + servletClass
- + "' declared in '" + module.getName() + "'", e);
- }
- }
- }
- if (developmentMode) {
- // BACKWARDS COMPATIBILITY: most linkers currently fail in dev mode.
- if (module.getLinker("std") != null) {
- // TODO: unfortunately, this could be race condition between
dev/prod
- module.addLinker("std");
- }
- super.link(getTopLogger(), module);
- } else {
- compileForWebMode(module, userAgents);
- }
+ if (!developmentMode || !shouldAutoGenerateResources) {
+ compileForWebMode(moduleName, userAgents);
+ }
+ }
+
+ /**
+ * Accessor method to DevModeBase.setHeadless -- without this, we get
+ * IllegalAccessError from the -notHeadless arg handler. Compiler bug?
+ *
+ * @param headlessMode
+ */
+ void setHeadlessAccessor(boolean headlessMode) {
+ setHeadless(headlessMode);
}
/**
=======================================
--- /branches/2.1/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
Fri Apr 23 06:39:33 2010
+++ /branches/2.1/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
Wed May 12 10:39:51 2010
@@ -111,11 +111,10 @@
public InitialResponse getTestBlock(int blockIndex, ClientInfo
clientInfo)
throws TimeoutException {
ClientInfoExt clientInfoExt;
- HttpServletRequest request = getThreadLocalRequest();
if (clientInfo.getSessionId() < 0) {
- clientInfoExt = createNewClientInfo(clientInfo.getUserAgent(),
request);
+ clientInfoExt = createNewClientInfo(clientInfo.getUserAgent());
} else {
- clientInfoExt = createClientInfo(clientInfo, request);
+ clientInfoExt = createClientInfo(clientInfo);
}
TestBlock initialTestBlock = getHost().getTestBlock(clientInfoExt,
blockIndex, TIME_TO_WAIT_FOR_TESTNAME);
@@ -132,8 +131,7 @@
result.setException(deserialize(ew));
}
JUnitMessageQueue host = getHost();
- ClientInfoExt clientInfoExt = createClientInfo(clientInfo,
- getThreadLocalRequest());
+ ClientInfoExt clientInfoExt = createClientInfo(clientInfo);
host.reportResults(clientInfoExt, results);
return host.getTestBlock(clientInfoExt, testBlock,
TIME_TO_WAIT_FOR_TESTNAME);
@@ -148,23 +146,21 @@
JUnitResult result = new JUnitResult();
initResult(request, result);
result.setException(new JUnitFatalLaunchException(requestPayload));
- getHost().reportFatalLaunch(createNewClientInfo(null, request),
result);
+ getHost().reportFatalLaunch(createNewClientInfo(null), result);
} else {
super.service(request, response);
}
}
- private ClientInfoExt createClientInfo(ClientInfo clientInfo,
- HttpServletRequest request) {
+ private ClientInfoExt createClientInfo(ClientInfo clientInfo) {
assert (clientInfo.getSessionId() >= 0);
return new ClientInfoExt(clientInfo.getSessionId(),
- clientInfo.getUserAgent(), getClientDesc(request));
+ clientInfo.getUserAgent(), getClientDesc(getThreadLocalRequest()));
}
- private ClientInfoExt createNewClientInfo(String userAgent,
- HttpServletRequest request) {
+ private ClientInfoExt createNewClientInfo(String userAgent) {
return new ClientInfoExt(createSessionId(), userAgent,
- getClientDesc(request));
+ getClientDesc(getThreadLocalRequest()));
}
private int createSessionId() {
@@ -350,12 +346,12 @@
JsniRef ref = JsniRef.parse(parts[0].substring(0,
parts[0].lastIndexOf(')') + 1));
- toReturn = new Object[]{
+ toReturn = new Object[] {
ref.className(), ref.memberName(), stw.fileName, stw.lineNumber};
} else {
// Use the raw data from the client
- toReturn = new Object[]{
+ toReturn = new Object[] {
stw.className, stw.methodName, stw.fileName, stw.lineNumber};
}
return toReturn;
=======================================
--- /branches/2.1/user/test/com/google/gwt/core/ext/test/XSLinkerTest.java
Fri Apr 23 06:39:33 2010
+++ /branches/2.1/user/test/com/google/gwt/core/ext/test/XSLinkerTest.java
Wed May 12 10:39:51 2010
@@ -15,13 +15,9 @@
*/
package com.google.gwt.core.ext.test;
-import com.google.gwt.junit.DoNotRunWith;
-import com.google.gwt.junit.Platform;
-
/**
* Tests the cross-site linker.
*/
-...@donotrunwith(Platform.Devel)
public class XSLinkerTest extends LinkerTest {
@Override
public String getModuleName() {
=======================================
--- /branches/2.1/user/test/com/google/gwt/dev/jjs/RunAsyncFailure.gwt.xml
Fri Apr 23 06:39:33 2010
+++ /branches/2.1/user/test/com/google/gwt/dev/jjs/RunAsyncFailure.gwt.xml
Wed May 12 10:39:51 2010
@@ -15,7 +15,7 @@
<module>
<inherits name="com.google.gwt.core.Core" />
<source path="test" />
- <servlet path="/runAsyncFailure/*"
+ <servlet path="/runAsyncFailure"
class="com.google.gwt.user.server.runasync.RunAsyncFailureServlet" />
<set-configuration-property name="iframe.linker.deferredjs.subdir"
value="runAsyncFailure/deferredjs" />
=======================================
--- /branches/2.1/user/test/com/google/gwt/http/RequestBuilderTest.gwt.xml
Fri Apr 23 06:39:33 2010
+++ /branches/2.1/user/test/com/google/gwt/http/RequestBuilderTest.gwt.xml
Wed May 12 10:39:51 2010
@@ -15,6 +15,6 @@
<module>
<inherits name='com.google.gwt.user.User' />
- <servlet path='/testRequestBuilder/*'
+ <servlet path='/testRequestBuilder'
class='com.google.gwt.http.server.RequestBuilderTestServlet' />
</module>
=======================================
--- /branches/2.1/user/test/com/google/gwt/http/ResponseTest.gwt.xml Fri
Apr 23 06:39:33 2010
+++ /branches/2.1/user/test/com/google/gwt/http/ResponseTest.gwt.xml Wed
May 12 10:39:51 2010
@@ -15,6 +15,6 @@
<module>
<inherits name='com.google.gwt.user.User' />
- <servlet path='/testResponse/*'
+ <servlet path='/testResponse'
class='com.google.gwt.http.server.ResponseTestServlet' />
</module>
=======================================
---
/branches/2.1/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
Fri Apr 23 06:39:33 2010
+++
/branches/2.1/user/test/com/google/gwt/http/server/RequestBuilderTestServlet.java
Wed May 12 10:39:51 2010
@@ -30,6 +30,10 @@
*/
public class RequestBuilderTestServlet extends HttpServlet {
+ private static String getPathInfoBase() {
+
return "/com.google.gwt.http.RequestBuilderTest.JUnit/testRequestBuilder/";
+ }
+
@Override
protected void doDelete(HttpServletRequest request,
HttpServletResponse response) {
@@ -45,7 +49,7 @@
protected void doGet(HttpServletRequest request, HttpServletResponse
response)
throws IOException {
String pathInfo = request.getPathInfo();
- if (pathInfo.equals("/setRequestHeader")) {
+ if (pathInfo.equals(getPathInfoBase() + "setRequestHeader")) {
String value = request.getHeader("Foo");
if (value.equals("Bar1")) {
response.setStatus(HttpServletResponse.SC_OK);
@@ -53,13 +57,13 @@
} else {
response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
}
- } else if (pathInfo.equals("/send_GET")) {
+ } else if (pathInfo.equals(getPathInfoBase() + "send_GET")) {
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().write(RequestBuilderTest.SERVLET_GET_RESPONSE);
- } else if (pathInfo.equals("/sendRequest_GET")) {
+ } else if (pathInfo.equals(getPathInfoBase() + "sendRequest_GET")) {
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().write(RequestBuilderTest.SERVLET_GET_RESPONSE);
- } else if (pathInfo.equals("/setTimeout/timeout")) {
+ } else if (pathInfo.equals(getPathInfoBase() + "setTimeout/timeout")) {
// cause a timeout on the client
try {
Thread.sleep(5000);
@@ -67,7 +71,7 @@
}
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().print(RequestBuilderTest.SERVLET_GET_RESPONSE);
- } else if (pathInfo.equals("/setTimeout/noTimeout")) {
+ } else if (pathInfo.equals(getPathInfoBase()
+ "setTimeout/noTimeout")) {
// wait but not long enough to timeout
try {
Thread.sleep(1000);
@@ -75,7 +79,7 @@
}
response.setStatus(HttpServletResponse.SC_OK);
response.getWriter().print(RequestBuilderTest.SERVLET_GET_RESPONSE);
- } else if (pathInfo.equals("/user/pass")) {
+ } else if (pathInfo.equals(getPathInfoBase() + "user/pass")) {
String auth = request.getHeader("Authorization");
if (auth == null) {
response.setHeader("WWW-Authenticate", "BASIC");
@@ -107,7 +111,7 @@
*/
response.getWriter().print(RequestBuilderTest.SERVLET_POST_RESPONSE);
response.setStatus(HttpServletResponse.SC_OK);
- } else if (request.getPathInfo().equals("/simplePost")) {
+ } else if (request.getPathInfo().equals(getPathInfoBase()
+ "simplePost")) {
response.getWriter().print(RequestBuilderTest.SERVLET_POST_RESPONSE);
response.setStatus(HttpServletResponse.SC_OK);
} else {
=======================================
--- /branches/2.1/user/test/com/google/gwt/junit/JUnitSuite.java Fri Apr 23
06:39:33 2010
+++ /branches/2.1/user/test/com/google/gwt/junit/JUnitSuite.java Wed May 12
10:39:51 2010
@@ -15,7 +15,6 @@
*/
package com.google.gwt.junit;
-import com.google.gwt.junit.client.DevModeOnCompiledScriptTest;
import com.google.gwt.junit.client.GWTTestCaseTest;
import com.google.gwt.junit.client.PropertyDefiningGWTTest;
import com.google.gwt.junit.tools.GWTTestSuite;
@@ -34,7 +33,6 @@
// Suppressed due to flakiness on Linux
// suite.addTestSuite(BenchmarkTest.class);
suite.addTestSuite(GWTTestCaseTest.class);
- suite.addTestSuite(DevModeOnCompiledScriptTest.class);
// Must run after a GWTTestCase so JUnitShell is initialized.
suite.addTestSuite(BatchingStrategyTest.class);
--
http://groups.google.com/group/Google-Web-Toolkit-Contributors