brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [08/10] incubator-brooklyn git commit: fix a few https/tomcat issues
Date Thu, 13 Nov 2014 12:44:15 GMT
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7ef195f0/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerRebindIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerRebindIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerRebindIntegrationTest.java
deleted file mode 100644
index 9a1bd5e..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/Jboss7ServerRebindIntegrationTest.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.entity.webapp.jboss;
-
-import static org.testng.Assert.assertEquals;
-
-import java.net.URL;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.rebind.RebindTestFixtureWithApp;
-import brooklyn.entity.rebind.RebindTestUtils;
-import brooklyn.location.basic.LocalhostMachineProvisioningLocation;
-import brooklyn.test.EntityTestUtils;
-import brooklyn.test.HttpTestUtils;
-import brooklyn.test.WebAppMonitor;
-import brooklyn.test.entity.TestApplication;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
-/**
- * TODO re-write this like WebAppIntegrationTest, rather than being jboss7 specific.
- */
-public class Jboss7ServerRebindIntegrationTest extends RebindTestFixtureWithApp {
-    private static final Logger LOG = LoggerFactory.getLogger(Jboss7ServerRebindIntegrationTest.class);
-    
-    private URL warUrl;
-    private LocalhostMachineProvisioningLocation localhostProvisioningLocation;
-    private TestApplication newApp;
-    private List<WebAppMonitor> webAppMonitors = new CopyOnWriteArrayList<WebAppMonitor>();
-    private ExecutorService executor;
-    
-    @BeforeMethod(groups = "Integration")
-    @Override
-    public void setUp() throws Exception {
-        super.setUp();
-        String warPath = "hello-world.war";
-        warUrl = getClass().getClassLoader().getResource(warPath);
-        executor = Executors.newCachedThreadPool();
-        localhostProvisioningLocation = (LocalhostMachineProvisioningLocation) origManagementContext.getLocationRegistry().resolve("localhost");
-    }
-
-    @Override
-    @AfterMethod(alwaysRun=true)
-    public void tearDown() throws Exception {
-        for (WebAppMonitor monitor : webAppMonitors) {
-            monitor.terminate();
-        }
-        if (executor != null) executor.shutdownNow();
-        super.tearDown();
-    }
-
-    private WebAppMonitor newWebAppMonitor(String url) {
-        WebAppMonitor monitor = new WebAppMonitor(url)
-//                .delayMillis(0)
-                .logFailures(LOG);
-        webAppMonitors.add(monitor);
-        executor.execute(monitor);
-        return monitor;
-    }
-    
-    @Test(groups = "Integration")
-    public void testRebindsToRunningServer() throws Exception {
-        // Start an app-server, and wait for it to be fully up
-        JBoss7Server origServer = origApp.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                    .configure("war", warUrl.toString()));
-        
-        origApp.start(ImmutableList.of(localhostProvisioningLocation));
-        
-        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(origServer.getAttribute(JBoss7Server.ROOT_URL),
200);
-        WebAppMonitor monitor = newWebAppMonitor(origServer.getAttribute(JBoss7Server.ROOT_URL));
-        
-        // Rebind
-        newApp = rebind(false, true);
-        JBoss7Server newServer = (JBoss7Server) Iterables.find(newApp.getChildren(), Predicates.instanceOf(JBoss7Server.class));
-        String newRootUrl = newServer.getAttribute(JBoss7Server.ROOT_URL);
-        
-        assertEquals(newRootUrl, origServer.getAttribute(JBoss7Server.ROOT_URL));
-        assertEquals(newServer.getAttribute(JBoss7Server.MANAGEMENT_HTTP_PORT), origServer.getAttribute(JBoss7Server.MANAGEMENT_HTTP_PORT));
-        assertEquals(newServer.getAttribute(JBoss7Server.DEPLOYED_WARS), origServer.getAttribute(JBoss7Server.DEPLOYED_WARS));
-        
-        EntityTestUtils.assertAttributeEqualsEventually(newServer, SoftwareProcess.SERVICE_UP,
true);
-        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(newRootUrl, 200);
-
-        // confirm that deploy() effector affects the correct jboss server 
-        newServer.deploy(warUrl.toString(), "myhello.war");
-        HttpTestUtils.assertHttpStatusCodeEventuallyEquals(newRootUrl+"myhello", 200);
-        
-        // check we see evidence of the enrichers and sensor-feeds having an effect.
-        // Relying on WebAppMonitor to cause these to change.
-        EntityTestUtils.assertAttributeChangesEventually(newServer, JBoss7Server.REQUEST_COUNT);
-        EntityTestUtils.assertAttributeChangesEventually(newServer, JBoss7Server.REQUESTS_PER_SECOND_IN_WINDOW);
-        EntityTestUtils.assertAttributeChangesEventually(newServer, JBoss7Server.REQUESTS_PER_SECOND_IN_WINDOW);
-        EntityTestUtils.assertAttributeChangesEventually(newServer, JBoss7Server.PROCESSING_TIME_FRACTION_IN_WINDOW);
-        
-        assertEquals(monitor.getFailures(), 0);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7ef195f0/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JbossServerWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JbossServerWebAppFixtureIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JbossServerWebAppFixtureIntegrationTest.java
deleted file mode 100644
index 3b0bdf9..0000000
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/jboss/JbossServerWebAppFixtureIntegrationTest.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package brooklyn.entity.webapp.jboss;
-
-import org.testng.annotations.DataProvider;
-import org.testng.annotations.Test;
-
-import brooklyn.entity.basic.SoftwareProcess;
-import brooklyn.entity.proxying.EntitySpec;
-import brooklyn.entity.webapp.AbstractWebAppFixtureIntegrationTest;
-import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
-import brooklyn.location.basic.PortRanges;
-import brooklyn.test.entity.TestApplication;
-
-public class JbossServerWebAppFixtureIntegrationTest extends AbstractWebAppFixtureIntegrationTest
{
-
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void testReportsServiceDownWhenKilled(final SoftwareProcess entity) throws Exception
{
-        super.testReportsServiceDownWhenKilled(entity);
-    }
-    
-    @DataProvider(name = "basicEntities")
-    public Object[][] basicEntities() {
-        TestApplication jboss6App = newTestApplication();
-        JBoss6Server jboss6 = jboss6App.createAndManageChild(EntitySpec.create(JBoss6Server.class)
-                .configure(JBoss6Server.PORT_INCREMENT, PORT_INCREMENT));
-        
-        TestApplication jboss7App = newTestApplication();
-        JBoss7Server jboss7 = jboss7App.createAndManageChild(EntitySpec.create(JBoss7Server.class)
-                .configure(JBoss7Server.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT)));
-        
-        return new JavaWebAppSoftwareProcess[][] {
-                new JavaWebAppSoftwareProcess[] {jboss6}, 
-                new JavaWebAppSoftwareProcess[] {jboss7}
-                
-        };
-    }
-
-    // to be able to test on this class in Eclipse IDE
-    @Test(groups = "Integration", dataProvider = "basicEntities")
-    public void canStartAndStop(final SoftwareProcess entity) {
-        super.canStartAndStop(entity);
-    }
-
-//    @Override
-//    // TODO override parent and add seam-booking-as{6,7}
-//    @DataProvider(name = "entitiesWithWarAndURL")
-//    public Object[][] entitiesWithWar() {
-//        List<Object[]> result = Lists.newArrayList();
-//        
-//        for (Object[] entity : basicEntities()) {
-//            result.add(new Object[] {
-//                    entity[0],
-//                    "hello-world.war",
-//                    "hello-world/",
-//                    "" // no sub-page path
-//                    });
-//        }
-//        
-//        TestApplication tomcatApp = newTestApplication();
-//        TomcatServer tomcat = tomcatApp.createAndManageChild(EntitySpec.create(TomcatServer.class)
-//                .configure(TomcatServer.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT)));
-//        result.add(new Object[] {
-//                tomcat,
-//                "swf-booking-mvc.war",
-//                "swf-booking-mvc/",
-//                "spring/intro",
-//               });
-//            // FIXME seam-booking does not work
-////            [   new JBoss6ServerImpl(parent:application, portIncrement:PORT_INCREMENT),
-////              "seam-booking-as6.war",
-////                "seam-booking-as6/",
-////            ],
-////            [   new JBoss7ServerImpl(parent:application, httpPort:DEFAULT_HTTP_PORT),
-////                "seam-booking-as7.war",
-////                "seam-booking-as7/",
-////            ],
-//        
-//        return result.toArray(new Object[][] {});
-//    }
-
-    public static void main(String ...args) throws Exception {
-        JbossServerWebAppFixtureIntegrationTest t = new JbossServerWebAppFixtureIntegrationTest();
-        t.setUp();
-        t.testReportsServiceDownWhenKilled((SoftwareProcess) t.basicEntities()[0][0]);
-        t.shutdownApp();
-        t.shutdownMgmt();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7ef195f0/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
index ff9ed93..39c775d 100644
--- a/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
+++ b/software/webapp/src/test/java/brooklyn/entity/webapp/tomcat/TomcatServerWebAppFixtureIntegrationTest.java
@@ -32,21 +32,21 @@ import org.slf4j.LoggerFactory;
 import org.testng.Assert;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.DataProvider;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Lists;
+import org.testng.annotations.Test;
 
 import brooklyn.entity.basic.SoftwareProcess;
 import brooklyn.entity.proxying.EntitySpec;
 import brooklyn.entity.webapp.AbstractWebAppFixtureIntegrationTest;
 import brooklyn.entity.webapp.HttpsSslConfig;
 import brooklyn.entity.webapp.JavaWebAppSoftwareProcess;
-import brooklyn.entity.webapp.jboss.JBoss7Server;
 import brooklyn.location.basic.PortRanges;
 import brooklyn.test.entity.TestApplication;
 import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.repeat.Repeater;
 
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+
 public class TomcatServerWebAppFixtureIntegrationTest extends AbstractWebAppFixtureIntegrationTest
{
 
     @SuppressWarnings("unused")
@@ -67,22 +67,27 @@ public class TomcatServerWebAppFixtureIntegrationTest extends AbstractWebAppFixt
             throw Exceptions.propagate(e);
         }
 
-        TomcatServer httpsTomcat = tomcatApp.createAndManageChild(EntitySpec.create(TomcatServer.class)
-                .configure(TomcatServer.HTTP_PORT, PortRanges.fromString(DEFAULT_HTTP_PORT))
+        TestApplication tomcatHttpsApp = newTestApplication();
+        TomcatServer httpsTomcat = tomcatHttpsApp.createAndManageChild(EntitySpec.create(TomcatServer.class)
                 .configure(TomcatServer.ENABLED_PROTOCOLS, ImmutableSet.of("https"))
                 .configure(TomcatServer.HTTPS_SSL_CONFIG,
                         new HttpsSslConfig().keyAlias("myname").keystorePassword("mypass").keystoreUrl(keystoreFile.getAbsolutePath())));
 
         return new JavaWebAppSoftwareProcess[][] {
-                new JavaWebAppSoftwareProcess[] { tomcat, httpsTomcat }
+                new JavaWebAppSoftwareProcess[] { tomcat },
+                new JavaWebAppSoftwareProcess[] { httpsTomcat }
         };
     }
 
-//    // uncomment to be able to test on this class from GUI in Eclipse IDE
-//    @Test(groups = "Integration", dataProvider = "basicEntities")
-//    public void canStartAndStop(final SoftwareProcess entity) {
-//        super.canStartAndStop(entity);
-//    }
+    // exists to be able to test on this class from GUI in Eclipse IDE
+    @Test(groups = "Integration", dataProvider = "basicEntities")
+    public void canStartAndStop(final SoftwareProcess entity) {
+        super.canStartAndStop(entity);
+    }
+    @Test(groups = "Integration", dataProvider = "basicEntities")
+    public void testReportsServiceDownWhenKilled(final SoftwareProcess entity) throws Exception
{
+        super.testReportsServiceDownWhenKilled(entity);
+    }
 
     @Override
     // as parent, but with spring travel

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/7ef195f0/usage/camp/src/test/resources/test-tomcat-https.yaml
----------------------------------------------------------------------
diff --git a/usage/camp/src/test/resources/test-tomcat-https.yaml b/usage/camp/src/test/resources/test-tomcat-https.yaml
new file mode 100644
index 0000000..88209a1
--- /dev/null
+++ b/usage/camp/src/test/resources/test-tomcat-https.yaml
@@ -0,0 +1,29 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#  http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+name: Test Tomcat HTTPS
+location: localhost
+services:
+- type: brooklyn.entity.webapp.tomcat.TomcatServer
+  war: http://search.maven.org/remotecontent?filepath=io/brooklyn/example/brooklyn-example-hello-world-sql-webapp/0.6.0/brooklyn-example-hello-world-sql-webapp-0.6.0.war
+  quorumSize: 2
+  enabledProtocols: [https]
+  httpsSsl:
+    url: classpath://brooklyn/entity/webapp/sample-java-keystore.jks
+    alias: myname
+    password: mypass


Mime
View raw message