https://issues.apache.org/jira/browse/AMQ-5526 - tidy up karaf-itest, features amqp now work,still issue with camel and bundlecontext null

This commit is contained in:
gtully 2015-01-21 15:10:09 +00:00
parent 548aa1e415
commit 25f18ad20d
14 changed files with 268 additions and 357 deletions

View File

@ -40,15 +40,25 @@
<artifactId>activemq-karaf</artifactId>
<scope>test</scope>
</dependency>
<!-- xbean gets lost in the pax exam container
these are here for versionFromProject manual install for broker feature pax-war dependency-->
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
<version>1.6.2</version>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-finder</artifactId>
<version>${xbean-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
<version>1.6.2</version>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-asm-util</artifactId>
<version>${xbean-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.xbean</groupId>
<artifactId>xbean-bundleutils</artifactId>
<version>${xbean-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
@ -67,54 +77,6 @@
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.runner</groupId>
<artifactId>pax-runner-no-jcl</artifactId>
<version>${pax-runner-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.swissbox</groupId>
<artifactId>pax-swissbox-tinybundles</artifactId>
<version>${pax-tiny-bundle-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-remote</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-rbc</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-rbc-client</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-invoker-junit</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-inject</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-extender-service</artifactId>
<version>${pax-exam-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
@ -127,26 +89,6 @@
<version>${karaf-version}</version>
<type>tar.gz</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.dev</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse</groupId>
<artifactId>osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.configadmin</artifactId>
<version>${felix-configadmin-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
@ -159,6 +101,18 @@
<artifactId>proton-jms</artifactId>
<version>${qpid-proton-version}</version>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-amqp-1-0-common</artifactId>
<version>${qpid-jms-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-amqp-1-0-client</artifactId>
<version>${qpid-jms-version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-amqp-1-0-client-jms</artifactId>

View File

@ -16,9 +16,12 @@
*/
package org.apache.activemq.karaf.itest;
import javax.security.auth.Subject;
import org.apache.felix.service.command.CommandProcessor;
import org.apache.felix.service.command.CommandSession;
import org.apache.karaf.features.FeaturesService;
import org.apache.karaf.jaas.boot.principal.RolePrincipal;
import org.apache.karaf.jaas.boot.principal.UserPrincipal;
import org.junit.After;
import org.junit.Before;
import org.ops4j.pax.exam.Option;
@ -27,6 +30,7 @@ import org.ops4j.pax.exam.ProbeBuilder;
import org.ops4j.pax.exam.karaf.options.KarafDistributionOption;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.UrlReference;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
import org.slf4j.Logger;
@ -37,6 +41,7 @@ import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.PrintStream;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.concurrent.Callable;
@ -48,16 +53,13 @@ import java.util.concurrent.TimeUnit;
import static org.ops4j.pax.exam.CoreOptions.*;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.*;
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 = 30000L;
public static final Logger LOG = LoggerFactory.getLogger(AbstractFeatureTest.class);
public static final long ASSERTION_TIMEOUT = 30000L;
public static final long COMMAND_TIMEOUT = 30000L;
public static final String USER = "karaf";
public static final String PASSWORD = "karaf";
@ -66,13 +68,14 @@ public abstract class AbstractFeatureTest {
try {
File location = new File(AbstractFeatureTest.class.getProtectionDomain().getCodeSource().getLocation().getFile());
basedir = new File(location, "../..").getCanonicalPath();
System.err.println("basedir=" + basedir);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
@Inject
protected BundleContext bundleContext;
BundleContext bundleContext;
@Inject
FeaturesService featuresService;
@ -97,39 +100,49 @@ public abstract class AbstractFeatureTest {
ExecutorService executor = Executors.newCachedThreadPool();
protected String executeCommand(final String command, final Long timeout, final Boolean silent) {
String response;
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
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", USER);
FutureTask<String> commandFuture = new FutureTask<String>(
new Callable<String>() {
public String call() {
try {
if (!silent) {
System.out.println(command);
System.out.flush();
String response;
final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
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", USER);
FutureTask<String> commandFuture = new FutureTask<String>(
new Callable<String>() {
public String call() {
Subject subject = new Subject();
subject.getPrincipals().add(new UserPrincipal("admin"));
subject.getPrincipals().add(new RolePrincipal("admin"));
subject.getPrincipals().add(new RolePrincipal("manager"));
subject.getPrincipals().add(new RolePrincipal("viewer"));
return Subject.doAs(subject, new PrivilegedAction<String>() {
@Override
public String run() {
try {
if (!silent) {
System.out.println(command);
System.out.flush();
}
commandSession.execute(command);
} catch (Exception e) {
e.printStackTrace(System.err);
}
commandSession.execute(command);
} catch (Exception e) {
e.printStackTrace(System.err);
printStream.flush();
return byteArrayOutputStream.toString();
}
printStream.flush();
return byteArrayOutputStream.toString();
}
});
});
}});
try {
executor.submit(commandFuture);
response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (Exception e) {
e.printStackTrace(System.err);
response = "SHELL COMMAND TIMED OUT: ";
}
return response;
try {
executor.submit(commandFuture);
response = commandFuture.get(timeout, TimeUnit.MILLISECONDS);
} catch (Exception e) {
e.printStackTrace(System.err);
response = "SHELL COMMAND TIMED OUT: ";
}
LOG.info("Execute: " + command + " - Response:" + response);
return response;
}
protected String executeCommand(final String command) {
return executeCommand(command, COMMAND_TIMEOUT, false);
@ -141,8 +154,13 @@ public abstract class AbstractFeatureTest {
* @throws Exception
*/
public void installAndAssertFeature(final String feature) throws Throwable {
System.err.println(executeCommand("features:install " + feature));
System.err.println(executeCommand("osgi:list -t 0"));
executeCommand("osgi:list -t 0");
executeCommand("features:install " + feature);
assertFeatureInstalled(feature);
}
public void assertFeatureInstalled(final String feature) throws Throwable {
executeCommand("osgi:list -t 0");
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
@ -150,9 +168,19 @@ public abstract class AbstractFeatureTest {
return true;
}
});
}
}
public boolean verifyBundleInstalled(final String bundleName) throws Exception {
boolean found = false;
for (Bundle bundle: bundleContext.getBundles()) {
LOG.debug("Checking: " + bundle.getSymbolicName());
if (bundle.getSymbolicName().equals(bundleName)) {
found = true;
break;
}
}
return found;
}
public static String karafVersion() {
return System.getProperty("karafVersion", "unknown-need-env-var");
@ -160,8 +188,10 @@ public abstract class AbstractFeatureTest {
public static UrlReference getActiveMQKarafFeatureUrl() {
String type = "xml/features";
return mavenBundle().groupId("org.apache.activemq").
UrlReference urlReference = mavenBundle().groupId("org.apache.activemq").
artifactId("activemq-karaf").versionAsInProject().type(type);
System.err.println("FeatureURL: " + urlReference.getURL());
return urlReference;
}
// for use from a probe
@ -185,10 +215,10 @@ public abstract class AbstractFeatureTest {
public static Option[] configureBrokerStart(Option[] existingOptions, String xmlConfig) {
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")),
replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/" + xmlConfig + ".xml")),
existingOptions);
return append(
replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/" + xmlConfig + ".xml")),
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);
}
@ -212,15 +242,14 @@ public abstract class AbstractFeatureTest {
Option[] options =
new Option[]{
karafDistributionConfiguration().frameworkUrl(
maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").version(karafVersion()))
//This version doesn't affect the version of karaf we use
maven().groupId("org.apache.karaf").artifactId("apache-karaf").type("tar.gz").versionAsInProject())
.karafVersion(karafVersion()).name("Apache Karaf")
.unpackDirectory(new File("target/paxexam/unpack/")),
KarafDistributionOption.keepRuntimeFolder(),
logLevel(LogLevelOption.LogLevel.INFO),
replaceConfigurationFile("etc/config.properties", new File(basedir+"/target/classes/org/apache/activemq/karaf/itest/config.properties")),
replaceConfigurationFile("etc/custom.properties", new File(basedir+"/src/test/resources/org/apache/activemq/karaf/itest/custom.properties")),
logLevel(LogLevelOption.LogLevel.WARN),
editConfigurationFilePut("etc/config.properties", "karaf.startlevel.bundle", "50"),
//debugConfiguration("5005", true),
features(getActiveMQKarafFeatureUrl(), f.toArray(new String[f.size()]))};
return options;

View File

@ -22,7 +22,6 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.channels.FileChannel;
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.MessageConsumer;
import javax.jms.Session;
import javax.jms.TextMessage;
@ -31,6 +30,10 @@ import org.apache.activemq.ActiveMQConnectionFactory;
public abstract class AbstractJmsFeatureTest extends AbstractFeatureTest {
public static void copyFile(File from, File to) throws IOException {
if (!to.exists()) {
System.err.println("Creating new file for: "+ to);
to.createNewFile();
}
FileChannel in = new FileInputStream(from).getChannel();
FileChannel out = new FileOutputStream(to).getChannel();
try {
@ -50,7 +53,7 @@ public abstract class AbstractJmsFeatureTest extends AbstractFeatureTest {
}
}
protected String consumeMessage(String nameAndPayload) throws Exception {
protected String consumeMessage(String nameAndPayload) throws Throwable {
Connection connection = getConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer consumer = session.createConsumer(session.createQueue(nameAndPayload));
@ -60,14 +63,14 @@ public abstract class AbstractJmsFeatureTest extends AbstractFeatureTest {
return message.getText();
}
protected void produceMessage(String nameAndPayload) throws Exception {
protected void produceMessage(String nameAndPayload) throws Throwable{
Connection connection = getConnection();
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
session.createProducer(session.createQueue(nameAndPayload)).send(session.createTextMessage(nameAndPayload));
connection.close();
}
protected Connection getConnection() throws JMSException {
protected Connection getConnection() throws Throwable {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
Connection connection = factory.createConnection(AbstractFeatureTest.USER, AbstractFeatureTest.PASSWORD);
connection.start();

View File

@ -17,15 +17,15 @@
package org.apache.activemq.karaf.itest;
import org.apache.qpid.amqp_1_0.jms.impl.ConnectionFactoryImpl;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import javax.jms.Connection;
import javax.jms.JMSException;
@RunWith(PaxExam.class)
public class ActiveMQAMQPBrokerFeatureTest extends ActiveMQBrokerFeatureTest {
@ -34,33 +34,38 @@ public class ActiveMQAMQPBrokerFeatureTest extends ActiveMQBrokerFeatureTest {
@Configuration
public static Option[] configure() {
Option[] activeMQOptions = configure("activemq");
MavenArtifactProvisionOption qpidClient = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client").versionAsInProject();
MavenArtifactProvisionOption qpidClientJms = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client-jms").versionAsInProject();
MavenArtifactProvisionOption qpidCommon = CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-common").versionAsInProject();
MavenArtifactProvisionOption geronimoJms = CoreOptions.mavenBundle("org.apache.geronimo.specs", "geronimo-jms_1.1_spec").versionAsInProject();
MavenArtifactProvisionOption geronimoJta = CoreOptions.mavenBundle("org.apache.geronimo.specs", "geronimo-jta_1.1_spec","1.1.1");
final String fragmentHost = "qpid-amqp-jms-client";
Option qpidClient = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client").versionAsInProject().getURL().toString() + "$Bundle-SymbolicName=qpid-amqp-client&Fragment-Host=" + fragmentHost);
Option qpidClientJms = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-client-jms").versionAsInProject().getURL().toString() + "$Bundle-SymbolicName=" + fragmentHost);
Option qpidCommon = CoreOptions.wrappedBundle(CoreOptions.mavenBundle("org.apache.qpid", "qpid-amqp-1-0-common").versionAsInProject().getURL().toString());
Option[] options = append(qpidClient, activeMQOptions);
options = append(qpidClientJms, options);
options = append(qpidCommon, options);
options = append(geronimoJms, options);
options = append(geronimoJta, options);
Option[] configuredOptions = configureBrokerStart(options);
return configuredOptions;
}
@Override
protected Connection getConnection() throws JMSException {
ConnectionFactoryImpl factory = new ConnectionFactoryImpl("localhost", AMQP_PORT, AbstractFeatureTest.USER, AbstractFeatureTest.PASSWORD);
Connection connection = factory.createConnection();
connection.start();
protected Connection getConnection() throws Throwable {
ConnectionFactoryImpl factory = new ConnectionFactoryImpl("localhost", AMQP_PORT, AbstractFeatureTest.USER, AbstractFeatureTest.PASSWORD);
Connection connection = null;
ClassLoader originalLoader = Thread.currentThread().getContextClassLoader();
try {
// ensure service loader uses a loader that can find the impl - not the system classpath
Thread.currentThread().setContextClassLoader(factory.getClass().getClassLoader());
connection = factory.createConnection();
connection.start();
} finally {
Thread.currentThread().setContextClassLoader(originalLoader);
}
return connection;
}
@Override
@Ignore
@Test(timeout = 5 * 60 * 1000)
public void testTemporaryDestinations() throws Throwable {
// ignore until we have temporary destination are working in amqp
}

View File

@ -18,7 +18,6 @@ package org.apache.activemq.karaf.itest;
import java.util.concurrent.Callable;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
@ -42,7 +41,7 @@ public class ActiveMQBrokerFeatureTest extends AbstractJmsFeatureTest {
return configureBrokerStart(configure("activemq"));
}
@Test(timeout=2 * 60 * 1000)
@Test(timeout=5 * 60 * 1000)
public void test() throws Throwable {
withinReason(new Callable<Boolean>() {
@ -66,8 +65,15 @@ public class ActiveMQBrokerFeatureTest extends AbstractJmsFeatureTest {
final String nameAndPayload = String.valueOf(System.currentTimeMillis());
produceMessage(nameAndPayload);
System.err.println(executeCommand("activemq:bstat").trim());
assertEquals("JMS_BODY_FIELD:JMSText = " + nameAndPayload, executeCommand("activemq:browse --amqurl tcp://localhost:61616 --user karaf --password karaf -Vbody " + nameAndPayload).trim());
executeCommand("activemq:bstat", COMMAND_TIMEOUT, false).trim();
withinReason(new Callable<Boolean>(){
@Override
public Boolean call() throws Exception {
assertEquals("JMS_BODY_FIELD:JMSText = " + nameAndPayload, executeCommand("activemq:browse --amqurl tcp://localhost:61616 --user karaf --password karaf -Vbody " + nameAndPayload).trim());
return true;
}
});
assertEquals("got our message", nameAndPayload, consumeMessage(nameAndPayload));
}

View File

@ -16,7 +16,10 @@
*/
package org.apache.activemq.karaf.itest;
import java.io.File;
import java.util.Date;
import java.util.concurrent.Callable;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.MavenUtils;
@ -27,23 +30,45 @@ import org.ops4j.pax.exam.junit.PaxExam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
@RunWith(PaxExam.class)
public class ActiveMQBrokerNdCamelFeatureTest extends AbstractJmsFeatureTest {
@Configuration
public static Option[] configure() {
Option[] baseOptions = configure("activemq", "activemq-camel");
return configureBrokerStart(append(features(getCamelFeatureUrl(
MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")
), "activemq-camel"), baseOptions), "activemq-nd-camel");
return append(
editConfigurationFilePut("etc/system.properties", "camel.version", MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")),
configure("activemq"));
}
@Ignore("java.lang.IllegalArgumentException: BundleContext must be specified - needs investigation")
@Test(timeout = 2 * 60 * 1000)
public void test() throws Throwable {
System.err.println(executeCommand("osgi:list").trim());
assertFeatureInstalled("activemq");
executeCommand("features:addurl " + getCamelFeatureUrl());
installAndAssertFeature("activemq-camel");
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
assertTrue("activemq-camel bundle installed", verifyBundleInstalled("org.apache.activemq.activemq-camel"));
return true;
}
});
// start broker with embedded camel route
String karafDir = System.getProperty("karaf.base");
File target = new File(karafDir + "/etc/activemq.xml");
copyFile(new File(basedir + "/../../../src/test/resources/org/apache/activemq/karaf/itest/activemq-nd-camel.xml"), target);
target = new File(karafDir + "/etc/org.apache.activemq.server-default.cfg");
copyFile(new File(basedir + "/../../../src/test/resources/org/apache/activemq/karaf/itest/org.apache.activemq.server-default.cfg"), target);
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
@ -61,10 +86,15 @@ public class ActiveMQBrokerNdCamelFeatureTest extends AbstractJmsFeatureTest {
}
});
System.err.println(executeCommand("activemq:bstat").trim());
withinReason(new Callable<Boolean>(){
@Override
public Boolean call() throws Exception {
assertTrue("we have camel consumers", executeCommand("activemq:dstat").trim().contains("camel_in"));
return true;
}
});
// produce and consume
final String nameAndPayload = String.valueOf(System.currentTimeMillis());
produceMessage("camel_in");
assertEquals("got our message", "camel_in", consumeMessage("camel_out"));
}

View File

@ -19,37 +19,38 @@ package org.apache.activemq.karaf.itest;
import java.io.File;
import java.util.concurrent.Callable;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.junit.PaxExam;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
@RunWith(JUnit4TestRunner.class)
@RunWith(PaxExam.class)
public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeatureTest {
@Configuration
public static Option[] configure() {
Option[] baseOptions = configure("activemq");
// copy camel.xml into a temporary directory in karaf, so we later can hot-deploy it
Option[] baseOptions = append(
replaceConfigurationFile("data/tmp/camel.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/camel.xml")),
configure("activemq", "activemq-camel"));
return configureBrokerStart(append(features(getCamelFeatureUrl(
MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")
), "activemq-camel"), baseOptions));
baseOptions = append(replaceConfigurationFile("data/tmp/camel.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/camel.xml")), baseOptions);
baseOptions = append(editConfigurationFilePut("etc/system.properties", "camel.version", MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")), baseOptions);
return configureBrokerStart(baseOptions);
}
@Ignore("camel.xml from auto deploy directory does not seem to get picked up, no idea why atm")
@Test(timeout = 2 * 60 * 1000)
public void test() throws Throwable {
System.err.println(executeCommand("features:list").trim());
System.err.println(executeCommand("osgi:list").trim());
assertFeatureInstalled("activemq");
executeCommand("features:addurl " + getCamelFeatureUrl());
installAndAssertFeature("activemq-camel");
withinReason(new Callable<Boolean>() {
@Override
@ -68,6 +69,16 @@ public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeature
}
});
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
assertTrue("activemq-camel bundle installed", verifyBundleInstalled("org.apache.activemq.activemq-camel"));
return true;
}
});
assertFeatureInstalled("activemq-camel");
System.err.println(executeCommand("activemq:bstat").trim());
// hot deploy the camel.xml file by copying it to the deploy directory
@ -75,11 +86,16 @@ public class ActiveMQBrokerNdExternalCamelFeatureTest extends AbstractJmsFeature
String karafDir = System.getProperty("karaf.base");
System.err.println("Hot deploying Camel application");
copyFile(new File(karafDir + "/data/tmp/camel.xml"), new File(karafDir + "/deploy/camel.xml"));
Thread.sleep(3 * 1000);
System.err.println("Continuing...");
withinReason(new Callable<Boolean>(){
@Override
public Boolean call() throws Exception {
assertTrue("we have camel consumers", executeCommand("activemq:dstat").trim().contains("camel_in"));
return true;
}
});
// produce and consume
final String nameAndPayload = String.valueOf(System.currentTimeMillis());
produceMessage("camel_in");
assertEquals("got our message", "camel_in", consumeMessage("camel_out"));
}

View File

@ -24,8 +24,8 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.junit.PaxExam;
import static org.junit.Assert.assertEquals;
@ -33,7 +33,7 @@ import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.replaceConfigurationFile;
@RunWith(JUnit4TestRunner.class)
@RunWith(PaxExam.class)
public class ActiveMQBrokerRuntimeConfigTest extends AbstractJmsFeatureTest {
@Configuration

View File

@ -16,46 +16,69 @@
*/
package org.apache.activemq.karaf.itest;
import javax.jms.Destination;
import java.util.concurrent.Callable;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.CoreOptions;
import org.ops4j.pax.exam.MavenUtils;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.options.MavenArtifactProvisionOption;
import static org.junit.Assert.assertTrue;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
@RunWith(JUnit4TestRunner.class)
@RunWith(PaxExam.class)
public class ObrFeatureTest extends AbstractFeatureTest {
@Configuration
public static Option[] configure() {
return append(
@Configuration
public static Option[] configure() {
Option[] options = append(
editConfigurationFilePut("etc/system.properties", "camel.version", MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")),
configure("obr"));
}
// can't see where these deps die in a pax-web container - vanilla distro unpack can install war feature ok
options = append(CoreOptions.mavenBundle("org.apache.xbean", "xbean-bundleutils").versionAsInProject(), options);
options = append(CoreOptions.mavenBundle("org.apache.xbean", "xbean-asm-util").versionAsInProject(), options);
return append(CoreOptions.mavenBundle("org.apache.xbean", "xbean-finder").versionAsInProject(), options);
}
@Test(timeout=5 * 60 * 1000)
public void testClient() throws Throwable {
installAndAssertFeature("activemq-client");
}
@Test(timeout=5 * 60 * 1000)
public void testActiveMQ() throws Throwable {
installAndAssertFeature("activemq");
}
@Test(timeout=5 * 60 * 1000)
public void testBroker() throws Throwable {
installAndAssertFeature("activemq-broker");
}
public void testWar() throws Throwable {
// note xbean deps manually installed above, should not be needed
installAndAssertFeature("war");
}
@Test(timeout=5 * 60 * 1000)
public void testCamel() throws Throwable {
System.err.println(executeCommand("features:addurl " + getCamelFeatureUrl()));
installAndAssertFeature("activemq-camel");
}
public void testClient() throws Throwable {
installAndAssertFeature("activemq-client");
}
@Test(timeout=5 * 60 * 1000)
public void testActiveMQ() throws Throwable {
installAndAssertFeature("activemq");
}
@Test(timeout=5 * 60 * 1000)
public void testBroker() throws Throwable {
// ensure pax-war feature deps are there for web-console
withinReason(new Callable<Boolean>() {
@Override
public Boolean call() throws Exception {
assertTrue("xbean finder bundle installed", verifyBundleInstalled("org.apache.xbean.finder"));
return true;
}
});
installAndAssertFeature("activemq-broker");
}
@Test(timeout=5 * 60 * 1000)
public void testCamel() throws Throwable {
executeCommand("features:addurl " + getCamelFeatureUrl());
installAndAssertFeature("activemq-camel");
}
}

View File

@ -88,7 +88,7 @@
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616?maximumConnections=1000"/>
<transportConnector name="http" uri="http://0.0.0.0:61626"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:61636"/>
<transportConnector name="amqp" uri="amqp://0.0.0.0:61636?transport.transformer=jms"/>
<transportConnector name="ws" uri="ws://0.0.0.0:61646"/>
<transportConnector name="mqtt" uri="ws://0.0.0.0:61656"/>
</transportConnectors>

View File

@ -1,124 +0,0 @@
################################################################################
#
# 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.
#
################################################################################
# FIXING PAX-EXAM BUG
#
# This file lists Karaf default settings for this particular version of Karaf.
# For easier maintenance when upgrading Karaf and to better document which
# default values have changed, it is recommended to place any changes to
# these values in a custom.properties file in the same folder as this file.
# Each value specified in custom.properties will override the default value
# here.
#
#
# Properties file inclusions (as a space separated list of relative paths)
# Included files will override the values specified in this file
# NB: ${includes} properties files are mandatory, it means that Karaf will not start
# if the include file is not found
#
${includes} = jre.properties custom.properties
#
# Properties file inclusions (as a space separated list of relative paths)
# Included files will override the values specified in this file
# NB: ${optionals} properties files are optionals, it means that Karaf will just
# display a warning message but the bootstrap will be performed
#
# ${optionals} = my.properties
#
# Framework selection properties
#
karaf.framework=felix
#
# Location of the OSGi frameworks
#
karaf.framework.felix=${karaf.default.repository}/org/apache/felix/org.apache.felix.framework/${felix-framework-version}/org.apache.felix.framework-${felix-framework-version}.jar
#
# Framework config properties.
#
org.osgi.framework.system.packages= \
org.osgi.framework.startlevel;uses:="org.osgi.framework";version="1.0", \
org.osgi.framework.wiring;uses:="org.osgi.resource,org.osgi.framework";version="1.1", \
org.osgi.framework.hooks.bundle;uses:="org.osgi.framework";version="1.1", \
org.osgi.framework.hooks.service;uses:="org.osgi.framework";version="1.1", \
org.osgi.framework.hooks.resolver;uses:="org.osgi.framework.wiring";version="1.0", \
org.osgi.framework.launch;uses:="org.osgi.framework";version="1.1", \
org.osgi.framework.namespace;uses:="org.osgi.resource";version="1.0", \
org.osgi.framework;version="1.7",\
org.osgi.framework.hooks.weaving;uses:="org.osgi.framework.wiring";version="1.0",\
org.osgi.resource;version="1.0",org.osgi.service.url;version="1.0",\
org.osgi.service.startlevel;uses:="org.osgi.framework";version="1.1",\
org.osgi.service.packageadmin;uses:="org.osgi.framework";version="1.2",\
org.osgi.service.url;version="1.0", \
org.osgi.util.tracker;uses:="org.osgi.framework";version="1.5.1", \
org.apache.karaf.jaas.boot;version="${karaf-version}", \
org.apache.karaf.jaas.boot.principal;version="${karaf-version}", \
org.apache.karaf.management.boot;version="${karaf-version}", \
org.apache.karaf.version;version="${karaf-version}", \
${jre-${java.specification.version}}
# Extra packages appended after standard packages
# org.osgi.framework.system.packages.extra=
# javax.transaction is needed to avoid class loader constraint violation when using javax.sql
org.osgi.framework.bootdelegation=org.apache.karaf.jaas.boot,sun.*,com.sun.*,javax.transaction,javax.transaction.*
# OSGi Execution Environment
org.osgi.framework.executionenvironment=J2SE-1.7,JavaSE-1.7,J2SE-1.6,JavaSE-1.6,J2SE-1.5,JavaSE-1.5,J2SE-1.4,JavaSE-1.4,J2SE-1.3,JavaSE-1.3,J2SE-1.2,,JavaSE-1.2,CDC-1.1/Foundation-1.1,CDC-1.0/Foundation-1.0,J2ME,OSGi/Minimum-1.1,OSGi/Minimum-1.0
# Set the parent classloader for the bundle to the classloader that loads the Framework (i.e. everything in lib/*.jar)
org.osgi.framework.bundle.parent=framework
# To enable the use of the startup.properties file to control the start level:
karaf.auto.start=startup.properties
org.osgi.framework.startlevel.beginning=100
karaf.startlevel.bundle=80
karaf.shutdown.port.file=${karaf.data}/port
#
# FileMonitor properties
#
felix.fileinstall.dir = ${karaf.base}/etc
felix.fileinstall.filter = .*\\.cfg
felix.fileinstall.poll = 1000
felix.fileinstall.noInitialDelay = true
felix.fileinstall.log.level = 3
#
# Delay for writing the framework state to disk in equinox
# must be >= 1000 and <= 1800000
#
eclipse.stateSaveDelayInterval = 1000
#
# OBR Repository list
# This property will be modified by the obr:addUrl and obr:removeUrl commands.
#
obr.repository.url =
karaf.delay.console=false

View File

@ -1,30 +0,0 @@
################################################################################
#
# 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.
#
################################################################################
#
# All the values specified here will override the default values given
# in config.properties.
#
karaf.systemBundlesStartLevel=50
#
# You can place any customized configuration here.
#

View File

@ -22,7 +22,7 @@
<!-- Bundles needed if only client will be deployed in the container -->
<feature name="activemq-client" description="ActiveMQ client libraries" version="${project.version}" resolver="(obr)" start-level="50">
<feature version="[3.1,4)">spring</feature>
<feature version="[3.2,4)">spring</feature>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-annotation_1.0_spec/1.1.1</bundle>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jta_1.1_spec/1.1.1</bundle>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_1.1_spec/1.1.1</bundle>

13
pom.xml
View File

@ -89,7 +89,7 @@
<junit-version>4.11</junit-version>
<hamcrest-version>1.3</hamcrest-version>
<jxta-version>2.0</jxta-version>
<karaf-version>2.3.3</karaf-version>
<karaf-version>2.4.1</karaf-version>
<leveldb-api-version>0.6</leveldb-api-version>
<leveldb-version>0.6</leveldb-version>
<leveldbjni-version>1.8</leveldbjni-version>
@ -126,18 +126,17 @@
<xmlresolver-bundle-version>1.2_5</xmlresolver-bundle-version>
<xpp3-version>1.1.4c</xpp3-version>
<xstream-version>1.4.7</xstream-version>
<xbean-version>3.16</xbean-version>
<xbean-version>3.18</xbean-version>
<xerces-version>2.11.0</xerces-version>
<jaxb-basics-version>0.6.4</jaxb-basics-version>
<stompjms-version>1.19</stompjms-version>
<pax-exam-version>3.4.0</pax-exam-version>
<pax-exam-version>4.3.0</pax-exam-version>
<paxexam-karaf-container-version>1.0.0</paxexam-karaf-container-version>
<pax-runner-version>1.6.1</pax-runner-version>
<pax-tiny-bundle-version>1.3.1</pax-tiny-bundle-version>
<pax-url-version>1.5.2</pax-url-version>
<felix-configadmin-version>1.4.0</felix-configadmin-version>
<felix-framework-version>4.0.3</felix-framework-version>
<pax-url-version>2.3.0</pax-url-version>
<felix-configadmin-version>1.8.0</felix-configadmin-version>
<felix-framework-version>4.4.1</felix-framework-version>
<site-repo-url>scpexe://people.apache.org/www/activemq.apache.org/maven/</site-repo-url>
<source-version>1.7</source-version>