Fix JBoss7ServerNonInheritingIntegrationTest

- relax assertion of root_url using the same hostname value as
  `getAttribute(HOSTNAME)`

Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/f466be09
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/f466be09
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/f466be09

Branch: refs/heads/master
Commit: f466be093f2186de9cb56d1d4308137e3dd181c3
Parents: 35e50e6
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/incubator-brooklyn/blob/f466be09/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");

Reply via email to