activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1441459 - in /activemq/trunk: activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ activemq-web-console/src/main/java/org/apache/activemq/web/config/
Date Fri, 01 Feb 2013 14:27:56 GMT
Author: gtully
Date: Fri Feb  1 14:27:56 2013
New Revision: 1441459

URL: http://svn.apache.org/viewvc?rev=1441459&view=rev
Log:
add broker nd webconsole round trip itest

Added:
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
  (with props)
Modified:
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
    activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
    activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java

Modified: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java?rev=1441459&r1=1441458&r2=1441459&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
(original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/AbstractFeatureTest.java
Fri Feb  1 14:27:56 2013
@@ -157,10 +157,18 @@ public abstract class AbstractFeatureTes
     }
 
     public static Option[] configureBrokerStart(Option[] existingOptions) {
+        existingOptions = append(
+                replaceConfigurationFile("etc/org.apache.activemq.server-default.cfg", new
File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg")),
+                existingOptions);
+        return append(
+                replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml")),
+                existingOptions);
+    }
+
+    public static Option[] append(Option toAdd, Option[] existingOptions) {
         ArrayList<Option> newOptions = new ArrayList<Option>();
         newOptions.addAll(Arrays.asList(existingOptions));
-        newOptions.add(replaceConfigurationFile("etc/org.apache.activemq.server-default.cfg",
new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg")));
-        newOptions.add(replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml")));
+        newOptions.add(toAdd);
         return newOptions.toArray(new Option[]{});
     }
 

Modified: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java?rev=1441459&r1=1441458&r2=1441459&view=diff
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
(original)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerFeatureTest.java
Fri Feb  1 14:27:56 2013
@@ -41,8 +41,6 @@ public class ActiveMQBrokerFeatureTest e
 
     @Test
     public void test() throws Throwable {
-        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
-        factory.getBrokerURL();
 
         withinReason(new Callable<Boolean>() {
             @Override
@@ -63,15 +61,29 @@ public class ActiveMQBrokerFeatureTest e
 
         // produce and consume
         final String nameAndPayload = String.valueOf(System.currentTimeMillis());
+        produceMessage(nameAndPayload);
+        assertEquals("got our message", nameAndPayload, consumeMessage(nameAndPayload));
+    }
+
+    protected String consumeMessage(String nameAndPayload) throws Exception {
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
         Connection connection = factory.createConnection(USER,PASSWORD);
         connection.start();
         Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-        session.createProducer(session.createQueue(nameAndPayload)).send(session.createTextMessage(nameAndPayload));
-
         MessageConsumer consumer = session.createConsumer(session.createQueue(nameAndPayload));
         TextMessage message = (TextMessage) consumer.receive(4000);
         System.err.println("message: " + message);
-        assertEquals("got our message", nameAndPayload, message.getText());
         connection.close();
+        return message.getText();
     }
+
+    protected void produceMessage(String nameAndPayload) throws Exception {
+        ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
+        Connection connection = factory.createConnection(USER,PASSWORD);
+        connection.start();
+        Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        session.createProducer(session.createQueue(nameAndPayload)).send(session.createTextMessage(nameAndPayload));
+        connection.close();
+    }
+
 }

Added: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java?rev=1441459&view=auto
==============================================================================
--- activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
(added)
+++ activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
Fri Feb  1 14:27:56 2013
@@ -0,0 +1,87 @@
+/**
+ * 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.karaf.itest;
+
+import java.util.concurrent.TimeUnit;
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.UsernamePasswordCredentials;
+import org.apache.commons.httpclient.auth.AuthScope;
+import org.apache.commons.httpclient.methods.GetMethod;
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.CoreOptions;
+import org.ops4j.pax.exam.Option;
+import org.ops4j.pax.exam.junit.Configuration;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+
+
+import static org.junit.Assert.assertEquals;
+
+@RunWith(JUnit4TestRunner.class)
+public class ActiveMQBrokerNdWebConsoleFeatureTest extends ActiveMQBrokerFeatureTest {
+
+    static final String WEB_CONSOLE_URL = "http://localhost:8181/activemqweb/";
+
+    @Configuration
+    public static Option[] configure() {
+        return append(CoreOptions.mavenBundle("commons-codec", "commons-codec").versionAsInProject(),
+                append(CoreOptions.mavenBundle("commons-httpclient", "commons-httpclient").versionAsInProject(),
+                configureBrokerStart(configure("activemq-broker", "activemq-web-console"))));
+    }
+
+    @Override
+    protected void produceMessage(String nameAndPayload) throws Exception {
+        HttpClient client = new HttpClient();
+
+        System.err.println("attempting publish via web console..");
+
+        // set credentials
+        client.getState().setCredentials(
+                new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT),
+                new UsernamePasswordCredentials(USER, PASSWORD)
+         );
+
+        // need to first get the secret
+        GetMethod get = new GetMethod(WEB_CONSOLE_URL + "send.jsp");
+        get.setDoAuthentication(true);
+
+        // Give console some time to start
+        for (int i=0; i<20; i++) {
+            TimeUnit.SECONDS.sleep(1);
+            try {
+                i = client.executeMethod(get);
+            } catch (java.net.ConnectException ignored) {}
+        }
+        assertEquals("get succeeded on " + get, 200, get.getStatusCode());
+
+        String response = get.getResponseBodyAsString();
+        final String secretMarker = "<input type=\"hidden\" name=\"secret\" value=\"";
+        String secret = response.substring(response.indexOf(secretMarker) + secretMarker.length());
+        secret = secret.substring(0, secret.indexOf("\"/>"));
+
+        PostMethod post = new PostMethod(WEB_CONSOLE_URL + "sendMessage.action");
+        post.setDoAuthentication(true);
+        post.addParameter("secret", secret);
+
+        post.addParameter("JMSText", nameAndPayload);
+        post.addParameter("JMSDestination", nameAndPayload);
+        post.addParameter("JMSDestinationType", "queue");
+
+        // execute the send
+        assertEquals("post succeeded, " + post, 302, client.executeMethod(post));
+    }
+}

Propchange: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest/ActiveMQBrokerNdWebConsoleFeatureTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java?rev=1441459&r1=1441458&r2=1441459&view=diff
==============================================================================
--- activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
(original)
+++ activemq/trunk/activemq-web-console/src/main/java/org/apache/activemq/web/config/OsgiConfiguration.java
Fri Feb  1 14:27:56 2013
@@ -73,7 +73,7 @@ public class OsgiConfiguration extends A
 
     @Override
     public void updated(Dictionary dictionary) throws ConfigurationException {
-        jmxUrl = (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_URL);
+        jmxUrl = dictionary != null ? (String)dictionary.get(SystemPropertiesConfiguration.PROPERTY_JMX_URL)
: null;
         if (jmxUrl == null) {
             throw new IllegalArgumentException("A JMS-url must be specified (system property
" + SystemPropertiesConfiguration.PROPERTY_JMX_URL);
         }



Mime
View raw message