OK,
I figured it out myself. I will write my solution here for the next person who needs to do something similar.
It is a security thing that I can not do cross site calls, it looks that HtmlUnit does not allow me to bypass this.
As an alternative approach I implement a proxy in the GWTTestCase Jetty instance that would forward all calls to the GWT-RPC service.
But then I stumbled on the fact that the servlet refuses the calls because the *.gwt.rpc file can not be found (md5 values are different between a production build and the GWTTestCase generated permutaiton).
The final solution seems to be to use GWT SyncProxy. This is a little open source lib (created for Android development) that allows you to invoke GWT-RPC calls from a regular java application. It seems to download the *.nocache.js file and searches for the MD5 that is needed to construct a correct gwt rpc request.
The only problem seems to be that GWT Sync Proxy does not support the xsilinker, but I can live without this for the moment.
David
On Tue, Apr 1, 2014 at 1:38 PM, stuckagain <david.nouls@gmail.com> wrote:
--Hi,I'm trying to create an integration test that checks if a GWT-RPC service is working with our integration test servers.My initial thought was to just use a GWTTestCase and point the GWT-RPC ServiceDefTarget to the real server.It did not work:
32 [JS executor for com.gargoylesoftware.htmlunit.WebClient@3afb2359] ERROR com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl - Job run failed with unexpected
RuntimeException: Wrapped java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
net.sourceforge.htmlunit.corejs.javascript.WrappedException: Wrapped java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
at net.sourceforge.htmlunit.corejs.javascript.Context.throwAsScriptRuntimeEx(Context.java:1889)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.doSend(XMLHttpRequest.java:681)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest.access0(XMLHttpRequest.java:94)
at com.gargoylesoftware.htmlunit.javascript.host.xml.XMLHttpRequest$1.run(XMLHttpRequest.java:603)
at net.sourceforge.htmlunit.corejs.javascript.Context.call(Context.java:602)
at net.sourceforge.htmlunit.corejs.javascript.ContextFactory.call(ContextFactory.java:507)
at com.gargoylesoftware.htmlunit.javascript.background.JavascriptXMLHttpRequestJob.run(JavascriptXMLHttpRequestJob.java:36)
at com.gargoylesoftware.htmlunit.javascript.background.JavaScriptJobManagerImpl.runSingleJob(JavaScriptJobManagerImpl.java:328)
at com.gargoylesoftware.htmlunit.javascript.background.DefaultJavaScriptExecutor.run(DefaultJavaScriptExecutor.java:162)
at java.lang.Thread.run(Thread.java:724)
Caused by:
java.lang.RuntimeException: No permitted "Access-Control-Allow-Origin" header.
... 9 moreI tried using a Filter that sets the Access-Control-Allow-Origin header to *, but it does not seem to work.Is there a better way to perform this kind of integration test with GWT code ? Or is there a way to disable this check in HtmlUnit ?
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment