[ARTEMIS-1630] Create Artemis Client features

This commit is contained in:
jpoth 2018-01-23 12:18:07 +01:00
parent 974bdd622e
commit cef1cc8f8d
13 changed files with 932 additions and 10 deletions

View File

@ -0,0 +1,113 @@
<!-- 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-pom</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>artemis-core-client-osgi</artifactId>
<packaging>bundle</packaging>
<name>ActiveMQ Artemis Client OSGi</name>
<description>
Combines the commons and core-client as they contain too many duplicate packages
to be deployed separately.
</description>
<properties>
<activemq.basedir>${project.basedir}/..</activemq.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.modules</groupId>
<artifactId>jboss-modules</artifactId>
<version>1.3.1.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
<Import-Package>
io.netty.buffer;io.netty.*;version="[4.1,5)",
org.apache.johnzon.core,
*
</Import-Package>
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -38,18 +38,13 @@
<bundle>mvn:io.netty/netty-transport-native-epoll/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-transport-native-kqueue/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-transport-native-unix-common/${netty.version}</bundle>
<bundle>mvn:io.netty/netty-codec-http/${netty.version}</bundle>
</feature>
<feature name="artemis-core" version="${pom.version}" description="ActiveMQ Artemis broker libraries">
<feature name="artemis-common" version="${pom.version}" description="ActiveMQ Artemis Common libraries">
<feature>transaction</feature>
<feature>netty-core</feature>
<feature>scr</feature>
<configfile finalname="etc/org.apache.activemq.artemis.cfg">mvn:org.apache.activemq/artemis-features/${pom.version}/cfg</configfile>
<configfile finalname="etc/artemis.xml">mvn:org.apache.activemq/artemis-features/${pom.version}/xml/artemis</configfile>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/${geronimo.jms.2.spec.version}</bundle>
<bundle dependency="true">mvn:com.google.guava/guava/${guava.version}</bundle>
<bundle dependency="true">mvn:io.netty/netty-codec-http/${netty.version}</bundle>
<bundle dependency="true">mvn:commons-beanutils/commons-beanutils/${commons.beanutils.version}</bundle>
<bundle dependency="true">mvn:commons-collections/commons-collections/${commons.collections.version}</bundle>
@ -58,11 +53,39 @@
<bundle dependency="true">mvn:org.apache.servicemix.specs/org.apache.servicemix.specs.json-api-1.1/${servicemix.json-1.1.spec.version}</bundle>
<bundle>mvn:org.apache.johnzon/johnzon-core/${johnzon.version}</bundle>
</feature>
<feature name="artemis-core" version="${pom.version}" description="ActiveMQ Artemis broker libraries">
<feature>artemis-common</feature>
<feature>scr</feature>
<configfile finalname="etc/org.apache.activemq.artemis.cfg">mvn:org.apache.activemq/artemis-features/${pom.version}/cfg</configfile>
<configfile finalname="etc/artemis.xml">mvn:org.apache.activemq/artemis-features/${pom.version}/xml/artemis</configfile>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/${geronimo.jms.2.spec.version}</bundle>
<bundle>mvn:org.apache.activemq/artemis-native/${pom.version}</bundle>
<bundle>mvn:org.apache.activemq/artemis-server-osgi/${pom.version}</bundle>
</feature>
<feature name="artemis-core-client" version="${pom.version}" description="ActiveMQ Artemis Core Client libraries">
<feature>artemis-common</feature>
<bundle>mvn:org.apache.activemq/artemis-core-client-osgi/${pom.version}</bundle>
</feature>
<feature name="artemis-jms-client" version="${pom.version}" description="ActiveMQ Artemis JMS Client libraries">
<feature>artemis-common</feature>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/${geronimo.jms.2.spec.version}</bundle>
<bundle>mvn:org.apache.activemq/artemis-jms-client-osgi/${pom.version}</bundle>
</feature>
<feature name="artemis-amqp-client" version="${pom.version}" description="ActiveMQ Artemis AMQP Client libraries">
<feature>transaction</feature>
<feature>netty-core</feature>
<bundle dependency="true">mvn:org.apache.geronimo.specs/geronimo-jms_2.0_spec/${geronimo.jms.2.spec.version}</bundle>
<bundle>mvn:org.apache.qpid/proton-j/${proton.version}</bundle>
<bundle>mvn:org.apache.qpid/qpid-jms-client/${qpid.jms.version}</bundle>
</feature>
<feature name="artemis-amqp" version="${pom.version}" description="ActiveMQ Artemis AMQP protocol libraries">
<feature>artemis-core</feature>
<bundle>mvn:org.apache.qpid/proton-j/${proton.version}</bundle>

View File

@ -0,0 +1,123 @@
<!-- 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. -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-pom</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>artemis-jms-client-osgi</artifactId>
<packaging>bundle</packaging>
<name>ActiveMQ Artemis JMS Client OSGi</name>
<description>
Combines the commons, jms-client and core-client as they contain too many duplicate packages
to be deployed separately.
</description>
<properties>
<activemq.basedir>${project.basedir}/..</activemq.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-commons</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-selector</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.jboss.modules</groupId>
<artifactId>jboss-modules</artifactId>
<version>1.3.1.Final</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-processor</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging-annotations</artifactId>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.jboss.logging</groupId>
<artifactId>jboss-logging</artifactId>
</dependency>
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.2</version>
<optional>true</optional>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>osgi.cmpn</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=org.apache.activemq</Embed-Dependency>
<Import-Package>
io.netty.buffer;io.netty.*;version="[4.1,5)",
org.apache.johnzon.core,
*
</Import-Package>
<_exportcontents>org.apache.activemq.artemis.*;-noimport:=true</_exportcontents>
</instructions>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -24,7 +24,7 @@
</parent>
<artifactId>artemis-server</artifactId>
<packaging>jar</packaging>
<packaging>bundle</packaging>
<name>ActiveMQ Artemis Server</name>
<properties>
@ -237,6 +237,11 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>3.3.0</version>
</plugin>
</plugins>
</build>

View File

@ -41,10 +41,12 @@
<module>artemis-selector</module>
<module>artemis-core-client</module>
<module>artemis-core-client-all</module>
<module>artemis-core-client-osgi</module>
<module>artemis-server</module>
<module>artemis-junit</module>
<module>artemis-jms-client</module>
<module>artemis-jms-client-all</module>
<module>artemis-jms-client-osgi</module>
<module>artemis-jms-server</module>
<module>artemis-native</module>
<module>artemis-journal</module>
@ -73,6 +75,8 @@
<!-- base url for site deployment. See distribution management for full url. Override this in settings.xml for staging -->
<staging.siteURL>scp://people.apache.org/x1/www/activemq.apache.org</staging.siteURL>
<karaf.version>4.0.6</karaf.version>
<pax.exam.version>4.9.1</pax.exam.version>
<commons.config.version>2.1</commons.config.version>
<commons.lang.version>3.0</commons.lang.version>
<activemq5-version>5.14.5</activemq5-version>

View File

@ -29,8 +29,6 @@
<properties>
<activemq.basedir>${project.basedir}/../..</activemq.basedir>
<karaf.version>4.0.6</karaf.version>
<pax.exam.version>4.9.1</pax.exam.version>
<paho.client.mqttv3.version>1.1.0</paho.client.mqttv3.version>
</properties>

View File

@ -0,0 +1,197 @@
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>artemis-tests-pom</artifactId>
<version>2.5.0-SNAPSHOT</version>
</parent>
<artifactId>karaf-client-integration-tests</artifactId>
<packaging>jar</packaging>
<name>ActiveMQ Artemis Client Integration Tests</name>
<description>
Integration tests for the artemis client features using Apache Karaf
</description>
<properties>
<activemq.basedir>${project.basedir}/../..</activemq.basedir>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-jms-client</artifactId>
<version>${qpid.jms.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>proton-j</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.logmanager</groupId>
<artifactId>jboss-logmanager</artifactId>
<scope>test</scope>
</dependency>
<!-- karaf test -->
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-karaf</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf</groupId>
<artifactId>apache-karaf</artifactId>
<version>${karaf.version}</version>
<scope>test</scope>
<type>tar.gz</type>
</dependency>
<dependency>
<groupId>org.apache.karaf.shell</groupId>
<artifactId>org.apache.karaf.shell.console</artifactId>
<version>${karaf.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-features</artifactId>
<version>${project.version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.karaf.features</groupId>
<artifactId>enterprise</artifactId>
<version>${karaf.version}</version>
<classifier>features</classifier>
<type>xml</type>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.servicemix.tooling</groupId>
<artifactId>depends-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<id>generate-depends-file</id>
<goals>
<goal>generate-depends-file</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-maven-plugin</artifactId>
<executions>
<execution>
<id>create</id>
<phase>pre-integration-test</phase>
<goals>
<goal>create</goal>
</goals>
<configuration>
<ignore>${skipIntegrationTests}</ignore>
</configuration>
</execution>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>cli</goal>
</goals>
<configuration>
<ignore>${skipIntegrationTests}</ignore>
<spawn>true</spawn>
<testURI>tcp://localhost:61616</testURI>
<args>
<param>run</param>
</args>
</configuration>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>cli</goal>
</goals>
<configuration>
<ignore>${skipIntegrationTests}</ignore>
<args>
<param>stop</param>
</args>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.20.1</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<skipITs>${skipIntegrationTests}</skipITs>
<argLine>${activemq-surefire-argline}</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -0,0 +1,84 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.artemis.tests.integration.karaf.client;
import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.io.IOException;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.ARTEMIS_AMQP_CLIENT;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.KARAF;
import static org.junit.Assert.assertEquals;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
/**
* Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class ArtemisAMQPClientFeatureIT {
@Configuration
public Option[] config() throws IOException {
return options(
KARAF.option(),
ARTEMIS_AMQP_CLIENT.option(),
when(false)
.useOptions(
debugConfiguration("5005", true))
);
}
@Test
public void testArtemisAMQPClient() throws Exception {
// setup connection
ConnectionFactory connectionFactory = new JmsConnectionFactory("amqp://localhost:5672");
try (Connection connection = connectionFactory.createConnection()) {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
// send message
Queue queue = session.createQueue("artemisAMPQClientFeatureITQueue");
MessageProducer sender = session.createProducer(queue);
String message = "Hello world ";
sender.send(session.createTextMessage(message));
// receive message and assert
connection.start();
MessageConsumer consumer = session.createConsumer(queue);
TextMessage m = (TextMessage) consumer.receive(5000);
assertEquals(message, m.getText());
}
}
}

View File

@ -0,0 +1,84 @@
/**
* 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.artemis.tests.integration.karaf.client;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientProducer;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import java.io.IOException;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.ARTEMIS_CORE_CLIENT;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.KARAF;
import static org.junit.Assert.assertEquals;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
/**
* Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class ArtemisCoreClientFeatureIT {
@Configuration
public Option[] config() throws IOException {
return options(
KARAF.option(),
ARTEMIS_CORE_CLIENT.option(),
when(false)
.useOptions(
debugConfiguration("5005", true))
);
}
@Test
public void testArtemisCoreClient() throws Exception {
try (ServerLocator locator = ActiveMQClient.createServerLocator("tcp://localhost:61616")) {
ClientSessionFactory factory = locator.createSessionFactory();
ClientSession session = factory.createSession();
String queueName = "artemisCoreClientFeatureITQueue";
ClientProducer producer = session.createProducer(queueName);
ClientMessage message = session.createMessage(true);
// send message
String textMessage = "Hello";
message.getBodyBuffer().writeString(textMessage);
session.createQueue(queueName, RoutingType.ANYCAST, queueName, true);
producer.send(message);
// assert
ClientConsumer consumer = session.createConsumer(queueName);
session.start();
ClientMessage msgReceived = consumer.receive();
assertEquals(textMessage, msgReceived.getBodyBuffer().readString());
}
}
}

View File

@ -0,0 +1,84 @@
/**
* 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.artemis.tests.integration.karaf.client;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.io.IOException;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.ARTEMIS_JMS_CLIENT;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.KARAF;
import static org.junit.Assert.assertEquals;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
/**
* Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class ArtemisJMSClientFeatureIT {
@Configuration
public Option[] config() throws IOException {
return options(
KARAF.option(),
ARTEMIS_JMS_CLIENT.option(),
when(false)
.useOptions(
debugConfiguration("5005", true))
);
}
@Test
public void testArtemisJMSClient() throws Exception {
// setup connection
ConnectionFactory cf = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
try (Connection connection = cf.createConnection()) {
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
connection.start();
Queue queue = ActiveMQJMSClient.createQueue("artemisJMSClientFeatureITQueue");
MessageProducer producer = session.createProducer(queue);
// send message
String textMessage = "This is a text message";
TextMessage message = session.createTextMessage(textMessage);
producer.send(message);
// receive message and assert
MessageConsumer messageConsumer = session.createConsumer(queue);
TextMessage messageReceived = (TextMessage) messageConsumer.receive(100);
assertEquals(textMessage, messageReceived.getText());
}
}
}

View File

@ -0,0 +1,108 @@
/**
* 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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.artemis.tests.integration.karaf.client;
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.jms.client.ActiveMQJMSConnectionFactory;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Configuration;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.PaxExam;
import org.ops4j.pax.exam.spi.reactors.ExamReactorStrategy;
import org.ops4j.pax.exam.spi.reactors.PerClass;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.MessageConsumer;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
import javax.jms.TextMessage;
import java.io.IOException;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.ARTEMIS_JMS_CLIENT;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.ARTEMIS_TRANSACTION_MANAGER;
import static org.apache.activemq.artemis.tests.integration.karaf.client.PaxExamOptions.KARAF;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.when;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.debugConfiguration;
/**
* Useful docs about this test: https://ops4j1.jira.com/wiki/display/paxexam/FAQ
*/
@RunWith(PaxExam.class)
@ExamReactorStrategy(PerClass.class)
public class ArtemisTransactionalJMSClientFeatureIT {
@Configuration
public Option[] config() throws IOException {
return options(
KARAF.option(),
ARTEMIS_JMS_CLIENT.option(),
ARTEMIS_TRANSACTION_MANAGER.option(),
when(false)
.useOptions(
debugConfiguration("5005", true))
);
}
@Test
public void testTransactionalArtemisJMSClient() throws Exception {
// setup connection
ConnectionFactory cf = new ActiveMQJMSConnectionFactory("tcp://localhost:61616");
try (Connection connection = cf.createConnection()) {
connection.start();
Queue queue = ActiveMQJMSClient.createQueue("ArtemisTransactionalJMSClientFeatureITQueue");
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer messageProducer = session.createProducer(queue);
MessageConsumer messageConsumer = session.createConsumer(queue);
// send messages
String textMessage1 = "This is a text message1";
TextMessage message1 = session.createTextMessage(textMessage1);
String textMessage2 = "This is a text message2";
TextMessage message2 = session.createTextMessage(textMessage2);
messageProducer.send(message1);
messageProducer.send(message2);
// assert null before commit
TextMessage receivedMessage = (TextMessage) messageConsumer.receive(10);
assertNull(receivedMessage);
// commit and rollback
session.commit();
receivedMessage = (TextMessage) messageConsumer.receive(10);
assertNotNull(receivedMessage);
session.rollback();
// assert messages
receivedMessage = (TextMessage) messageConsumer.receive(100);
assertEquals(textMessage1, receivedMessage.getText());
receivedMessage = (TextMessage) messageConsumer.receive(100);
assertEquals(textMessage2, receivedMessage.getText());
session.commit();
receivedMessage = (TextMessage) messageConsumer.receive(10);
assertNull(receivedMessage);
}
}
}

View File

@ -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
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* 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.artemis.tests.integration.karaf.client;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.karaf.options.LogLevelOption;
import org.ops4j.pax.exam.options.DefaultCompositeOption;
import java.io.File;
import static org.ops4j.pax.exam.CoreOptions.maven;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.configureConsole;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.karafDistributionConfiguration;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.keepRuntimeFolder;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.logLevel;
import static org.ops4j.pax.exam.karaf.options.KarafDistributionOption.features;
public enum PaxExamOptions {
KARAF(
karafDistributionConfiguration()
.frameworkUrl(
maven()
.groupId("org.apache.karaf")
.artifactId("apache-karaf")
.versionAsInProject()
.type("zip"))
.name("Apache Karaf")
.useDeployFolder(false)
.unpackDirectory(new File("target/paxexam/unpack/")),
keepRuntimeFolder(),
configureConsole().ignoreLocalConsole(),
logLevel(LogLevelOption.LogLevel.INFO)
),
ARTEMIS_CORE_CLIENT(
features(
maven()
.groupId("org.apache.activemq")
.artifactId("artemis-features")
.type("xml")
.classifier("features")
.versionAsInProject(),
"artemis-core-client")
),
ARTEMIS_JMS_CLIENT(
features(
maven()
.groupId("org.apache.activemq")
.artifactId("artemis-features")
.type("xml")
.classifier("features")
.versionAsInProject(),
"artemis-jms-client")
),
ARTEMIS_AMQP_CLIENT(
features(
maven()
.groupId("org.apache.activemq")
.artifactId("artemis-features")
.type("xml")
.classifier("features")
.versionAsInProject(),
"artemis-amqp-client")
),
ARTEMIS_TRANSACTION_MANAGER(
features(
maven()
.groupId("org.apache.karaf.features")
.artifactId("enterprise")
.type("xml")
.classifier("features")
.versionAsInProject(),
"transaction-manager-narayana")
);
private final Option[] options;
PaxExamOptions(Option... options) {
this.options = options;
}
public Option option() {
return new DefaultCompositeOption(options);
}
}

View File

@ -126,6 +126,7 @@
<module>timing-tests</module>
<module>jms-tests</module>
<module>integration-tests</module>
<module>karaf-client-integration-tests</module>
<module>compatibility-tests</module>
<module>soak-tests</module>
<module>stress-tests</module>