Skip to content
Permalink
Browse files
Upgraded to qpid 0.18 so that we can get rid of the incubator reposit…
…ory.
  • Loading branch information
veithen committed Nov 16, 2012
1 parent 9771097 commit b69265ee51ac0b5e5a7bd9641c8ba85e48c97ba8
Showing 9 changed files with 168 additions and 49 deletions.
@@ -126,13 +126,13 @@
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-broker</artifactId>
<version>1.0-incubating-M2.1</version>
<version>0.18</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.qpid</groupId>
<artifactId>qpid-client</artifactId>
<version>1.0-incubating-M2.1</version>
<version>0.18</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -168,21 +168,6 @@
</dependency>
</dependencies>

<repositories>
<!-- this is for qpid -->
<repository>
<id>apache-incubating</id>
<name>Apache Maven 2 Incubating Repository</name>
<url>http://people.apache.org/repo/m2-incubating-repository/</url>
<releases>
<updatePolicy>never</updatePolicy>
</releases>
<snapshots>
<updatePolicy>interval:60</updatePolicy>
</snapshots>
</repository>
</repositories>

<properties>
<jms-1.1-spec.version>1.1</jms-1.1-spec.version>
<jta-spec.version>1.0</jta-spec.version>
@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<broker>
<conf>src/test/conf/qpid</conf>
<security>
<pd-auth-manager>
<principal-database>
<class>org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase</class>
<attributes>
<attribute>
<name>passwordFile</name>
<value>${conf}/passwd</value>
</attribute>
</attributes>
</principal-database>
</pd-auth-manager>
<msg-auth>false</msg-auth>
</security>
<virtualhosts>${conf}/virtualhosts.xml</virtualhosts>
</broker>
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<log4j:configuration>
<!-- This file is intentionally empty; we configure log4j elsewhere before starting qpid. -->
</log4j:configuration>
@@ -0,0 +1,19 @@
#
# 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.
#
guest:guest
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->
<virtualhosts>
<default>test</default>
<virtualhost>
<name>test</name>
<test>
<store>
<class>org.apache.qpid.server.store.MemoryMessageStore</class>
</store>
<queues>
<minimumAlertRepeatGap>30000</minimumAlertRepeatGap>
<maximumMessageCount>50</maximumMessageCount>
<queue>
<name>queue</name>
<queue>
<exchange>amq.direct</exchange>
<maximumQueueDepth>4235264</maximumQueueDepth>
<!-- 4Mb -->
<maximumMessageSize>2117632</maximumMessageSize>
<!-- 2Mb -->
<maximumMessageAge>600000</maximumMessageAge>
<!-- 10 mins -->
</queue>
</queue>
<queue>
<name>ping</name>
<ping>
<exchange>amq.direct</exchange>
<maximumQueueDepth>4235264</maximumQueueDepth>
<!-- 4Mb -->
<maximumMessageSize>2117632</maximumMessageSize>
<!-- 2Mb -->
<maximumMessageAge>600000</maximumMessageAge>
<!-- 10 mins -->
</ping>
</queue>
</queues>
</test>
</virtualhost>
</virtualhosts>
@@ -46,19 +46,14 @@ private void setUp() throws Exception {
broker.setDataDirectory("target/activemq-data");
broker.setPersistenceAdapter(new MemoryPersistenceAdapter());
broker.start();
connectionFactory = new ActiveMQConnectionFactory("vm://" + BROKER_NAME);
}

@TearDown @SuppressWarnings("unused")
private void tearDown() throws Exception {
broker.stop();
}

@Override
protected ActiveMQConnectionFactory createConnectionFactory() throws Exception {
return new ActiveMQConnectionFactory("vm://" + BROKER_NAME);
}


@Override
public Queue createQueue(String name) {
return new ActiveMQQueue(name);
@@ -25,19 +25,11 @@
import javax.jms.Topic;

import org.apache.axis2.transport.testkit.name.Key;
import org.apache.axis2.transport.testkit.tests.Setup;
import org.apache.axis2.transport.testkit.tests.Transient;

@Key("broker")
public abstract class JMSTestEnvironment {
private @Transient ConnectionFactory connectionFactory;

@Setup @SuppressWarnings("unused")
private void setUp() throws Exception {
connectionFactory = createConnectionFactory();
}

protected abstract ConnectionFactory createConnectionFactory() throws Exception;
protected @Transient ConnectionFactory connectionFactory;

public Destination createDestination(String destinationType, String name) throws Exception {
if (destinationType.equals(JMSConstants.DESTINATION_TYPE_TOPIC)) {
@@ -26,36 +26,45 @@
import org.apache.axis2.transport.testkit.name.Name;
import org.apache.axis2.transport.testkit.tests.Setup;
import org.apache.axis2.transport.testkit.tests.TearDown;
import org.apache.axis2.transport.testkit.tests.Transient;
import org.apache.axis2.transport.testkit.util.PortAllocator;
import org.apache.qpid.AMQException;
import org.apache.qpid.client.AMQConnectionFactory;
import org.apache.qpid.client.AMQDestination;
import org.apache.qpid.client.AMQQueue;
import org.apache.qpid.client.AMQTopic;
import org.apache.qpid.client.transport.TransportConnection;
import org.apache.qpid.exchange.ExchangeDefaults;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.Broker;
import org.apache.qpid.server.BrokerOptions;
import org.apache.qpid.server.registry.ApplicationRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;

@Name("qpid")
public class QpidTestEnvironment extends JMSTestEnvironment {
private VirtualHost virtualHost;
private @Transient PortAllocator portAllocator;
private @Transient Broker broker;
private @Transient VirtualHost virtualHost;
private int port;

@Setup @SuppressWarnings("unused")
private void setUp() throws Exception {
TransportConnection.createVMBroker(1);
private void setUp(PortAllocator portAllocator) throws Exception {
this.portAllocator = portAllocator;
port = portAllocator.allocatePort();
broker = new Broker();
BrokerOptions options = new BrokerOptions();
options.setConfigFile("src/test/conf/qpid/config.xml");
options.setLogConfigFile("src/test/conf/qpid/log4j.xml");
options.addPort(port);
broker.startup(options);
// null means the default virtual host
virtualHost = ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHost(null);
virtualHost = ApplicationRegistry.getInstance().getVirtualHostRegistry().getVirtualHost(null);
connectionFactory = new AMQConnectionFactory("amqp://guest:guest@clientid/" + virtualHost.getName() + "?brokerlist='tcp://localhost:" + port + "'");
}

@TearDown @SuppressWarnings("unused")
private void tearDown() throws Exception {
TransportConnection.killVMBroker(1);
}

@Override
protected AMQConnectionFactory createConnectionFactory() throws Exception {
return new AMQConnectionFactory("vm://:1", "guest", "guest", "fred", "test");
broker.shutdown();
portAllocator.releasePort(port);
}

@Override
@@ -72,6 +81,6 @@ public Topic createTopic(String name) throws AMQException {

@Override
public void deleteDestination(Destination destination) throws Exception {
QpidUtil.deleteQueue(virtualHost, ((AMQDestination)destination).getDestinationName().asString());
QpidUtil.deleteQueue(virtualHost, ((AMQDestination)destination).getRoutingKey().asString());
}
}
@@ -21,22 +21,23 @@

import org.apache.qpid.AMQException;
import org.apache.qpid.framing.AMQShortString;
import org.apache.qpid.server.model.UUIDGenerator;
import org.apache.qpid.server.queue.AMQQueue;
import org.apache.qpid.server.queue.AMQQueueFactory;
import org.apache.qpid.server.queue.QueueRegistry;
import org.apache.qpid.server.virtualhost.VirtualHost;

public class QpidUtil {
private QpidUtil() {}

public static void createQueue(VirtualHost virtualHost, AMQShortString exchangeName, String name) throws AMQException {
AMQShortString _name = new AMQShortString(name);
QueueRegistry queueRegistry = virtualHost.getQueueRegistry();
if (queueRegistry.getQueue(_name) != null) {
if (queueRegistry.getQueue(name) != null) {
throw new IllegalStateException("Queue " + name + " already exists");
}
AMQQueue queue = new AMQQueue(_name, false, null, false, virtualHost);
AMQQueue queue = AMQQueueFactory.createAMQQueueImpl(UUIDGenerator.generateQueueUUID(name, virtualHost.getName()), name, false, null, false, false, virtualHost, null);
queueRegistry.registerQueue(queue);
queue.bind(_name, null, virtualHost.getExchangeRegistry().getExchange(exchangeName));
virtualHost.getBindingFactory().addBinding(name, queue, virtualHost.getExchangeRegistry().getExchange(exchangeName), null);
}

public static void deleteQueue(VirtualHost virtualHost, String name) throws AMQException {

0 comments on commit b69265e

Please sign in to comment.