mirror of https://github.com/apache/activemq.git
https://issues.apache.org/jira/browse/AMQ-4432 - itest with mods to support, spring.handlers is now aware of camel handler
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@1463909 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a3578eb91b
commit
b65fd27109
|
@ -167,8 +167,12 @@ public abstract class AbstractFeatureTest {
|
|||
|
||||
// for use from a probe
|
||||
public String getCamelFeatureUrl() {
|
||||
return getCamelFeatureUrl(System.getProperty("camel.version", "unknown"));
|
||||
}
|
||||
|
||||
public static String getCamelFeatureUrl(String ver) {
|
||||
return "mvn:org.apache.camel.karaf/apache-camel/"
|
||||
+ System.getProperty("camel.version", "unknown")
|
||||
+ ver
|
||||
+ "/xml/features";
|
||||
}
|
||||
|
||||
|
@ -180,15 +184,20 @@ public abstract class AbstractFeatureTest {
|
|||
artifactId("standard").version(karafVersion()).type(type);
|
||||
}
|
||||
|
||||
public static Option[] configureBrokerStart(Option[] existingOptions) {
|
||||
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")),
|
||||
existingOptions);
|
||||
return append(
|
||||
replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/activemq.xml")),
|
||||
replaceConfigurationFile("etc/activemq.xml", new File(basedir + "/src/test/resources/org/apache/activemq/karaf/itest/" + xmlConfig + ".xml")),
|
||||
existingOptions);
|
||||
}
|
||||
|
||||
public static Option[] configureBrokerStart(Option[] existingOptions) {
|
||||
final String xmlConfig = "activemq";
|
||||
return configureBrokerStart(existingOptions, xmlConfig);
|
||||
}
|
||||
|
||||
public static Option[] append(Option toAdd, Option[] existingOptions) {
|
||||
ArrayList<Option> newOptions = new ArrayList<Option>();
|
||||
newOptions.addAll(Arrays.asList(existingOptions));
|
||||
|
|
|
@ -62,6 +62,9 @@ public class ActiveMQBrokerFeatureTest extends AbstractFeatureTest {
|
|||
// produce and consume
|
||||
final String nameAndPayload = String.valueOf(System.currentTimeMillis());
|
||||
produceMessage(nameAndPayload);
|
||||
|
||||
System.err.println(executeCommand("activemq:bstat").trim());
|
||||
|
||||
assertEquals("got our message", nameAndPayload, consumeMessage(nameAndPayload));
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,99 @@
|
|||
/**
|
||||
* 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.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;
|
||||
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 static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.openengsb.labs.paxexam.karaf.options.KarafDistributionOption.editConfigurationFilePut;
|
||||
import static org.ops4j.pax.exam.CoreOptions.scanFeatures;
|
||||
|
||||
@RunWith(JUnit4TestRunner.class)
|
||||
public class ActiveMQBrokerNdCamelFeatureTest extends AbstractFeatureTest {
|
||||
|
||||
@Configuration
|
||||
public static Option[] configure() {
|
||||
Option[] baseOptions = configure("activemq");
|
||||
return configureBrokerStart(append(scanFeatures(getCamelFeatureUrl(
|
||||
MavenUtils.getArtifactVersion("org.apache.camel.karaf", "apache-camel")
|
||||
), "activemq-camel"), baseOptions), "activemq-nd-camel");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test() throws Throwable {
|
||||
System.err.println(executeCommand("features:list").trim());
|
||||
|
||||
withinReason(new Callable<Boolean>() {
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
assertEquals("brokerName = amq-broker", executeCommand("activemq:list").trim());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
withinReason(new Callable<Boolean>(){
|
||||
@Override
|
||||
public Boolean call() throws Exception {
|
||||
assertTrue(executeCommand("activemq:bstat").trim().contains("BrokerName = amq-broker"));
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
System.err.println(executeCommand("activemq:bstat").trim());
|
||||
|
||||
// produce and consume
|
||||
final String nameAndPayload = String.valueOf(System.currentTimeMillis());
|
||||
produceMessage("camel_in");
|
||||
assertEquals("got our message", "camel_in", consumeMessage("camel_out"));
|
||||
}
|
||||
|
||||
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);
|
||||
MessageConsumer consumer = session.createConsumer(session.createQueue(nameAndPayload));
|
||||
TextMessage message = (TextMessage) consumer.receive(10000);
|
||||
System.err.println("message: " + message);
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
|
@ -47,6 +47,7 @@ public class ActiveMQBrokerNdWebConsoleFeatureTest extends ActiveMQBrokerFeature
|
|||
protected void produceMessage(String nameAndPayload) throws Exception {
|
||||
HttpClient client = new HttpClient();
|
||||
|
||||
System.err.println(executeCommand("activemq:bstat").trim());
|
||||
System.err.println("attempting publish via web console..");
|
||||
|
||||
// set credentials
|
||||
|
@ -83,5 +84,7 @@ public class ActiveMQBrokerNdWebConsoleFeatureTest extends ActiveMQBrokerFeature
|
|||
|
||||
// execute the send
|
||||
assertEquals("post succeeded, " + post, 302, client.executeMethod(post));
|
||||
|
||||
System.err.println(executeCommand("activemq:bstat").trim());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<!--
|
||||
|
||||
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.
|
||||
|
||||
-->
|
||||
|
||||
<beans
|
||||
xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:amq="http://activemq.apache.org/schema/core"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
|
||||
http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
|
||||
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">
|
||||
|
||||
|
||||
<broker xmlns="http://activemq.apache.org/schema/core"
|
||||
brokerName="${broker-name}"
|
||||
dataDirectory="${data}"
|
||||
start="false">
|
||||
|
||||
<persistenceAdapter>
|
||||
<kahaDB directory="${data}/kahadb"/>
|
||||
</persistenceAdapter>
|
||||
|
||||
<plugins>
|
||||
<jaasAuthenticationPlugin configuration="karaf" />
|
||||
<authorizationPlugin>
|
||||
<map>
|
||||
<authorizationMap groupClass="org.apache.karaf.jaas.boot.principal.RolePrincipal">
|
||||
<authorizationEntries>
|
||||
<authorizationEntry queue=">" read="admin" write="admin" admin="admin"/>
|
||||
<authorizationEntry topic=">" read="admin" write="admin" admin="admin"/>
|
||||
<authorizationEntry topic="ActiveMQ.Advisory.>" read="admin" write="admin" admin="admin"/>
|
||||
</authorizationEntries>
|
||||
</authorizationMap>
|
||||
</map>
|
||||
</authorizationPlugin>
|
||||
</plugins>
|
||||
|
||||
<systemUsage>
|
||||
<systemUsage>
|
||||
<memoryUsage>
|
||||
<memoryUsage limit="64 mb"/>
|
||||
</memoryUsage>
|
||||
<storeUsage>
|
||||
<storeUsage limit="100 gb"/>
|
||||
</storeUsage>
|
||||
<tempUsage>
|
||||
<tempUsage limit="50 gb"/>
|
||||
</tempUsage>
|
||||
</systemUsage>
|
||||
</systemUsage>
|
||||
|
||||
<transportConnectors>
|
||||
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
|
||||
</transportConnectors>
|
||||
</broker>
|
||||
|
||||
<bean id="activemqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
|
||||
<property name="brokerURL" value="tcp://localhost:61616?jms.dispatchAsync=false"/>
|
||||
<property name="userName" value="karaf" />
|
||||
<property name="password" value="karaf" />
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="pooledConnectionFactory" class="org.apache.activemq.pool.XaPooledConnectionFactory">
|
||||
<property name="connectionFactory" ref="activemqConnectionFactory"/>
|
||||
</bean>
|
||||
|
||||
<!-- Define the activemq Camel component so we can integrate with the AMQ broker -->
|
||||
<bean id="activemq" class="org.apache.activemq.camel.component.ActiveMQComponent"
|
||||
depends-on="pooledConnectionFactory">
|
||||
<property name="connectionFactory" ref="pooledConnectionFactory"/>
|
||||
<property name="cacheLevel" value="0"/>
|
||||
</bean>
|
||||
|
||||
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
|
||||
<route id="queueToDbTransacted">
|
||||
<from uri="activemq:queue:camel_in"/>
|
||||
<to uri="activemq:queue:camel_out"/>
|
||||
</route>
|
||||
</camelContext>
|
||||
|
||||
|
||||
</beans>
|
|
@ -71,7 +71,7 @@
|
|||
<feature name="activemq-camel" version="${project.version}" resolver="(obr)" start-level="50">
|
||||
<feature version="${project.version}">activemq-client</feature>
|
||||
<feature version="${camel-version-range}">camel-jms</feature>
|
||||
<bundle>mvn:org.apache.activemq/activemq-camel/${project.version}</bundle>
|
||||
<feature version="${camel-version-range}">camel</feature>
|
||||
</feature>
|
||||
|
||||
<feature name="activemq-web-console" version="${project.version}" resolver="(obr)" start-level="50">
|
||||
|
|
|
@ -221,6 +221,9 @@
|
|||
<includes>
|
||||
<include>spring.*</include>
|
||||
</includes>
|
||||
<excludes>
|
||||
<exclude>spring.handlers</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
# manual creation to include camel handler so we can embed camel context in xbean xml config
|
||||
#
|
||||
http\://activemq.apache.org/schema/core=org.apache.xbean.spring.context.v2.XBeanNamespaceHandler
|
||||
http\://camel.apache.org/schema/spring=org.apache.camel.spring.handler.CamelNamespaceHandler
|
||||
http\://camel.apache.org/schema/spring/v2.10=org.apache.camel.spring.handler.CamelNamespaceHandler
|
||||
http\://camel.apache.org/schema/osgi=org.apache.camel.osgi.CamelNamespaceHandler
|
Loading…
Reference in New Issue