activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1441421 - in /activemq/trunk/activemq-karaf-itest/src/test/java/org/apache/activemq/karaf/itest: AbstractFeatureTest.java ActiveMQBrokerFeatureTest.java
Date Fri, 01 Feb 2013 12:21:34 GMT
Author: gtully
Date: Fri Feb  1 12:21:34 2013
New Revision: 1441421

URL: http://svn.apache.org/viewvc?rev=1441421&view=rev
Log:
add produce/consume roundtrip validation

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

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=1441421&r1=1441420&r2=1441421&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 12:21:34 2013
@@ -53,6 +53,8 @@ public abstract class AbstractFeatureTes
     private static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureTest.class);
     private static final long ASSERTION_TIMEOUT = 20000L;
     private static final long COMMAND_TIMEOUT = 10000L;
+    public static final String USER = "karaf";
+    public static final String PASSWORD = "karaf";
 
     static String basedir;
     static {
@@ -92,7 +94,7 @@ public abstract class AbstractFeatureTes
             final PrintStream printStream = new PrintStream(byteArrayOutputStream);
             final CommandSession commandSession = commandProcessor.createSession(System.in,
printStream, printStream);
             commandSession.put("APPLICATION", System.getProperty("karaf.name", "root"));
-            commandSession.put("USER", "karaf");
+            commandSession.put("USER", USER);
             FutureTask<String> commandFuture = new FutureTask<String>(
                     new Callable<String>() {
                         public String call() {
@@ -126,70 +128,6 @@ public abstract class AbstractFeatureTes
     }
 
 
-//    protected void testComponent(String component) throws Exception {
-//        long max = System.currentTimeMillis() + 10000;
-//        while (true) {
-//            try {
-//                assertNotNull("Cannot get component with name: " + component, createCamelContext().getComponent(component));
-//                return;
-//            } catch (Exception t) {
-//                if (System.currentTimeMillis() < max) {
-//                    Thread.sleep(1000);
-//                } else {
-//                    throw t;
-//                }
-//            }
-//        }
-//    }
-//
-//    protected void testDataFormat(String format) throws Exception {
-//        long max = System.currentTimeMillis() + 10000;
-//        while (true) {
-//            try {
-//                DataFormatDefinition dataFormatDefinition = createDataformatDefinition(format);
-//                assertNotNull(dataFormatDefinition);
-//                assertNotNull(dataFormatDefinition.getDataFormat(new DefaultRouteContext(createCamelContext())));
-//                return;
-//            } catch (Exception t) {
-//                if (System.currentTimeMillis() < max) {
-//                    Thread.sleep(1000);
-//                    continue;
-//                } else {
-//                    throw t;
-//                }
-//            }
-//        }
-//    }
-//
-//    protected DataFormatDefinition createDataformatDefinition(String format) {
-//        return null;
-//    }
-
-//    protected void testLanguage(String lang) throws Exception {
-//        long max = System.currentTimeMillis() + 10000;
-//        while (true) {
-//            try {
-//                assertNotNull(createCamelContext().resolveLanguage(lang));
-//                return;
-//            } catch (Exception t) {
-//                if (System.currentTimeMillis() < max) {
-//                    Thread.sleep(1000);
-//                    continue;
-//                } else {
-//                    throw t;
-//                }
-//            }
-//        }
-//    }
-
-//    protected CamelContext createCamelContext() throws Exception {
-//        CamelContextFactory factory = new CamelContextFactory();
-//        factory.setBundleContext(bundleContext);
-//        LOG.info("Get the bundleContext is " + bundleContext);
-//        return factory.createContext();
-//    }
-
-
     public static String karafVersion() {
         return System.getProperty("karafVersion", "2.3.0");
     }

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=1441421&r1=1441420&r2=1441421&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 12:21:34 2013
@@ -17,6 +17,10 @@
 package org.apache.activemq.karaf.itest;
 
 import java.util.concurrent.Callable;
+import javax.jms.Connection;
+import javax.jms.MessageConsumer;
+import javax.jms.Session;
+import javax.jms.TextMessage;
 import org.apache.activemq.ActiveMQConnectionFactory;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -40,7 +44,7 @@ public class ActiveMQBrokerFeatureTest e
         ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
         factory.getBrokerURL();
 
-        withinReason(new Callable<Boolean>(){
+        withinReason(new Callable<Boolean>() {
             @Override
             public Boolean call() throws Exception {
                 assertEquals("brokerName = amq-broker", executeCommand("activemq:list").trim());
@@ -57,5 +61,17 @@ public class ActiveMQBrokerFeatureTest e
             }
         });
 
+        // produce and consume
+        final String nameAndPayload = String.valueOf(System.currentTimeMillis());
+        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();
     }
 }



Mime
View raw message