Source:
<code>public void test( @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) URL baseURLDep1, @ArquillianResource @OperateOnDeployment(DEPLOYMENT_2) URL baseURLDep2) throws URISyntaxException, IOException { <START> URL baseURL1 = new URL(baseURLDep1.toExternalForm() + "/"); <END> URL baseURL2 = new URL(baseURLDep2.toExternalForm() + "/"); URI uri11 = SimpleServlet.createURI(baseURL1.toURI().resolve(MODULE_1 + "/").toURL()); URI uri12 = SimpleServlet.createURI(baseURL1.toURI().resolve(MODULE_2 + "/").toURL()); URI uri21 = SimpleServlet.createURI(baseURL2.toURI().resolve(MODULE_1 + "/").toURL()); URI uri22 = SimpleServlet.createURI(baseURL2.toURI().resolve(MODULE_2 + "/").toURL()); try (CloseableHttpClient client = TestHttpClientUtils.promiscuousCookieHttpClient()) { HttpResponse response = client.execute(new HttpGet(uri11)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(1, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri12)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(2, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri21)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(3, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri22)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(4, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } } }</code><technical_language>prefer add SimpleServlet.createURI(...) methods accept a URI avoid need for convoluted URL -> string -> URL -> string -> URL conversions</technical_language>

Target:
public void test( @ArquillianResource @OperateOnDeployment(DEPLOYMENT_1) URL baseURLDep1, @ArquillianResource @OperateOnDeployment(DEPLOYMENT_2) URL baseURLDep2) throws URISyntaxException, IOException { URI baseURI1 = new URI(baseURLDep1.toExternalForm() + "/"); URI baseURI2 = new URI(baseURLDep2.toExternalForm() + "/"); URI uri11 = SimpleServlet.createURI(baseURI1.resolve(MODULE_1 + "/")); URI uri12 = SimpleServlet.createURI(baseURI1.resolve(MODULE_2 + "/")); URI uri21 = SimpleServlet.createURI(baseURI2.resolve(MODULE_1 + "/")); URI uri22 = SimpleServlet.createURI(baseURI2.resolve(MODULE_2 + "/")); try (CloseableHttpClient client = TestHttpClientUtils.promiscuousCookieHttpClient()) { HttpResponse response = client.execute(new HttpGet(uri11)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(1, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri12)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(2, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri21)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(3, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } response = client.execute(new HttpGet(uri22)); try { Assert.assertEquals(HttpServletResponse.SC_OK, response.getStatusLine().getStatusCode()); Assert.assertEquals(4, Integer.parseInt(response.getFirstHeader(SimpleServlet.VALUE_HEADER).getValue())); } finally { HttpClientUtils.closeQuietly(response); } } }