activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r1381660 - in /activemq/trunk/activemq-optional/src/test: java/org/apache/activemq/transport/ws/WSTransportTest.java resources/log4j.properties resources/org/apache/activemq/transport/ws/websocket.html webapp/ webapp/websocket.html
Date Thu, 06 Sep 2012 16:19:02 GMT
Author: dejanb
Date: Thu Sep  6 16:19:01 2012
New Revision: 1381660

URL: http://svn.apache.org/viewvc?rev=1381660&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-4028 - added basic support; chrome driver still
doesn't work well with this scenario, so it requires more investigation

Added:
    activemq/trunk/activemq-optional/src/test/webapp/
    activemq/trunk/activemq-optional/src/test/webapp/websocket.html
      - copied, changed from r1380847, activemq/trunk/activemq-optional/src/test/resources/org/apache/activemq/transport/ws/websocket.html
Removed:
    activemq/trunk/activemq-optional/src/test/resources/org/apache/activemq/transport/ws/websocket.html
Modified:
    activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
    activemq/trunk/activemq-optional/src/test/resources/log4j.properties

Modified: activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java?rev=1381660&r1=1381659&r2=1381660&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
(original)
+++ activemq/trunk/activemq-optional/src/test/java/org/apache/activemq/transport/ws/WSTransportTest.java
Thu Sep  6 16:19:01 2012
@@ -29,8 +29,16 @@ import java.net.UnknownHostException;
 
 import org.apache.activemq.broker.BrokerFactory;
 import org.apache.activemq.broker.BrokerService;
+import org.apache.activemq.broker.SslContext;
+import org.apache.activemq.spring.SpringSslContext;
 import org.apache.activemq.transport.stomp.StompConnection;
 import org.apache.activemq.util.Wait;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.nio.SelectChannelConnector;
+import org.eclipse.jetty.server.ssl.SslSocketConnector;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+import org.eclipse.jetty.webapp.WebAppContext;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -51,11 +59,12 @@ public class WSTransportTest {
     private static final int MESSAGE_COUNT = 1000;
 
     private BrokerService broker;
+    private Server server;
     private WebDriver driver;
     private File profileDir;
 
     private String stompUri;
-    private String wsUri;
+    protected String wsUri;
 
     private StompConnection stompConnection = new StompConnection();
 
@@ -63,8 +72,16 @@ public class WSTransportTest {
         BrokerService broker = BrokerFactory.createBroker(
                 new URI("broker:()/localhost?persistent=false&useJmx=false"));
 
+        SpringSslContext context = new SpringSslContext();
+        context.setKeyStore("src/test/resources/server.keystore");
+        context.setKeyStoreKeyPassword("password");
+        context.setTrustStore("src/test/resources/client.keystore");
+        context.setTrustStorePassword("password");
+        context.afterPropertiesSet();
+        broker.setSslContext(context);
+
         stompUri = broker.addConnector("stomp://localhost:0").getPublishableConnectString();
-        wsUri = broker.addConnector("ws://127.0.0.1:61623?websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001").getPublishableConnectString();
+        wsUri = broker.addConnector(getWSConnectorURI()).getPublishableConnectString();
         broker.setDeleteAllMessagesOnStartup(deleteMessages);
         broker.start();
         broker.waitUntilStarted();
@@ -72,6 +89,35 @@ public class WSTransportTest {
         return broker;
     }
 
+    protected String getWSConnectorURI() {
+        return "ws://127.0.0.1:61623?websocket.maxTextMessageSize=99999&transport.maxIdleTime=1001";
+    }
+
+    protected Server createWebServer() throws Exception {
+        Server server = new Server();
+
+        Connector connector = createJettyConnector();
+        connector.setServer(server);
+
+        WebAppContext context = new WebAppContext();
+        context.setResourceBase("src/test/webapp");
+        context.setContextPath("/");
+        context.setServer(server);
+
+        server.setHandler(context);
+        server.setConnectors(new Connector[] {
+                connector
+        });
+        server.start();
+        return server;
+    }
+
+    protected Connector createJettyConnector() {
+        SelectChannelConnector connector = new SelectChannelConnector();
+        connector.setPort(8080);
+        return connector;
+    }
+
     protected void stopBroker() throws Exception {
         if (broker != null) {
             broker.stop();
@@ -85,6 +131,7 @@ public class WSTransportTest {
         profileDir = new File("activemq-data/profiles");
         broker = createBroker(true);
         stompConnect();
+        server = createWebServer();
     }
 
     @After
@@ -99,6 +146,9 @@ public class WSTransportTest {
                 driver.quit();
                 driver = null;
             }
+            if (server != null) {
+                server.stop();
+            }
         }
     }
 
@@ -153,15 +203,13 @@ public class WSTransportTest {
         }
     }
 
-    public void doTestWebSockets(WebDriver driver) throws Exception {
-
-        URL url = getClass().getResource("websocket.html");
-
-        LOG.info("working dir = ");
+    protected String getTestURI() {
+        return "http://localhost:8080/websocket.html#" + wsUri;
+    }
 
-        LOG.info("page url: " + url);
+    public void doTestWebSockets(WebDriver driver) throws Exception {
 
-        driver.get(url + "#" + wsUri);
+        driver.get(getTestURI());
 
         final WebElement webStatus = driver.findElement(By.id("status"));
         final WebElement webReceived = driver.findElement(By.id("received"));

Modified: activemq/trunk/activemq-optional/src/test/resources/log4j.properties
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/resources/log4j.properties?rev=1381660&r1=1381659&r2=1381660&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/test/resources/log4j.properties (original)
+++ activemq/trunk/activemq-optional/src/test/resources/log4j.properties Thu Sep  6 16:19:01
2012
@@ -21,11 +21,14 @@
 log4j.rootLogger=INFO, out, stdout
 
 log4j.logger.org.apache.activemq.spring=WARN
+#log4j.logger.org.apache.activemq=DEBUG
+#log4j.logger.org.eclipse.jetty.io.nio.ssl=DEBUG
+#log4j.logger.org.apache.http=INFO
 
 # CONSOLE appender not used by default
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender
 log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c - %m%n
 
 # File appender
 log4j.appender.out=org.apache.log4j.FileAppender

Copied: activemq/trunk/activemq-optional/src/test/webapp/websocket.html (from r1380847, activemq/trunk/activemq-optional/src/test/resources/org/apache/activemq/transport/ws/websocket.html)
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/test/webapp/websocket.html?p2=activemq/trunk/activemq-optional/src/test/webapp/websocket.html&p1=activemq/trunk/activemq-optional/src/test/resources/org/apache/activemq/transport/ws/websocket.html&r1=1380847&r2=1381660&rev=1381660&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/test/resources/org/apache/activemq/transport/ws/websocket.html
(original)
+++ activemq/trunk/activemq-optional/src/test/webapp/websocket.html Thu Sep  6 16:19:01 2012
@@ -20,10 +20,10 @@
     <meta charset="utf-8">
     <title>Chat Example Using STOMP Over WebSockets</title>
     <!--[if lt IE 9]>
-      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
+      <script src="https://html5shim.googlecode.com/svn/trunk/html5.js"></script>
     <![endif]-->
-    <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
-    <script src="../../../../../../../../activemq-web-demo/src/main/webapp/websocket/stomp.js"></script>
+    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js'></script>
+    <script src="stomp.js"></script>
     <script>//<![CDATA[
     $(document).ready(function() {
       if(window.WebSocket) {
@@ -35,9 +35,14 @@
         var passcode = "password";
         destination = "/queue/websocket";
 
-        $("#status").html("Connecting");
+        $("#status").html("Connecting " + url);
         client = Stomp.client(url);
 
+        // this allows to display debug logs directly on the web page
+        client.debug = function(str) {
+        $("#debug").append(str + "\n");
+        };
+
         // the client is notified when it is connected to the server.
         client.connect(login, passcode, function(frame) {
           $("#status").html("Connected");
@@ -53,6 +58,7 @@
   </head>
   <body>
     <div id="status">Loading</div>
+    <pre id="debug"></pre>
     <div id="received"></div>
   </body>
 </html>



Mime
View raw message