ARTEMIS-780 Fixes a number of broken tests

This commit is contained in:
Martyn Taylor 2016-12-09 18:00:06 +00:00
parent a20b23bf37
commit 1339c930de
14 changed files with 51 additions and 22 deletions

View File

@ -207,13 +207,13 @@ public class AMQPSessionCallback implements SessionCallback {
public QueueQueryResult queueQuery(String queueName, boolean autoCreate) throws Exception {
QueueQueryResult queueQueryResult = serverSession.executeQueueQuery(SimpleString.toSimpleString(queueName));
if (!queueQueryResult.isExists() && queueQueryResult.isAutoCreateJmsQueues() && autoCreate) {
if (!queueQueryResult.isExists() && queueQueryResult.isAutoCreateQueues() && autoCreate) {
try {
serverSession.createQueue(new SimpleString(queueName), new SimpleString(queueName), null, false, true);
} catch (ActiveMQQueueExistsException e) {
// The queue may have been created by another thread in the mean time. Catch and do nothing.
}
queueQueryResult = new QueueQueryResult(queueQueryResult.getName(), queueQueryResult.getAddress(), queueQueryResult.isDurable(), queueQueryResult.isTemporary(), queueQueryResult.getFilterString(), queueQueryResult.getConsumerCount(), queueQueryResult.getMessageCount(), queueQueryResult.isAutoCreateJmsQueues(), true);
queueQueryResult = new QueueQueryResult(queueQueryResult.getName(), queueQueryResult.getAddress(), queueQueryResult.isDurable(), queueQueryResult.isTemporary(), queueQueryResult.getFilterString(), queueQueryResult.getConsumerCount(), queueQueryResult.getMessageCount(), queueQueryResult.isAutoCreateQueues(), true, queueQueryResult.isAutoCreated(), queueQueryResult.isDeleteOnNoConsumers(), queueQueryResult.getRoutingType(), queueQueryResult.getMaxConsumers());
}
return queueQueryResult;
}

View File

@ -51,9 +51,13 @@ public class AddressCommandTest extends JMSTestBase {
String address = "address";
CreateAddress command = new CreateAddress();
command.setName(address);
command.setRoutingTypes(RoutingType.ANYCAST.toString() + "," + RoutingType.MULTICAST.toString());
command.execute(new ActionContext(System.in, new PrintStream(output), new PrintStream(error)));
checkExecutionPassed(command);
assertNotNull(server.getAddressInfo(new SimpleString(address)));
AddressInfo addressInfo = server.getAddressInfo(new SimpleString(address));
assertNotNull(addressInfo);
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.ANYCAST));
assertTrue(addressInfo.getRoutingTypes().contains(RoutingType.MULTICAST));
}
@Test

View File

@ -234,7 +234,7 @@ public class SessionTest extends ActiveMQTestBase {
ClientSession clientSession = cf.createSession(false, true, true);
QueueQuery resp = clientSession.queueQuery(new SimpleString(queueName));
Assert.assertFalse(resp.isExists());
Assert.assertFalse(resp.isAutoCreateJmsQueues());
Assert.assertFalse(resp.isAutoCreateQueues());
Assert.assertEquals(null, resp.getAddress());
clientSession.close();
}

View File

@ -57,7 +57,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueName, null, false);
createQueue(i, address, queueName, null, false, RoutingType.ANYCAST);
addConsumer(i, i, queueName, null);
}
@ -118,7 +118,7 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
for (int i = 0; i < 3; i++) {
createAddressInfo(i, address, RoutingType.ANYCAST, -1, false);
setupSessionFactory(i, isNetty());
createQueue(i, address, queueNamePrefix + i, null, false);
createQueue(i, address, queueNamePrefix + i, null, false, RoutingType.ANYCAST);
addConsumer(i, i, queueNamePrefix + i, null);
}
@ -184,9 +184,9 @@ public class AnycastRoutingWithClusterTest extends ClusterTestBase {
String filter1 = "giraffe";
String filter2 = "platypus";
createQueue(0, address, queueNamePrefix + 0, filter1, false);
createQueue(1, address, queueNamePrefix + 1, filter1, false);
createQueue(2, address, queueNamePrefix + 2, filter2, false);
createQueue(0, address, queueNamePrefix + 0, filter1, false, RoutingType.ANYCAST);
createQueue(1, address, queueNamePrefix + 1, filter1, false, RoutingType.ANYCAST);
createQueue(2, address, queueNamePrefix + 2, filter2, false, RoutingType.ANYCAST);
for (int i = 0; i < 3; i++) {
addConsumer(i, i, queueNamePrefix + i, null);

View File

@ -492,6 +492,15 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
createQueue(node, address, queueName, filterVal, durable, null, null);
}
protected void createQueue(final int node,
final String address,
final String queueName,
final String filterVal,
final boolean durable,
RoutingType routingType) throws Exception {
createQueue(node, address, queueName, filterVal, durable, null, null, routingType);
}
protected void createQueue(final int node,
final String address,
final String queueName,
@ -499,6 +508,17 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
final boolean durable,
final String user,
final String password) throws Exception {
createQueue(node, address, queueName, filterVal, durable, user, password, RoutingType.MULTICAST);
}
protected void createQueue(final int node,
final String address,
final String queueName,
final String filterVal,
final boolean durable,
final String user,
final String password,
RoutingType routingType) throws Exception {
ClientSessionFactory sf = sfs[node];
if (sf == null) {
@ -515,7 +535,7 @@ public abstract class ClusterTestBase extends ActiveMQTestBase {
log.info("Creating " + queueName + " , address " + address + " on " + servers[node]);
session.createQueue(address, queueName, filterString, durable);
session.createQueue(address, routingType, queueName, filterString, durable);
session.close();
}

View File

@ -49,6 +49,7 @@ import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionCre
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionReceiveMessage;
import org.apache.activemq.artemis.core.protocol.core.impl.wireformat.SessionSendMessage;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.ServerMessage;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@ -1052,7 +1053,7 @@ public class InterceptorTest extends ActiveMQTestBase {
public void testInterceptorOnURI() throws Exception {
locator.close();
server.createQueue(QUEUE, QUEUE, null, true, false);
server.createQueue(QUEUE, RoutingType.ANYCAST, QUEUE, null, true, false);
String uri = "tcp://localhost:61616?incomingInterceptorList=" + Incoming.class.getCanonicalName() + "&outgoingInterceptorList=" + Outgoing.class.getName();

View File

@ -45,6 +45,7 @@ import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.ha.SharedStoreMasterPolicyConfiguration;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.tests.integration.IntegrationTestLogger;
import org.apache.activemq.artemis.tests.integration.jms.serializables.TestClass1;
@ -243,7 +244,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase {
private void testDeserializationOptions(boolean useJndi, boolean useBrowser) throws Exception {
String qname = "SerialTestQueue";
SimpleString qaddr = new SimpleString(qname);
liveService.createQueue(qaddr, qaddr, null, true, false);
liveService.createQueue(qaddr, RoutingType.ANYCAST, qaddr, null, true, false);
//default ok
String blackList = null;
@ -316,7 +317,7 @@ public class ActiveMQConnectionFactoryTest extends ActiveMQTestBase {
String qname = "SerialTestQueue";
SimpleString qaddr = new SimpleString(qname);
liveService.createQueue(qaddr, qaddr, null, true, false);
liveService.createQueue(qaddr, RoutingType.ANYCAST, qaddr, null, true, false);
try {
String blackList = null;

View File

@ -43,6 +43,7 @@ import org.apache.activemq.artemis.core.registry.JndiBindingRegistry;
import org.apache.activemq.artemis.core.remoting.impl.invm.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.NodeManager;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.core.server.impl.InVMNodeManager;
import org.apache.activemq.artemis.jms.client.ActiveMQConnection;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
@ -133,7 +134,7 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase {
SimpleString jmsQueueName = new SimpleString("myqueue");
coreSession.createQueue(jmsQueueName, jmsQueueName, null, true);
coreSession.createQueue(jmsQueueName, RoutingType.ANYCAST, jmsQueueName, null, true);
Queue queue = sess.createQueue("myqueue");
@ -206,7 +207,7 @@ public class JMSFailoverListenerTest extends ActiveMQTestBase {
SimpleString jmsQueueName = new SimpleString("myqueue");
coreSessionLive.createQueue(jmsQueueName, jmsQueueName, null, true);
coreSessionLive.createQueue(jmsQueueName, RoutingType.ANYCAST, jmsQueueName, null, true);
Queue queue = sessLive.createQueue("myqueue");

View File

@ -39,6 +39,7 @@ import org.apache.activemq.artemis.api.jms.JMSFactoryType;
import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQSession;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
@ -100,7 +101,7 @@ public class JMSReconnectTest extends ActiveMQTestBase {
SimpleString jmsQueueName = new SimpleString("myqueue");
coreSession.createQueue(jmsQueueName, jmsQueueName, null, true);
coreSession.createQueue(jmsQueueName, RoutingType.ANYCAST, jmsQueueName, null, true);
Queue queue = sess.createQueue("myqueue");

View File

@ -566,7 +566,7 @@ public class ActiveMQServerControlUsingCoreTest extends ActiveMQServerControlTes
@Override
public void createAddress(@Parameter(name = "name", desc = "The name of the address") String name,
@Parameter(name = "deliveryMode", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
@Parameter(name = "routingType", desc = "The delivery modes enabled for this address'") Object[] routingTypes) throws Exception {
}

View File

@ -833,7 +833,7 @@ public class SecurityTest extends ActiveMQTestBase {
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("auser", "pass");
Role role = new Role("arole", false, false, true, true, false, false, false, false, false, false);
Role role = new Role("arole", false, false, true, true, false, false, false, false, false, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
securityRepository.addMatch(SecurityTest.addressA, roles);
@ -923,7 +923,7 @@ public class SecurityTest extends ActiveMQTestBase {
HierarchicalRepository<Set<Role>> securityRepository = server.getSecurityRepository();
ActiveMQJAASSecurityManager securityManager = (ActiveMQJAASSecurityManager) server.getSecurityManager();
securityManager.getConfiguration().addUser("auser", "pass");
Role role = new Role("arole", false, false, false, false, true, true, false, false, false, false);
Role role = new Role("arole", false, false, false, false, true, true, false, false, false, true);
Set<Role> roles = new HashSet<>();
roles.add(role);
securityRepository.addMatch(SecurityTest.addressA, roles);

View File

@ -47,7 +47,7 @@ public class QueueTest extends JMSTestCase {
conn.start();
p.send(s.createTextMessage("payload"));
TextMessage m = (TextMessage) c.receive();
TextMessage m = (TextMessage) c.receive(5000);
ProxyAssertSupport.assertEquals("payload", m.getText());
} finally {

View File

@ -275,7 +275,7 @@ public class MessageHeaderTest extends MessageHeaderTestBase {
propNames.add(propName);
}
ProxyAssertSupport.assertEquals(9, propNames.size());
ProxyAssertSupport.assertTrue(propNames.size() >= 9);
ProxyAssertSupport.assertTrue(propNames.contains("myBool"));
ProxyAssertSupport.assertTrue(propNames.contains("myByte"));

View File

@ -34,6 +34,7 @@ import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.api.core.management.ManagementHelper;
import org.apache.activemq.artemis.api.core.management.ResourceNames;
import org.apache.activemq.artemis.core.remoting.impl.netty.NettyConnectorFactory;
import org.apache.activemq.artemis.core.server.RoutingType;
import org.apache.activemq.artemis.tests.util.SpawnedVMSupport;
import org.objectweb.jtests.jms.admin.Admin;
@ -119,7 +120,7 @@ public class AbstractAdmin implements Admin {
public void createQueue(final String name) {
Boolean result;
try {
invokeSyncOperation(ResourceNames.BROKER, "createQueue", name, name);
invokeSyncOperation(ResourceNames.BROKER, "createQueue", name, RoutingType.ANYCAST.toString(), name, null, true, ActiveMQDefaultConfiguration.getDefaultMaxQueueConsumers(), ActiveMQDefaultConfiguration.getDefaultDeleteQueueOnNoConsumers(), true);
} catch (Exception e) {
throw new IllegalStateException(e);
}