Reverted wonky junitHost-based JUnit page load back to a static HTML page that determines what module to load on the client side.
Suggested by: mmendez
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@1942 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/junit/RunStyle.java b/user/src/com/google/gwt/junit/RunStyle.java
index 91b8c21..ba1e255 100644
--- a/user/src/com/google/gwt/junit/RunStyle.java
+++ b/user/src/com/google/gwt/junit/RunStyle.java
@@ -49,6 +49,6 @@
* @return a URL suffix that should be loaded
*/
protected String getUrlSuffix(String moduleName) {
- return moduleName + "/junithost/junit.html";
+ return moduleName + "/junit.html";
}
}
diff --git a/user/src/com/google/gwt/junit/junit.html b/user/src/com/google/gwt/junit/public/junit.html
similarity index 79%
rename from user/src/com/google/gwt/junit/junit.html
rename to user/src/com/google/gwt/junit/public/junit.html
index 1029f82..c652ddd 100644
--- a/user/src/com/google/gwt/junit/junit.html
+++ b/user/src/com/google/gwt/junit/public/junit.html
@@ -17,10 +17,10 @@
<head>
<meta name='gwt:onLoadErrorFn' content='junitOnLoadErrorFn'>
<meta name='gwt:onPropertyErrorFn' content='junitOnPropertyErrorFn'>
-<base href="__MODULE_BASE__">
</head>
<body>
<script language='javascript'>
+<!--
function junitOnLoadErrorFn(moduleName) {
junitError('Failed to load module "' + moduleName +
'".\nPlease see the log for details.');
@@ -38,13 +38,23 @@
}
function junitError(msg) {
- var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Msxml2.XMLHTTP");
+ var xmlHttpRequest = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP");
xmlHttpRequest.open('POST', 'loadError', true);
xmlHttpRequest.setRequestHeader('Content-Type', 'text/plain; charset=utf-8');
xmlHttpRequest.send(msg);
}
+
+function loadSelectionScript() {
+ var moduleName = document.location.href;
+ var pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(0, pos);
+ pos = moduleName.lastIndexOf('/');
+ moduleName = moduleName.substr(pos + 1);
+ document.write("<script language='javascript' src='" + moduleName + ".nocache.js'></script>");
+}
+loadSelectionScript();
+-->
</script>
-<script language='javascript' src='__MODULE_NAME__.nocache.js'></script>
<iframe src="javascript:''" id='__gwt_historyFrame' style='position:absolute;width:0;height:0;border:0'></iframe>
</body>
</html>
diff --git a/user/src/com/google/gwt/junit/server/JUnitHostImpl.java b/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
index 573d0df..9c94904 100644
--- a/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
+++ b/user/src/com/google/gwt/junit/server/JUnitHostImpl.java
@@ -25,10 +25,8 @@
import com.google.gwt.user.client.rpc.InvocationException;
import com.google.gwt.user.server.rpc.RPCServletUtils;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
-import com.google.gwt.util.tools.Utility;
import java.io.IOException;
-import java.io.PrintWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
@@ -98,30 +96,11 @@
}
@Override
- protected void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- String requestURI = request.getRequestURI();
- if (requestURI.endsWith("/junithost/junit.html")) {
- String prefix = getPrefix(requestURI);
- String moduleName = getModuleName(prefix);
- response.setContentType("text/html");
- PrintWriter writer = response.getWriter();
- String htmlSrc = Utility.getFileFromClassPath("com/google/gwt/junit/junit.html");
- htmlSrc = htmlSrc.replace("__MODULE_BASE__", prefix + "/");
- htmlSrc = htmlSrc.replace("__MODULE_NAME__", prefix + "/" + moduleName);
- writer.write(htmlSrc);
- return;
- }
- response.setContentType("text/plain");
- response.setStatus(HttpServletResponse.SC_NOT_FOUND);
- }
-
- @Override
protected void service(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
String requestURI = request.getRequestURI();
if (requestURI.endsWith("/junithost/loadError")) {
- String moduleName = getModuleName(getPrefix(requestURI));
+ String moduleName = getModuleName(requestURI);
String requestPayload = RPCServletUtils.readContentAsUtf8(request);
JUnitResult result = new JUnitResult();
initResult(request, result);
@@ -248,16 +227,12 @@
return machine + " / " + agent;
}
- private String getModuleName(String prefix) {
- int pos = prefix.lastIndexOf('/');
- String moduleName = prefix.substring(pos + 1);
- return moduleName;
- }
-
- private String getPrefix(String requestURI) {
+ private String getModuleName(String requestURI) {
int pos = requestURI.indexOf("/junithost");
String prefix = requestURI.substring(0, pos);
- return prefix;
+ pos = prefix.lastIndexOf('/');
+ String moduleName = prefix.substring(pos + 1);
+ return moduleName;
}
private void initResult(HttpServletRequest request, JUnitResult result) {