Fix JBoss7ServerNonInheritingIntegrationTest - relax assertion of root_url using the same hostname value as `getAttribute(HOSTNAME)`
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-library/repo Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-library/commit/a29eab17 Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-library/tree/a29eab17 Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-library/diff/a29eab17 Branch: refs/heads/0.7.0-incubating Commit: a29eab170d8bbbf47f1da82ae4c749867c06e58a Parents: aba2fbe Author: Aled Sage <[email protected]> Authored: Mon Jun 22 00:30:02 2015 +0100 Committer: Aled Sage <[email protected]> Committed: Mon Jun 22 00:30:02 2015 +0100 ---------------------------------------------------------------------- ...Boss7ServerNonInheritingIntegrationTest.java | 26 ++++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/brooklyn-library/blob/a29eab17/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java ---------------------------------------------------------------------- diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java index 948a9d6..5f13362 100644 --- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java +++ b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JBoss7ServerNonInheritingIntegrationTest.java @@ -78,14 +78,13 @@ public class JBoss7ServerNonInheritingIntegrationTest extends BrooklynAppLiveTes app.start(ImmutableList.of(localhostProvisioningLocation)); - String httpUrl = "http://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/"; - String httpsUrl = "https://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/"; - - assertEquals(server.getAttribute(JBoss7Server.ROOT_URL).toLowerCase(), httpUrl.toLowerCase()); - + // Don't rely on hostname; differs from URL when tests run on AWS VM + String httpUrl = server.getAttribute(JBoss7Server.ROOT_URL); + assertEquals(httpUrl.toLowerCase(), ("http://"+URI.create(httpUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/").toLowerCase()); HttpTestUtils.assertHttpStatusCodeEventuallyEquals(httpUrl, 200); HttpTestUtils.assertContentContainsText(httpUrl, "Hello"); + String httpsUrl = "https://"+URI.create(httpUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/"; HttpTestUtils.assertUrlUnreachable(httpsUrl); Asserts.succeedsEventually(new Runnable() { @@ -108,11 +107,11 @@ public class JBoss7ServerNonInheritingIntegrationTest extends BrooklynAppLiveTes app.start(ImmutableList.of(localhostProvisioningLocation)); - String httpUrl = "http://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/"; - String httpsUrl = "https://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/"; - - assertEquals(server.getAttribute(JBoss7Server.ROOT_URL).toLowerCase(), httpsUrl.toLowerCase()); + // Don't rely on hostname; differs from URL when tests run on AWS VM + String httpsUrl = server.getAttribute(JBoss7Server.ROOT_URL); + assertEquals(httpsUrl.toLowerCase(), ("https://"+URI.create(httpsUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/").toLowerCase()); + String httpUrl = "http://"+URI.create(httpsUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/"; HttpTestUtils.assertUrlUnreachable(httpUrl); // FIXME HttpTestUtils isn't coping with https, giving @@ -144,11 +143,12 @@ public class JBoss7ServerNonInheritingIntegrationTest extends BrooklynAppLiveTes .configure(JBoss7Server.HTTPS_SSL_CONFIG, new HttpsSslConfig().keyAlias("myname").keystorePassword("mypass").keystoreUrl(keystoreFile.getAbsolutePath()))); app.start(ImmutableList.of(localhostProvisioningLocation)); - - String httpUrl = "http://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/"; - String httpsUrl = "https://"+server.getAttribute(JBoss7Server.HOSTNAME)+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/"; - assertEquals(server.getAttribute(JBoss7Server.ROOT_URL).toLowerCase(), httpsUrl.toLowerCase()); + // Don't rely on hostname; differs from URL when tests run on AWS VM + String httpsUrl = server.getAttribute(JBoss7Server.ROOT_URL); + String httpUrl = "http://"+URI.create(httpsUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTP_PORT)+"/"; + + assertEquals(httpsUrl.toLowerCase(), ("https://"+URI.create(httpsUrl).getHost()+":"+server.getAttribute(JBoss7Server.HTTPS_PORT)+"/").toLowerCase()); HttpTestUtils.assertHttpStatusCodeEventuallyEquals(httpUrl, 200); HttpTestUtils.assertContentContainsText(httpUrl, "Hello");
