-
1. Re: find out URL of embedded deployed webapp
kpiwko Jan 3, 2014 11:25 AM (in response to tomeicher)1 of 1 people found this helpfulHey Tom,
I expect that you want to run HttpUnit as client, not inside the server, right? In such case, you can "force" only one method to run as client and inject URL there:
@Test @RunAsClient public void myHttpUnitTest(@ArquillianResource URL contextPath) { // context path is for instance http://localhost:8080/testApp here, based on you container and deployment }
If that's not the case, workaround is to use following trick
static URL myUrlField; @InSequence(1) @Test @RunAsClient public void getURL(@ArquillianResource URL url) { myUrlField = url; } @InSequence(2) @Test public void myTest() { // this test is running inside of the server, but it has access to myUrlField, which contains url of the deployment, because the first test set static field }
Hope that helps,
Karel
-
2. Re: find out URL of embedded deployed webapp
tomeicher Jan 8, 2014 5:45 AM (in response to kpiwko)Hello Karel, many thanks,
yes, I need the URL in a server test, i.e. testable=true, i.e. not RunAsClient test.
(Reason: I need access to EJBs and EntityManager to setup the test environment for http call, and to verify the result of the http call)
This is a neat little trick with the static, however, it does not work for me (Arquillian 1.0.3 against JBossAS 7.2.0.Final),
since the test-classes' classloaders are different (have different hashCode()s).
Also, System.getProperties() is different (has different hashCode()s) in the client and server tests.
...
Any more good ideas appreciated...
Cheers, Tom.
-
3. Re: find out URL of embedded deployed webapp
kpiwko Jan 8, 2014 10:45 AM (in response to tomeicher)Hmm, I wasn't aware of that class loader might play role here, good to know. Actually, I think it is a bug, Arquillian should transfer state of static fields no matter of class loader instance, because having different classloaders is somehow expected - tests are running in different JVMs. I'm wondering why I've never hit such issue.
Another idea is to have a look at Arquillian Warp extension - arquillian-extension-warp/README.md at master · arquillian/arquillian-extension-warp · GitHub. It supports JSF, JAXRS, SpringMVC only but you might be able to rewrite the test by exposing REST endpoint or maybe you could alter Warp to fit your needs.
Karel
-
4. Re: find out URL of embedded deployed webapp
tomeicher Jan 10, 2014 7:26 AM (in response to kpiwko)Well, for now I made it a manual deploy configuration.
A bit disappointing, though...
See also: [ARQ-540] Support @ArquillianResource URL for in-container test cases - JBoss Issue Tracker
-
5. Re: find out URL of embedded deployed webapp
kpiwko Jan 12, 2014 10:52 AM (in response to tomeicher)Hi Tom,
other solution that pops up in mind is to use ServerSetupTask to propagate system property from client to server. It could help you to propagate at least base URL of the application server that is configured in arquillian.xml. This is used in AS7/WF testsuite as well.
Some details here:
HTH,
Karel