|
15 | 15 | */
|
16 | 16 | package com.google.gwt.junit.server;
|
17 | 17 |
|
| 18 | +import static com.google.gwt.user.client.rpc.RpcRequestBuilder.MODULE_BASE_HEADER; |
| 19 | + |
18 | 20 | import com.google.gwt.core.server.impl.StackTraceDeobfuscator;
|
19 | 21 | import com.google.gwt.junit.JUnitFatalLaunchException;
|
20 | 22 | import com.google.gwt.junit.JUnitMessageQueue;
|
|
25 | 27 | import com.google.gwt.junit.client.impl.JUnitResult;
|
26 | 28 | import com.google.gwt.junit.linker.JUnitSymbolMapsLinker;
|
27 | 29 | import com.google.gwt.user.client.rpc.InvocationException;
|
28 |
| -import com.google.gwt.user.server.rpc.HybridServiceServlet; |
29 | 30 | import com.google.gwt.user.server.rpc.RPCServletUtils;
|
| 31 | +import com.google.gwt.user.server.rpc.RemoteServiceServlet; |
30 | 32 |
|
31 | 33 | import java.io.IOException;
|
| 34 | +import java.net.MalformedURLException; |
| 35 | +import java.net.URL; |
32 | 36 | import java.util.HashMap;
|
33 | 37 | import java.util.concurrent.atomic.AtomicInteger;
|
34 | 38 |
|
|
41 | 45 | * communication between the unit test code running in a browser and the real
|
42 | 46 | * test process.
|
43 | 47 | */
|
44 |
| -public class JUnitHostImpl extends HybridServiceServlet implements JUnitHost { |
| 48 | +public class JUnitHostImpl extends RemoteServiceServlet implements JUnitHost { |
45 | 49 |
|
46 | 50 | /**
|
47 | 51 | * A hook into GWTUnitTestShell, the underlying unit test process.
|
@@ -154,6 +158,31 @@ private String getClientDesc(HttpServletRequest request) {
|
154 | 158 | return machine + " / " + agent;
|
155 | 159 | }
|
156 | 160 |
|
| 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 | + |
157 | 186 | private void initResult(HttpServletRequest request, JUnitResult result) {
|
158 | 187 | result.setAgent(request.getHeader("User-Agent"));
|
159 | 188 | result.setHost(request.getRemoteHost());
|
|
0 commit comments