Submit untested fixes for RunStyleRemoteWeb and RunStyleSelenium to hopefully
unbreak the 2.0 build.
Patch by: jat
Review by: rjrjr (TBR)
git-svn-id: https://google-web-toolkit.googlecode.com/svn/branches/farewellSwt@6224 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
index e4c61a9..9377c9c 100644
--- a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
+++ b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
@@ -131,11 +131,42 @@
private static final int RESPONSE_TIMEOUT_MS = 10000;
- public static RunStyle create(JUnitShell shell, String[] urls) {
+ private RemoteBrowser[] remoteBrowsers;
+
+ /**
+ * Whether one of the remote browsers was interrupted.
+ */
+ private boolean wasInterrupted;
+
+ /**
+ * A separate lock to control access to {@link #wasInterrupted}. This keeps
+ * the main thread calls into {@link #wasInterrupted()} from having to
+ * synchronized on the containing instance and potentially block on RPC calls.
+ * It is okay to take the {@link #wasInterruptedLock} while locking the
+ * containing instance; it is NOT okay to do the opposite or deadlock could
+ * occur.
+ */
+ private final Object wasInterruptedLock = new Object();
+
+ /**
+ * @param shell the containing shell
+ */
+ public RunStyleRemoteWeb(JUnitShell shell) {
+ super(shell);
+ }
+
+ @Override
+ public boolean initialize(String args) {
+ if (args == null || args.length() == 0) {
+ throw new JUnitFatalLaunchException(
+ "RemoteWeb runstyle requires comma-separated RMI URLs");
+ }
+ String[] urls = args.split(",");
try {
RMISocketFactoryWithTimeouts.init();
} catch (IOException e) {
- throw new JUnitFatalLaunchException("Error initializing RMISocketFactory", e);
+ throw new JUnitFatalLaunchException("Error initializing RMISocketFactory",
+ e);
}
int numClients = urls.length;
BrowserManager[] browserManagers = new BrowserManager[numClients];
@@ -157,36 +188,6 @@
throw new JUnitFatalLaunchException(message, cause);
}
}
- return new RunStyleRemoteWeb(shell, browserManagers, urls);
- }
-
- private final RemoteBrowser[] remoteBrowsers;
-
- /**
- * Whether one of the remote browsers was interrupted.
- */
- private boolean wasInterrupted;
-
- /**
- * A separate lock to control access to {@link #wasInterrupted}. This keeps
- * the main thread calls into {@link #wasInterrupted()} from having to
- * synchronized on the containing instance and potentially block on RPC calls.
- * It is okay to take the {@link #wasInterruptedLock} while locking the
- * containing instance; it is NOT okay to do the opposite or deadlock could
- * occur.
- */
- private final Object wasInterruptedLock = new Object();
-
- /**
- * @param shell the containing shell
- * @param browserManagers a populated array of RMI remote interfaces to each
- * remote BrowserManagerServer
- * @param urls the URLs for each BrowserManager - used for error reporting
- * only
- */
- private RunStyleRemoteWeb(JUnitShell shell, BrowserManager[] browserManagers,
- String[] urls) {
- super(shell);
synchronized (this) {
this.remoteBrowsers = new RemoteBrowser[browserManagers.length];
for (int i = 0; i < browserManagers.length; ++i) {
@@ -194,6 +195,7 @@
}
}
Runtime.getRuntime().addShutdownHook(new ShutdownCb());
+ return true;
}
@Override
diff --git a/user/src/com/google/gwt/junit/RunStyleSelenium.java b/user/src/com/google/gwt/junit/RunStyleSelenium.java
index 13c7723..2e95beb 100644
--- a/user/src/com/google/gwt/junit/RunStyleSelenium.java
+++ b/user/src/com/google/gwt/junit/RunStyleSelenium.java
@@ -65,26 +65,6 @@
}
}
- public static RunStyle create(JUnitShell shell, String[] targetsIn) {
- RCSelenium targets[] = new RCSelenium[targetsIn.length];
-
- Pattern pattern = Pattern.compile("([\\w\\.-]+):([\\d]+)/([\\w\\s\\*]+)");
- for (int i = 0; i < targets.length; ++i) {
- Matcher matcher = pattern.matcher(targetsIn[i]);
- if (!matcher.matches()) {
- throw new JUnitFatalLaunchException("Unable to parse Selenium target " + targetsIn[i]
- + " (expected format is [host]:[port]/[browser])");
- }
- RCSelenium instance =
- new RCSelenium(matcher.group(3), matcher.group(1), Integer.parseInt(matcher.group(2)));
- targets[i] = instance;
- }
-
- RunStyleSelenium runStyle = new RunStyleSelenium(shell, targets);
- runStyle.start();
- return runStyle;
- }
-
private RCSelenium remotes[];
/**
@@ -102,8 +82,31 @@
*/
private final Object wasInterruptedLock = new Object();
- protected RunStyleSelenium(final JUnitShell shell, RCSelenium targets[]) {
+ public RunStyleSelenium(final JUnitShell shell) {
super(shell);
+ }
+
+ @Override
+ public boolean initialize(String args) {
+ if (args == null || args.length() == 0) {
+ throw new JUnitFatalLaunchException(
+ "Selenium runstyle requires comma-separated Selenium-RC targets");
+ }
+ String[] targetsIn = args.split(",");
+ RCSelenium targets[] = new RCSelenium[targetsIn.length];
+
+ Pattern pattern = Pattern.compile("([\\w\\.-]+):([\\d]+)/([\\w\\s\\*]+)");
+ for (int i = 0; i < targets.length; ++i) {
+ Matcher matcher = pattern.matcher(targetsIn[i]);
+ if (!matcher.matches()) {
+ throw new JUnitFatalLaunchException("Unable to parse Selenium target "
+ + targetsIn[i] + " (expected format is [host]:[port]/[browser])");
+ }
+ RCSelenium instance = new RCSelenium(matcher.group(3), matcher.group(1),
+ Integer.parseInt(matcher.group(2)));
+ targets[i] = instance;
+ }
+
this.remotes = targets;
// Install a shutdown hook that will close all of our outstanding Selenium
@@ -116,12 +119,15 @@
try {
remote.getSelenium().stop();
} catch (SeleniumException se) {
- shell.getTopLogger().log(TreeLogger.WARN, "Error stoping selenium session", se);
+ shell.getTopLogger().log(TreeLogger.WARN,
+ "Error stopping selenium session", se);
}
}
}
}
});
+ start();
+ return true;
}
@Override