Skip to content
This repository was archived by the owner on Sep 26, 2020. It is now read-only.

Commit c71f2d8

Browse files
committed
Remove dependency from GWT-JUnit on deRPC
GWT-JUnit never actually used deRPC, which additionally is being phased out and its use now discouraged. git fetch https://gwt.googlesource.com/gwt refs/changes/90/1290/2 && git cherry-pick FETCH_HEAD Change-Id: I74c9d2e339187c2a47ccea4b0082c3a59ffe5ae4
1 parent 277fbaa commit c71f2d8

File tree

1 file changed

+31
-2
lines changed

1 file changed

+31
-2
lines changed

user/src/com/google/gwt/junit/server/JUnitHostImpl.java

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
*/
1616
package com.google.gwt.junit.server;
1717

18+
import static com.google.gwt.user.client.rpc.RpcRequestBuilder.MODULE_BASE_HEADER;
19+
1820
import com.google.gwt.core.server.impl.StackTraceDeobfuscator;
1921
import com.google.gwt.junit.JUnitFatalLaunchException;
2022
import com.google.gwt.junit.JUnitMessageQueue;
@@ -25,10 +27,12 @@
2527
import com.google.gwt.junit.client.impl.JUnitResult;
2628
import com.google.gwt.junit.linker.JUnitSymbolMapsLinker;
2729
import com.google.gwt.user.client.rpc.InvocationException;
28-
import com.google.gwt.user.server.rpc.HybridServiceServlet;
2930
import com.google.gwt.user.server.rpc.RPCServletUtils;
31+
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
3032

3133
import java.io.IOException;
34+
import java.net.MalformedURLException;
35+
import java.net.URL;
3236
import java.util.HashMap;
3337
import java.util.concurrent.atomic.AtomicInteger;
3438

@@ -41,7 +45,7 @@
4145
* communication between the unit test code running in a browser and the real
4246
* test process.
4347
*/
44-
public class JUnitHostImpl extends HybridServiceServlet implements JUnitHost {
48+
public class JUnitHostImpl extends RemoteServiceServlet implements JUnitHost {
4549

4650
/**
4751
* A hook into GWTUnitTestShell, the underlying unit test process.
@@ -154,6 +158,31 @@ private String getClientDesc(HttpServletRequest request) {
154158
return machine + " / " + agent;
155159
}
156160

161+
/**
162+
* Extract the module's base path from the current request.
163+
*
164+
* @return the module's base path, modulo protocol and host, as reported by
165+
* {@link com.google.gwt.core.client.GWT#getModuleBaseURL()} or
166+
* <code>null</code> if the request did not contain the
167+
* {@value com.google.gwt.user.client.rpc.RpcRequestBuilder#MODULE_BASE_HEADER} header
168+
*/
169+
private String getRequestModuleBasePath() {
170+
try {
171+
String header = getThreadLocalRequest().getHeader(MODULE_BASE_HEADER);
172+
if (header == null) {
173+
return null;
174+
}
175+
String path = new URL(header).getPath();
176+
String contextPath = getThreadLocalRequest().getContextPath();
177+
if (!path.startsWith(contextPath)) {
178+
return null;
179+
}
180+
return path.substring(contextPath.length());
181+
} catch (MalformedURLException e) {
182+
return null;
183+
}
184+
}
185+
157186
private void initResult(HttpServletRequest request, JUnitResult result) {
158187
result.setAgent(request.getHeader("User-Agent"));
159188
result.setHost(request.getRemoteHost());

0 commit comments

Comments
 (0)