When dealing with multiple different environments and hidden dynamic container configuration you very soon come to a point where you need access to the backing containers ip/port/context information. This is especially useful when doing remote end point testing. So instead of trying to setup all containers on the same ip/port/context, or hard code this in your test, Arquillian provides something we call @ArquillianResource injection. Via this injection point we can expose multiple internal objects.
Note that @ArquillianResource injection of URLs is only supported for in-container tests since Arquillian version 1.1.9.Final (see ARQ-540).
When you need to get a hold of the request URI (up through the context path) your Deployment defined, e.g. "http://localhost:8080/test", you can use @ArquillianResource on a field or method argument of type URL:
If you are deploying an EAR with multiple WARs, and you've deployed a given servlet to just one of them, you can provide the servlet's class to get the request URI up through the context path for the WAR that contains that servlet, e.g. "http://localhost:8080/test1" vs. "http://localhost:8080/test2":
Note that this version does not return the request URI to the given servlet, e.g. "http://localhost:8080/test2/MyServlet", but again just the request URI up through the context path.