I am trying to run an asynchronous test and need to send a request to my server, which has a REST-API. So my problem is that the tests are executed on the local machine, but this obviously violates the same origin policy and I get a RuntimeError if I try to run the GWTtestCase:
com.google.gwt.http.client.RequestPermissionException: The URL http://<url-to-my-rest-service> is invalid or violates the same-origin security restriction
at com.google.gwt.http.client.RequestBuilder.doSend(RequestBuilder.java:394)
at com.google.gwt.http.client.RequestBuilder.send(RequestBuilder.java:242)
...
I know that I can run these tests manually, but with the latest updates of my browser (chromium), the GWT-Plugin was removed. So I don't know how to launch the tests in SuperDevMode.
Edit:
If I want to run the tests manually I write the following into the terminal:
mvn gwt:test -Dgwt.args="-prod -userAgents safari -runStyle Manual:1"
Maven then will print an URL to the terminal which I should enter into the browser to execute the tests:
http://127.0.1.1:57818/<my-package>.JUnit/junit-standards.html?gwt.codesvr=127.0.1.1:40387
But if I enter this URL into my browser (Chromium) it will notify me that the GWT-Plugin is currently not installed. If I remove the part behind the question mark (like I do if I want to run the GWT-Code in SuperDevMode on the localhost) ?gwt.codesvr=127.0.1.1:40387
then the browser will show only a blank page, and also if I started the codeserver with:
mvn process-classes gwt:run-codeserver
the codeserver-bookmarks (Dev Mode On
) are not working and GWT is not able to detect a module which is "compilable".
So how excatly do I compile the JUnit-Test-Module with the SuperDevMode?
You can't bypass the SOP, but you could use a servlet to proxy requests to your remote server (servlets declared with <servlet>
in your gwt.xml files are honored by JUnitShell).
And if you want to run the tests in Chrome/Chromium, you can either use -runStyle Manual
or Selenium (note: there's even a custom run style for PhantomJS), and because DevMode no longer works, as you noted, you'd have to run tests in prod mode: -prod -userAgents safari