ARTEMIS-1545 Fixing compatibility issues with topic Subscriptions

This commit is contained in:
Clebert Suconic 2018-01-08 15:11:52 -05:00 committed by Justin Bertram
parent ba9d06ba70
commit c8dc7de445
21 changed files with 579 additions and 178 deletions

View File

@ -640,8 +640,11 @@ public class ActiveMQSessionContext extends SessionContext {
int maxConsumers,
boolean purgeOnNoConsumers,
boolean autoCreated) throws ActiveMQException {
CreateQueueMessage request = new CreateQueueMessage_V2(address, queueName, routingType, filterString, durable, temp, maxConsumers, purgeOnNoConsumers, autoCreated, true);
if (!sessionChannel.getConnection().isVersionBeforeAddressChange()) {
if (sessionChannel.getConnection().isVersionBeforeAddressChange()) {
CreateQueueMessage request = new CreateQueueMessage(address, queueName, filterString, durable, temp, true);
sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE);
} else {
CreateQueueMessage request = new CreateQueueMessage_V2(address, queueName, routingType, filterString, durable, temp, maxConsumers, purgeOnNoConsumers, autoCreated, true);
sessionChannel.sendBlocking(request, PacketImpl.NULL_RESPONSE);
}
}

View File

@ -311,6 +311,7 @@
<configuration>
<libListWithDeps>
<arg>org.apache.activemq:artemis-jms-server:${project.version}</arg>
<arg>org.apache.activemq:artemis-cli:${project.version}</arg>
<arg>org.apache.activemq:artemis-jms-client:${project.version}</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:${project.version}</arg>
<arg>org.apache.activemq:artemis-amqp-protocol:${project.version}</arg>
@ -333,6 +334,7 @@
<libListWithDeps>
<arg>org.apache.activemq:artemis-jms-server:2.4.0</arg>
<arg>org.apache.activemq:artemis-jms-client:2.4.0</arg>
<arg>org.apache.activemq:artemis-cli:2.4.0</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:2.4.0</arg>
<arg>org.apache.activemq:artemis-amqp-protocol:2.4.0</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:2.4.0</arg>
@ -354,6 +356,7 @@
<libListWithDeps>
<arg>org.apache.activemq:artemis-jms-server:1.4.0</arg>
<arg>org.apache.activemq:artemis-jms-client:1.4.0</arg>
<arg>org.apache.activemq:artemis-cli:1.4.0</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:1.4.0</arg>
<arg>org.apache.activemq:artemis-amqp-protocol:1.4.0</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:1.4.0</arg>
@ -375,6 +378,7 @@
<libListWithDeps>
<arg>org.apache.activemq:artemis-jms-server:1.5.5</arg>
<arg>org.apache.activemq:artemis-jms-client:1.5.5</arg>
<arg>org.apache.activemq:artemis-cli:1.5.5</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:1.5.5</arg>
<arg>org.apache.activemq:artemis-amqp-protocol:1.5.5</arg>
<arg>org.apache.activemq:artemis-hornetq-protocol:1.5.5</arg>

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.compatibility;
@ -36,7 +40,7 @@ public class GroovyRun {
public static GroovyShell shell = new GroovyShell(binding);
// Called with reflection
public static void doMain(String script, String... arg) throws Throwable {
public static void doTest(String script, String... arg) throws Throwable {
int i = 0;
for (String a : arg) {
System.out.println("[" + (i++) + "]=" + a);
@ -62,11 +66,15 @@ public class GroovyRun {
}
URI scriptURI = scriptURL.toURI();
binding.setVariable(argVariableName, arg);
setVariable(argVariableName, arg);
shell.evaluate(scriptURI);
}
public static void setVariable(String name, Object arg) {
binding.setVariable(name, arg);
}
// Called with reflection
public static void execute(String script) throws Throwable {
shell.evaluate(script);

View File

@ -1,15 +1,19 @@
package clients
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// Create a client connection factory

View File

@ -1,26 +1,24 @@
package clients
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// This script is called by sendMessages.groovy
import javax.jms.ConnectionFactory;
import java.util.HashMap;
import java.util.Map;
import org.hornetq.api.core.TransportConfiguration;
import org.hornetq.api.jms.HornetQJMSConstants;
import org.hornetq.core.message.impl.MessageImpl;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory;
import org.hornetq.core.remoting.impl.netty.TransportConstants;
import org.hornetq.jms.client.HornetQJMSConnectionFactory;

View File

@ -0,0 +1,39 @@
/*
* 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.
*/
import org.apache.activemq.artemis.cli.commands.ActionContext
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataExporter
System.out.println("Arg::" + arg[0]);
File pagingfile = new File(arg[0] + "/sender/data/paging")
pagingfile.mkdirs()
XmlDataExporter exporter = new XmlDataExporter();
exporter.binding = arg[0] + "/sender/data/bindings"
exporter.journal = arg[0] + "/sender/data/journal"
try {
exporter.largeMessages = arg[0] + "/sender/data/largeMessages"
} catch (Throwable e) {
exporter.largeMessges = arg[0] + "/sender/data/largeMessages"
}
exporter.paging = arg[0] + "/sender/data/paging"
PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(arg[0] + "/journal.export")));
exporter.execute(new ActionContext(System.in, out, System.err))
out.close();
//exporter.binding

View File

@ -0,0 +1,38 @@
/*
* 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.
*/
import org.apache.activemq.artemis.cli.commands.ActionContext
import org.apache.activemq.artemis.cli.commands.tools.XmlDataExporter
System.out.println("Arg::" + arg[0]);
File pagingfile = new File(arg[0] + "/sender/data/paging")
pagingfile.mkdirs()
XmlDataExporter exporter = new XmlDataExporter();
exporter.binding = arg[0] + "/sender/data/bindings"
exporter.journal = arg[0] + "/sender/data/journal"
try {
exporter.largeMessages = arg[0] + "/sender/data/largeMessages"
} catch (Throwable e) {
exporter.largeMessges = arg[0] + "/sender/data/largeMessages"
}
exporter.paging = arg[0] + "/sender/data/paging"
PrintStream out = new PrintStream(new BufferedOutputStream(new FileOutputStream(arg[0] + "/journal.export")));
exporter.execute(new ActionContext(System.in, out, System.err))
out.close();
//exporter.binding

View File

@ -0,0 +1,27 @@
/*
* 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.
*/
import org.apache.activemq.artemis.cli.commands.ActionContext
import org.apache.activemq.artemis.cli.commands.tools.xml.XmlDataImporter
System.out.println("Arg::" + arg[0]);
File pagingfile = new File(arg[0] + "/sender/data/paging")
pagingfile.mkdirs()
XmlDataImporter importer = new XmlDataImporter();
importer.input = arg[0] + "/journal.export"
importer.execute(new ActionContext(System.in, System.out, System.err))

View File

@ -0,0 +1,28 @@
/*
* 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.
*/
import org.apache.activemq.artemis.cli.commands.ActionContext
import org.apache.activemq.artemis.cli.commands.tools.XmlDataImporter
System.out.println("Arg::" + arg[0]);
File pagingfile = new File(arg[0] + "/sender/data/paging")
pagingfile.mkdirs()
XmlDataImporter importer = new XmlDataImporter();
importer.input = arg[0] + "/journal.export"
importer.execute(new ActionContext(System.in, System.out, System.err))

View File

@ -5,16 +5,20 @@ import org.apache.activemq.artemis.tests.compatibility.GroovyRun
import javax.jms.*
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// starts an artemis server
@ -24,6 +28,7 @@ String operation = arg[2];
String queueName = "queue";
String topicName = "topic";
int LARGE_MESSAGE_SIZE = 10 * 1024;
@ -57,9 +62,18 @@ if (clientType.startsWith("ARTEMIS")) {
Connection connection = cf.createConnection();
Session session = connection.createSession(true, Session.SESSION_TRANSACTED);
Queue queue = session.createQueue(queueName);
Topic topic = session.createTopic(topicName);
if (operation.equals("sendAckMessages")) {
MessageProducer producer = session.createProducer(queue);
Destination destination = queue;
if (operation.equals("sendTopic") || operation.equals("receiveNonDurableSubscription")) {
destination = topic;
}
if (operation.equals("sendAckMessages") || operation.equals("sendTopic")) {
println("sending...")
MessageProducer producer = session.createProducer(destination);
producer.setDeliveryMode(DeliveryMode.PERSISTENT);
System.out.println("Sending messages");
@ -67,29 +81,36 @@ if (operation.equals("sendAckMessages")) {
TextMessage message = session.createTextMessage(textBody);
message.setStringProperty(HDR_DUPLICATE_DETECTION_ID, "some-duplicate");
message.setStringProperty("prop", "test");
message.setIntProperty("order", 0)
producer.send(message);
BytesMessage bytesMessage = session.createBytesMessage();
bytesMessage.writeBytes(BYTES_BODY);
bytesMessage.setIntProperty("order", 1)
producer.send(bytesMessage);
for (int i = 0; i < 10; i++) {
BytesMessage m = session.createBytesMessage();
m.setIntProperty("count", i);
m.setIntProperty("order", 2 + i)
m.setObjectProperty(propertyLargeMessage, createFakeLargeStream(LARGE_MESSAGE_SIZE));
producer.send(m);
}
producer.send(session.createObjectMessage("rapadura"));
ObjectMessage objMessage = session.createObjectMessage("rapadura");
objMessage.setIntProperty("count", 13)
producer.send(objMessage);
MapMessage mapMessage = session.createMapMessage();
mapMessage.setString("prop", "rapadura")
mapMessage.setIntProperty("order", 14)
producer.send(mapMessage);
StreamMessage streamMessage = session.createStreamMessage();
streamMessage.setIntProperty("order", 15);
streamMessage.writeString("rapadura");
streamMessage.writeString("doce");
streamMessage.writeInt(33);
@ -97,16 +118,25 @@ if (operation.equals("sendAckMessages")) {
Message plain = session.createMessage();
plain.setStringProperty("plain", "doce");
plain.setIntProperty("order", 15)
producer.send(plain);
session.commit();
connection.close();
System.out.println("Message sent");
} else if (operation.equals("receiveMessages")) {
MessageConsumer consumer = session.createConsumer(queue);
}
if (operation.equals("receiveMessages") || operation.equals("receiveNonDurableSubscription")) {
MessageConsumer consumer;
consumer = session.createConsumer(destination);
connection.start();
if (latch != null) {
latch.countDown();
}
System.out.println("Receiving messages");
TextMessage message = (TextMessage) consumer.receive(5000);
@ -165,8 +195,6 @@ if (operation.equals("sendAckMessages")) {
session.commit();
connection.close();
System.out.println("Message received");
} else {
throw new RuntimeException("Invalid operation " + operation);
}

View File

@ -7,16 +7,20 @@ import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// starts an artemis server

View File

@ -1,15 +1,19 @@
package clients
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// Create a client connection factory

View File

@ -1,15 +1,19 @@
package servers
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// starts an artemis server
@ -36,7 +40,7 @@ System.out.println("folder:: " + folder);
configuration.setBrokerInstance(new File(folder + "/" + id));
configuration.addAcceptorConfiguration("artemis", "tcp://0.0.0.0:61616");
configuration.setSecurityEnabled(false);
configuration.setPersistenceEnabled(false);
configuration.setPersistenceEnabled(persistent);
try {
if (!type.startsWith("ARTEMIS-1")) {
configuration.addAddressesSetting("#", new AddressSettings().setAutoCreateAddresses(true));
@ -53,8 +57,5 @@ server.setConfiguration(configuration);
server.setJmsConfiguration(jmsConfiguration);
server.start();
// uncomment this next statements to validate https://issues.apache.org/jira/browse/ARTEMIS-1561
if (producer.toString().startsWith("ARTEMIS-1") && type.equals("ARTEMIS-SNAPSHOT") ||
producer.toString().startsWith("HORNETQ")) {
server.getJMSServerManager().createQueue(true, "queue", null, true);
}
server.getJMSServerManager().createTopic(true, "topic");
server.getJMSServerManager().createQueue(true, "queue", null, true);

View File

@ -1,15 +1,19 @@
package servers
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
// starts a hornetq server
@ -19,7 +23,7 @@ import org.hornetq.core.config.impl.ConfigurationImpl
import org.hornetq.core.remoting.impl.netty.NettyAcceptorFactory
import org.hornetq.core.remoting.impl.netty.TransportConstants
import org.hornetq.jms.server.config.impl.JMSConfigurationImpl
import org.hornetq.jms.server.config.impl.JMSQueueConfigurationImpl
import org.hornetq.jms.server.config.impl.*
import org.hornetq.jms.server.embedded.EmbeddedJMS
String folder = arg[0];
@ -46,7 +50,11 @@ configuration.getAcceptorConfigurations().add(tpc);
jmsConfiguration = new JMSConfigurationImpl();
JMSQueueConfigurationImpl queueConfiguration = new JMSQueueConfigurationImpl("queue", null, true);
TopicConfigurationImpl topicConfiguration = new TopicConfigurationImpl("topic");
jmsConfiguration.getQueueConfigurations().add(queueConfiguration);
jmsConfiguration.getTopicConfigurations().add(topicConfiguration);
server = new EmbeddedJMS();
server.setConfiguration(configuration);
server.setJmsConfiguration(jmsConfiguration);

View File

@ -0,0 +1,121 @@
/*
* 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.compatibility;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.apache.activemq.artemis.utils.FileUtil;
import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE;
import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT;
import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.TWO_FOUR;
/**
* To run this test on the IDE and debug it, run the compatibility-tests through a command line once:
*
* cd /compatibility-tests
* mvn install -Ptests | tee output.log
*
* on the output.log you will see the output generated by {@link #getClasspathProperty(String)}
*
* On your IDE, edit the Run Configuration to your test and add those -D as parameters to your test.
* On Idea you would do the following:
*
* Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
*/
@RunWith(Parameterized.class)
public class ExportImportTest extends VersionedBaseTest {
// this will ensure that all tests in this class are run twice,
// once with "true" passed to the class' constructor and once with "false"
@Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}")
public static Collection getParameters() {
// we don't need every single version ever released..
// if we keep testing current one against 2.4 and 1.4.. we are sure the wire and API won't change over time
List<Object[]> combinations = new ArrayList<>();
/*
// during development sometimes is useful to comment out the combinations
// and add the ones you are interested.. example:
*/
// combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE});
// combinations.add(new Object[]{ONE_FIVE, ONE_FIVE, ONE_FIVE});
combinations.addAll(combinatory(new Object[]{null}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT}));
return combinations;
}
public ExportImportTest(String server, String sender, String receiver) throws Exception {
super(server, sender, receiver);
}
@Before
public void removeFolder() throws Throwable {
FileUtil.deleteDirectory(serverFolder.getRoot());
serverFolder.getRoot().mkdirs();
}
@After
public void tearDown() {
try {
stopServer(serverClassloader);
} catch (Throwable ignored) {
}
try {
stopServer(receiverClassloader);
} catch (Throwable ignored) {
}
}
@Test
@Ignore // There's some work to be done on exporter / importer, but I wanted to send it in already
public void testSendReceive() throws Throwable {
setVariable(senderClassloader, "persistent", Boolean.TRUE);
startServer(serverFolder.getRoot(), senderClassloader, "sender");
callScript(senderClassloader, "meshTest/sendMessages.groovy", server, sender, "sendAckMessages");
stopServer(senderClassloader);
if (sender.startsWith("ARTEMIS-1")) {
callScript(senderClassloader, "exportimport/export1X.groovy", serverFolder.getRoot().getAbsolutePath());
} else {
callScript(senderClassloader, "exportimport/export.groovy", serverFolder.getRoot().getAbsolutePath());
}
setVariable(receiverClassloader, "persistent", Boolean.TRUE);
startServer(serverFolder.getRoot(), receiverClassloader, "receiver");
if (receiver.startsWith("ARTEMIS-1")) {
callScript(receiverClassloader, "exportimport/import1X.groovy", serverFolder.getRoot().getAbsolutePath());
} else {
callScript(receiverClassloader, "exportimport/import.groovy", serverFolder.getRoot().getAbsolutePath());
}
setVariable(receiverClassloader, "latch", null);
callScript(receiverClassloader, "meshTest/sendMessages.groovy", server, receiver, "receiveMessages");
}
}

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.compatibility;
@ -16,7 +20,11 @@ package org.apache.activemq.artemis.tests.compatibility;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@ -42,7 +50,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.TWO_FOUR
* Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
*/
@RunWith(Parameterized.class)
public class MeshTest extends VersionedBaseTest {
public class MeshTest extends ServerBaseTest {
// this will ensure that all tests in this class are run twice,
// once with "true" passed to the class' constructor and once with "false"
@ -73,8 +81,36 @@ public class MeshTest extends VersionedBaseTest {
@Test
public void testSendReceive() throws Throwable {
callMain(senderClassloader, GroovyRun.class.getName(), "meshTest/sendMessages.groovy", server, sender, "sendAckMessages");
callMain(receiverClassloader, GroovyRun.class.getName(), "meshTest/sendMessages.groovy", server, receiver, "receiveMessages");
setVariable(receiverClassloader, "latch", null);
callScript(senderClassloader, "meshTest/sendMessages.groovy", server, sender, "sendAckMessages");
callScript(receiverClassloader, "meshTest/sendMessages.groovy", server, receiver, "receiveMessages");
}
@Test
public void testSendReceiveTopicNonDurable() throws Throwable {
CountDownLatch latch = new CountDownLatch(1);
setVariable(receiverClassloader, "latch", latch);
AtomicInteger errors = new AtomicInteger(0);
Thread t = new Thread() {
@Override
public void run() {
try {
callScript(receiverClassloader, "meshTest/sendMessages.groovy", server, receiver, "receiveNonDurableSubscription");
} catch (Exception e) {
e.printStackTrace();
errors.incrementAndGet();
}
}
};
t.start();
Assert.assertTrue(latch.await(10, TimeUnit.SECONDS));
callScript(senderClassloader,"meshTest/sendMessages.groovy", server, sender, "sendTopic");
t.join();
Assert.assertEquals(0, errors.get());
}
}

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.compatibility;
@ -40,7 +44,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE
* Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
*/
@RunWith(Parameterized.class)
public class SendAckTest extends VersionedBaseTest {
public class SendAckTest extends ServerBaseTest {
// this will ensure that all tests in this class are run twice,
// once with "true" passed to the class' constructor and once with "false"
@ -72,8 +76,8 @@ public class SendAckTest extends VersionedBaseTest {
@Test
public void testSendReceive() throws Throwable {
callMain(senderClassloader, GroovyRun.class.getName(), "sendAckTest/sendAckMessages.groovy", server, sender, "sendAckMessages");
callMain(receiverClassloader, GroovyRun.class.getName(), "sendAckTest/sendAckMessages.groovy", server, receiver, "receiveMessages");
callScript(senderClassloader, "sendAckTest/sendAckMessages.groovy", server, sender, "sendAckMessages");
callScript(receiverClassloader, "sendAckTest/sendAckMessages.groovy", server, receiver, "receiveMessages");
}
}

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.compatibility;
@ -39,7 +43,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT
* Run->Edit Configuration->Add ArtemisMeshTest and add your properties.
*/
@RunWith(Parameterized.class)
public class SerializationTest extends VersionedBaseTest {
public class SerializationTest extends ServerBaseTest {
// this will ensure that all tests in this class are run twice,
// once with "true" passed to the class' constructor and once with "false"
@ -68,8 +72,8 @@ public class SerializationTest extends VersionedBaseTest {
public void testSerializeFactory() throws Throwable {
File file = serverFolder.newFile("objects.ser");
file.mkdirs();
callMain(senderClassloader, GroovyRun.class.getName(), "serial/serial.groovy", file.getAbsolutePath(), "write");
callMain(receiverClassloader, GroovyRun.class.getName(), "serial/serial.groovy", file.getAbsolutePath(), "read");
callScript(senderClassloader, "serial/serial.groovy", file.getAbsolutePath(), "write");
callScript(receiverClassloader, "serial/serial.groovy", file.getAbsolutePath(), "read");
}
}

View File

@ -0,0 +1,41 @@
/*
* 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.compatibility;
import org.apache.activemq.artemis.utils.FileUtil;
import org.junit.After;
import org.junit.Before;
public class ServerBaseTest extends VersionedBaseTest {
public ServerBaseTest(String server, String sender, String receiver) throws Exception {
super(server, sender, receiver);
}
@Before
public void setUp() throws Throwable {
FileUtil.deleteDirectory(serverFolder.getRoot());
setVariable(serverClassloader, "persistent", Boolean.FALSE);
startServer(serverFolder.getRoot(), serverClassloader, "live");
}
@After
public void tearDown() throws Throwable {
stopServer(serverClassloader);
}
}

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.compatibility;
@ -24,12 +28,9 @@ import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.apache.activemq.artemis.utils.FileUtil;
import org.apache.activemq.artemis.utils.RunnableEx;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assume;
import org.junit.Before;
import org.junit.ClassRule;
import org.junit.rules.TemporaryFolder;
@ -48,6 +49,9 @@ public abstract class VersionedBaseTest {
protected static Map<String, ClassLoader> loaderMap = new HashMap<>();
public VersionedBaseTest(String server, String sender, String receiver) throws Exception {
if (server == null) {
server = sender;
}
this.server = server;
this.sender = sender;
this.receiver = receiver;
@ -72,53 +76,30 @@ public abstract class VersionedBaseTest {
serverFolder = new TemporaryFolder(parent);
}
@Before
public void startServer() throws Throwable {
FileUtil.deleteDirectory(serverFolder.getRoot());
serverFolder.getRoot().mkdirs();
System.out.println("Folder::" + serverFolder.getRoot());
String scriptToUse;
if (server.startsWith("ARTEMIS")) {
scriptToUse = "servers/artemisServer.groovy";
} else {
scriptToUse = "servers/hornetqServer.groovy";
}
callMain(serverClassloader, GroovyRun.class.getName(), scriptToUse, serverFolder.getRoot().getAbsolutePath(), "1", server, sender, receiver);
}
@After
public void stopServer() throws Throwable {
callExecute(serverClassloader, GroovyRun.class.getName(), "server.stop()");
// GC help!!!
serverClassloader = null;
senderClassloader = null;
receiverClassloader = null;
}
@AfterClass
public static void cleanup() {
loaderMap.clear();
}
protected static void callMain(ClassLoader loader,
String className,
String script,
String... arguments) throws Exception {
protected static void callScript(ClassLoader loader, String script, String... arguments) throws Exception {
tclCall(loader, () -> {
Class clazz = loader.loadClass(className);
Method method = clazz.getMethod("doMain", String.class, String[].class);
Class clazz = loader.loadClass(GroovyRun.class.getName());
Method method = clazz.getMethod("doTest", String.class, String[].class);
method.invoke(null, script, arguments);
});
}
protected static void callExecute(ClassLoader loader, String className, String script) throws Exception {
protected static void setVariable(ClassLoader loader, String name, Object object) throws Exception {
tclCall(loader, () -> {
Class clazz = loader.loadClass(className);
Class clazz = loader.loadClass(GroovyRun.class.getName());
Method method = clazz.getMethod("setVariable", String.class, Object.class);
method.invoke(null, name, object);
});
}
protected static void callExecute(ClassLoader loader, String script) throws Exception {
tclCall(loader, () -> {
Class clazz = loader.loadClass(GroovyRun.class.getName());
Method method = clazz.getMethod("execute", String.class);
method.invoke(null, script);
});
@ -135,7 +116,6 @@ public abstract class VersionedBaseTest {
}
}
protected static ClassLoader defineClassLoader(String classPath) throws MalformedURLException {
String[] classPathArray = classPath.split(File.pathSeparator);
URL[] elements = new URL[classPathArray.length];
@ -176,7 +156,6 @@ public abstract class VersionedBaseTest {
Assume.assumeTrue("Cannot run these tests, no classpath found", ok);
}
loader = defineClassLoader(value);
loaderMap.put(name, loader);
@ -197,4 +176,22 @@ public abstract class VersionedBaseTest {
return combinations;
}
public void startServer(File folder, ClassLoader loader, String serverName) throws Throwable {
folder.mkdirs();
System.out.println("Folder::" + folder);
String scriptToUse;
if (server.startsWith("ARTEMIS")) {
scriptToUse = "servers/artemisServer.groovy";
} else {
scriptToUse = "servers/hornetqServer.groovy";
}
callScript(loader, scriptToUse, folder.getAbsolutePath(), serverName, server, sender, receiver);
}
public void stopServer(ClassLoader loader) throws Throwable {
callExecute(loader, "server.stop()");
}
}

View File

@ -1,14 +1,18 @@
/*
* Copyright 2005-2014 Red Hat, Inc.
* Red Hat 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
* 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.
* 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.
*/
/**