mirror of https://github.com/apache/activemq.git
add produce/consume roundtrip validation
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1441421 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
d5056d5fdc
commit
88beb15763
|
@ -53,6 +53,8 @@ public abstract class AbstractFeatureTest {
|
|||
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 AbstractFeatureTest {
|
|||
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 AbstractFeatureTest {
|
|||
}
|
||||
|
||||
|
||||
// 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");
|
||||
}
|
||||
|
|
|
@ -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 extends AbstractFeatureTest {
|
|||
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 extends AbstractFeatureTest {
|
|||
}
|
||||
});
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue