You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by ch...@apache.org on 2012/07/28 16:10:40 UTC
svn commit: r1366677 - in
/activemq/activemq-apollo/trunk/apollo-stomp/src/test:
resources/org/apache/activemq/apollo/stomp/
resources/org/apache/activemq/apollo/stomp/test/
scala/org/apache/activemq/apollo/stomp/
scala/org/apache/activemq/apollo/stomp...
Author: chirino
Date: Sat Jul 28 14:10:39 2012
New Revision: 1366677
URL: http://svn.apache.org/viewvc?rev=1366677&view=rev
Log:
Move the websocket tests into the test package.
Added:
activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/
activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket.html
- copied, changed from r1366571, activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/websocket.html
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/ChromeWebDriverTrait.scala
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/FirefoxWebDriverTrait.scala
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebDriverTrait.scala
Removed:
activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/websocket.html
activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/StompWebTest.scala
Copied: activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket.html (from r1366571, activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/websocket.html)
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket.html?p2=activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket.html&p1=activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/websocket.html&r1=1366571&r2=1366677&rev=1366677&view=diff
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/websocket.html (original)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/resources/org/apache/activemq/apollo/stomp/test/websocket.html Sat Jul 28 14:10:39 2012
@@ -23,7 +23,7 @@
<script src="http://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="../../../../../../../../apollo-distro/src/main/release/examples/websocket/js/stomp.js"></script>
+ <script src="../../../../../../../../../apollo-distro/src/main/release/examples/websocket/js/stomp.js"></script>
<script>//<![CDATA[
$(document).ready(function() {
if(window.WebSocket) {
Added: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/ChromeWebDriverTrait.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/ChromeWebDriverTrait.scala?rev=1366677&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/ChromeWebDriverTrait.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/ChromeWebDriverTrait.scala Sat Jul 28 14:10:39 2012
@@ -0,0 +1,38 @@
+/**
+ * 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 org.apache.activemq.apollo.stomp.test
+
+import java.io.File
+import org.openqa.selenium.chrome.{ChromeOptions, ChromeDriver}
+import org.apache.activemq.apollo.util.FileSupport._
+
+trait ChromeWebDriverTrait extends WebDriverTrait {
+ def create_web_driver(profileDir: File) = {
+ // val f = new File("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")
+ // if( f.exists() ) {
+ // System.setProperty("webdriver.chrome.driver", f.getCanonicalPath)
+ // }
+
+ val file = profileDir / "chrome"
+ file.mkdirs
+ val options = new ChromeOptions()
+ options.addArguments("--enable-udd-profiles", "--user-data-dir=" + file, "--allow-file-access-from-files")
+ // val capabilities = new DesiredCapabilities
+ // capabilities.setCapability("chrome.switches", Arrays.asList("--enable-udd-profiles", "--user-data-dir="+file, "--allow-file-access-from-files"));
+ new ChromeDriver(options)
+ }
+}
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/FirefoxWebDriverTrait.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/FirefoxWebDriverTrait.scala?rev=1366677&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/FirefoxWebDriverTrait.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/FirefoxWebDriverTrait.scala Sat Jul 28 14:10:39 2012
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.activemq.apollo.stomp.test
+
+import java.io.File
+import org.apache.activemq.apollo.util.FileSupport._
+import org.openqa.selenium.firefox.{FirefoxDriver, FirefoxProfile}
+
+trait FirefoxWebDriverTrait extends WebDriverTrait {
+ def create_web_driver(profileDir: File) = {
+ var file = profileDir / "firefox"
+ file.mkdirs
+ val profile = new FirefoxProfile(file);
+ new FirefoxDriver(profile)
+ }
+}
\ No newline at end of file
Added: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala?rev=1366677&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/StompWebSocketTests.scala Sat Jul 28 14:10:39 2012
@@ -0,0 +1,114 @@
+/**
+ * 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 org.apache.activemq.apollo.stomp.test
+
+import org.openqa.selenium.{By, WebDriver}
+import org.apache.activemq.apollo.util.FileSupport._
+import java.util.concurrent.TimeUnit._
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+object StompWebSocketTests {
+
+ class ChromeStompWebSocketTest extends StompWebSocketTestBase with ChromeWebDriverTrait
+ class FirefoxStompWebSocketTest extends StompWebSocketTestBase with FirefoxWebDriverTrait
+
+ abstract class StompWebSocketTestBase extends StompTestSupport with WebDriverTrait {
+
+ var driver: WebDriver = _
+
+ override def broker_config_uri = "xml:classpath:apollo-stomp-websocket.xml"
+
+ def ws_port: Int = connector_port("ws").get
+
+ override def beforeAll() = {
+ try {
+ driver = create_web_driver(test_data_dir / "profile")
+ super.beforeAll()
+ } catch {
+ case ignore: Exception =>
+ println("ignoring tests, could not create web driver: " + ignore)
+ }
+ }
+
+ override def afterAll() = {
+ if (driver != null) {
+ driver.quit()
+ driver = null
+ }
+ }
+
+ override protected def test(testName: String, testTags: org.scalatest.Tag*)(testFun: => scala.Unit): Unit = {
+ super.test(testName, testTags: _*) {
+ if (driver != null) {
+ testFun
+ }
+ }
+ }
+
+ test("websocket") {
+ val url = getClass.getResource("websocket.html")
+
+ System.out.println("url: " + url)
+ driver.get(url + "#ws://127.0.0.1:" + ws_port);
+ val web_status = driver.findElement(By.id("status"));
+ val web_received = driver.findElement(By.id("received"));
+
+ while ("Loading" == web_status.getText) {
+ Thread.sleep(100)
+ }
+
+ // Skip test if browser does not support websockets..
+ if (web_status.getText != "No WebSockets") {
+
+ // Wait for it to get connected..
+ within(2, SECONDS) {
+ web_status.getText should be("Connected")
+ }
+
+ // Send a message via normal TCP stomp..
+ connect("1.1")
+ async_send("/queue/websocket", "Hello")
+ within(2, SECONDS) {
+ // it should get received by the websocket client.
+ web_received.getText should be("Hello")
+ }
+
+ // Send a bunch of messages..
+ val send_count = 100000
+ for (i <- 1 to send_count) {
+ async_send("/queue/websocket", "messages #" + i)
+ }
+
+ within(10, SECONDS) {
+ // it should get received by the websocket client.
+ web_received.getText should be("messages #" + send_count)
+ }
+
+ }
+
+ }
+ }
+
+}
+
+
+
Added: activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebDriverTrait.scala
URL: http://svn.apache.org/viewvc/activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebDriverTrait.scala?rev=1366677&view=auto
==============================================================================
--- activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebDriverTrait.scala (added)
+++ activemq/activemq-apollo/trunk/apollo-stomp/src/test/scala/org/apache/activemq/apollo/stomp/test/WebDriverTrait.scala Sat Jul 28 14:10:39 2012
@@ -0,0 +1,30 @@
+/**
+ * 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 org.apache.activemq.apollo.stomp.test
+
+import java.io.File
+import org.openqa.selenium.WebDriver
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="http://hiramchirino.com">Hiram Chirino</a>
+ */
+trait WebDriverTrait {
+ def create_web_driver(profileDir: File): WebDriver
+}
\ No newline at end of file