You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by rg...@apache.org on 2016/11/26 23:30:22 UTC
svn commit: r1771521 - in /qpid/java/trunk:
broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/
systests/src/main/java/org/apache/qpid/test/utils/
systests/src/test/java/org/apache/qpid/server/queue/ systests/src/test/j...
Author: rgodfrey
Date: Sat Nov 26 23:30:22 2016
New Revision: 1771521
URL: http://svn.apache.org/viewvc?rev=1771521&view=rev
Log:
QPID-7546 : Make some more tests run under AMQP 1.0, add the ability to generically create a connection with a specific prefetch value
Modified:
qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java
qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/SortedQueueTest.java
qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
qpid/java/trunk/test-profiles/Java10Excludes
qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
Modified: qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java (original)
+++ qpid/java/trunk/broker-plugins/amqp-1-0-protocol/src/main/java/org/apache/qpid/server/protocol/v1_0/AMQPConnection_1_0.java Sat Nov 26 23:30:22 2016
@@ -123,7 +123,7 @@ public class AMQPConnection_1_0 extends
{
private static Logger LOGGER = LoggerFactory.getLogger(AMQPConnection_1_0.class);
- private static final Logger FRAME_LOGGER = LoggerFactory.getLogger("FRM");
+ private static final Logger FRAME_LOGGER = LoggerFactory.getLogger("org.apache.qpid.server.protocol.frame");
private final AtomicBoolean _stateChanged = new AtomicBoolean();
private final AtomicReference<Action<ProtocolEngine>> _workListener = new AtomicReference<>();
Modified: qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java (original)
+++ qpid/java/trunk/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Sat Nov 26 23:30:22 2016
@@ -19,11 +19,13 @@ package org.apache.qpid.test.utils;
import java.io.File;
import java.net.URISyntaxException;
+import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -254,48 +256,99 @@ public class QpidBrokerTestCase extends
* @return A connection factory
* @throws NamingException if there is an error getting the factory
*/
- public ConnectionFactory getConnectionFactory(String factoryName) throws NamingException
+ public ConnectionFactory getConnectionFactory(String factoryName)
+ throws NamingException
{
return getConnectionFactory(factoryName, "test", "clientid");
}
- public ConnectionFactory getConnectionFactory(String factoryName, String vhost, String clientId) throws NamingException
+ public ConnectionFactory getConnectionFactory(String factoryName, String vhost, String clientId)
+ throws NamingException
+ {
+ return getConnectionFactory(factoryName, vhost, clientId, Collections.<String, String>emptyMap());
+ }
+ public ConnectionFactory getConnectionFactory(String factoryName, String vhost, String clientId, Map<String,String> options)
+ throws NamingException
{
if(isBroker10())
{
+ Map<String,String> actualOptions = new LinkedHashMap<>();
+ actualOptions.put("amqp.vhost", vhost);
+ actualOptions.put("jms.clientID", clientId);
+ actualOptions.put("jms.forceSyncSend", "true");
+ actualOptions.putAll(options);
if("failover".equals(factoryName))
{
+ if(!actualOptions.containsKey("failover.maxReconnectAttempts"))
+ {
+ actualOptions.put("failover.maxReconnectAttempts", "2");
+ }
+ final StringBuilder stem = new StringBuilder("failover:(amqp://localhost:")
+ .append(System.getProperty("test.port"))
+ .append(",amqp://localhost:")
+ .append(System.getProperty("test.port.alt"))
+ .append(")");
+ appendOptions(actualOptions, stem);
+
_initialContextEnvironment.put("property.connectionfactory.failover.remoteURI",
- "failover:(amqp://localhost:"
- + System.getProperty("test.port")
- + ",amqp://localhost:"
- + System.getProperty("test.port.alt")
- + ")?failover.maxReconnectAttempts=20&amqp.vhost="
- + vhost
- + "&jms.clientID="
- + clientId
- + "&jms.forceSyncSend=true");
+ stem.toString());
}
else if("default".equals(factoryName))
{
+ final StringBuilder stem = new StringBuilder("amqp://localhost:").append(System.getProperty("test.port"));
+
+
+ appendOptions(actualOptions, stem);
+
_initialContextEnvironment.put("property.connectionfactory.default.remoteURI",
- "amqp://localhost:"
- + System.getProperty("test.port")
- + "?amqp.vhost="
- + vhost
- + "&jms.clientID="
- + clientId);
+ stem.toString());
}
}
return (ConnectionFactory) getInitialContext().lookup(factoryName);
}
+ private void appendOptions(final Map<String, String> actualOptions, final StringBuilder stem)
+ {
+ boolean first = true;
+ for(Map.Entry<String, String> option : actualOptions.entrySet())
+ {
+ if(first)
+ {
+ stem.append('?');
+ first = false;
+ }
+ else
+ {
+ stem.append('&');
+ }
+ stem.append(option.getKey()).append('=').append(URLEncoder.encode(option.getValue()));
+ }
+ }
+
public Connection getConnection() throws JMSException, NamingException
{
return getConnection(GUEST_USERNAME, GUEST_PASSWORD);
}
+ public Connection getConnectionWithPrefetch(int prefetch) throws JMSException, NamingException, URLSyntaxException
+ {
+ if(isBroker10())
+ {
+ String factoryName = Boolean.getBoolean(PROFILE_USE_SSL) ? "default.ssl" : "default";
+
+ final Map<String, String> options =
+ Collections.singletonMap("jms.prefetchPolicy.all", String.valueOf(prefetch));
+ final ConnectionFactory connectionFactory = getConnectionFactory(factoryName, "test", "clientid", options);
+ return connectionFactory.createConnection(GUEST_USERNAME, GUEST_PASSWORD);
+
+ }
+ else
+ {
+ return getConnectionWithOptions(Collections.singletonMap("max_prefetch", String.valueOf(prefetch)));
+ }
+ }
+
public Connection getConnectionWithOptions(Map<String, String> options)
throws URLSyntaxException, NamingException, JMSException
{
@@ -360,6 +413,18 @@ public class QpidBrokerTestCase extends
return new AMQQueue(ExchangeDefaults.DIRECT_EXCHANGE_NAME, getTestQueueName());
}
+ public Queue getQueueFromName(Session session, String name) throws JMSException
+ {
+ if(isBroker10())
+ {
+ return session.createQueue(name);
+ }
+ else
+ {
+ return session.createQueue("ADDR: '" + name + "'");
+ }
+ }
+
public Queue createTestQueue(Session session) throws JMSException
{
return createTestQueue(session, getTestQueueName());
Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/QueueDepthWithSelectorTest.java Sat Nov 26 23:30:22 2016
@@ -21,11 +21,6 @@
package org.apache.qpid.server.queue;
-import org.apache.qpid.QpidException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-
import javax.jms.Connection;
import javax.jms.JMSException;
import javax.jms.Message;
@@ -34,6 +29,9 @@ import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
+import org.apache.qpid.QpidException;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+
/**
* Test Case to ensure that messages are correctly returned.
* This includes checking:
@@ -65,12 +63,12 @@ public class QueueDepthWithSelectorTest
super.setUp();
_messages = new Message[MSG_COUNT];
- _queue = getTestQueue();
-
+
//Create Producer
_producerConnection = getConnection();
_producerConnection.start();
_producerSession = _producerConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _queue = createTestQueue(_producerSession);
_producer = _producerSession.createProducer(_queue);
// Create consumer
@@ -110,9 +108,9 @@ public class QueueDepthWithSelectorTest
try
{
Connection connection = getConnection();
- AMQSession session = (AMQSession)connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
- long queueDepth = session.getQueueDepth((AMQDestination) _queue);
+ Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ connection.start();
+ long queueDepth = getQueueDepth(connection, _queue);
assertEquals("Session reports Queue depth not as expected", expectedDepth, queueDepth);
connection.close();
@@ -156,7 +154,7 @@ public class QueueDepthWithSelectorTest
//do a synchronous op to ensure the acks are processed
//on the broker before proceeding
- ((AMQSession)_clientSession).sync();
+ _clientSession.createTemporaryQueue().delete();
}
/**
Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/SortedQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/SortedQueueTest.java?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/SortedQueueTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/server/queue/SortedQueueTest.java Sat Nov 26 23:30:22 2016
@@ -40,10 +40,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.apache.qpid.QpidException;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.configuration.ClientProperties;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
public class SortedQueueTest extends QpidBrokerTestCase
@@ -62,11 +58,10 @@ public class SortedQueueTest extends Qpi
protected void setUp() throws Exception
{
super.setUp();
- setTestClientSystemProperty(ClientProperties.MAX_PREFETCH_PROP_NAME, "1");
// Sort value array to generated "expected" order of messages.
Arrays.sort(VALUES_SORTED);
_producerConnection = getConnection();
- _consumerConnection = getConnection();
+ _consumerConnection = getConnectionWithPrefetch(1);
_producerSession = _producerConnection.createSession(true, Session.SESSION_TRANSACTED);
_receiveInterval = isBrokerStorePersistent() ? 3000l : 1500l;
}
@@ -337,11 +332,9 @@ public class SortedQueueTest extends Qpi
private Queue createQueue() throws QpidException, JMSException
{
final Map<String, Object> arguments = new HashMap<String, Object>();
- arguments.put(QueueArgumentsConverter.QPID_QUEUE_SORT_KEY, TEST_SORT_KEY);
- ((AMQSession<?,?>) _producerSession).createQueue(getTestQueueName(), false, true, false, arguments);
- final Queue queue = new AMQQueue("amq.direct", getTestQueueName());
- ((AMQSession<?,?>) _producerSession).declareAndBind((AMQDestination) queue);
- return queue;
+ arguments.put(SortedQueue.SORT_KEY, TEST_SORT_KEY);
+ createEntityUsingAmqpManagement(getTestQueueName(), _producerSession, "org.apache.qpid.SortedQueue", arguments);
+ return getQueueFromName(_producerSession, getTestQueueName());
}
private Message getSortableTestMesssage(final String key) throws JMSException
Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java (original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/PropertyValueTest.java Sat Nov 26 23:30:22 2016
@@ -39,26 +39,24 @@ import javax.jms.MessageListener;
import javax.jms.MessageProducer;
import javax.jms.Queue;
import javax.jms.Session;
+import javax.jms.TextMessage;
import com.google.common.base.Strings;
import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.message.JMSTextMessage;
import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
public class PropertyValueTest extends QpidBrokerTestCase implements MessageListener
{
private static final Logger _logger = LoggerFactory.getLogger(PropertyValueTest.class);
- private AMQConnection _connection;
+ private Connection _connection;
private Destination _destination;
private Session _session;
- private final List<JMSTextMessage> received = new ArrayList<JMSTextMessage>();
+ private final List<TextMessage> received = new ArrayList<>();
private final List<String> messages = new ArrayList<String>();
private Map<String, Destination> _replyToDestinations;
private int _count = 1;
@@ -74,21 +72,16 @@ public class PropertyValueTest extends Q
super.tearDown();
}
- private void init(AMQConnection connection) throws Exception
- {
- Destination destination = new AMQQueue(connection, randomize("PropertyValueTest"), true);
- init(connection, destination);
- }
-
- private void init(AMQConnection connection, Destination destination) throws Exception
+ private void init(Connection connection) throws Exception
{
_connection = connection;
- _destination = destination;
- _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ _destination = createTestQueue(_session);
// set up a slow consumer
- _session.createConsumer(destination).setMessageListener(this);
- connection.start();
+ connection.start()
+ ;
+ _session.createConsumer(_destination).setMessageListener(this);
}
private Message getTestMessage() throws Exception
@@ -184,8 +177,8 @@ public class PropertyValueTest extends Q
*/
public void testLargeHeader_010_HeadersFillContentHeaderFrame() throws Exception
{
- _connection = (AMQConnection) getConnection();
- int maximumFrameSize = (int) _connection.getMaximumFrameSize();
+ _connection = getConnection();
+ int maximumFrameSize = (int) ((AMQConnection)_connection).getMaximumFrameSize();
Map<String, String> headerProperties = new HashMap<>();
int headerPropertySize = ((1<<16) - 1);
int i = 0;
@@ -231,8 +224,8 @@ public class PropertyValueTest extends Q
public void testLargeHeader_08091_HeadersFillContentHeaderFrame() throws Exception
{
- _connection = (AMQConnection) getConnection();
- int maximumFrameSize = (int) _connection.getMaximumFrameSize();
+ _connection = getConnection();
+ int maximumFrameSize = (int) ((AMQConnection)_connection).getMaximumFrameSize();
String propertyName = "string";
int overhead = calculateOverHead_08091_FrameWithHeader(propertyName);
@@ -246,7 +239,7 @@ public class PropertyValueTest extends Q
_session = _connection.createSession(true, Session.SESSION_TRANSACTED);
MessageProducer producer = _session.createProducer(_session.createQueue(getTestQueueName()));
- int maximumFrameSize = (int) _connection.getMaximumFrameSize();
+ int maximumFrameSize = (int) ((AMQConnection)_connection).getMaximumFrameSize();
String propertyName = "string";
int overhead = calculateOverHead_08091_FrameWithHeader(propertyName);
@@ -323,7 +316,7 @@ public class PropertyValueTest extends Q
_logger.error("Run Number:" + run++);
try
{
- init( (AMQConnection) getConnection());
+ init(getConnection());
}
catch (Exception e)
{
@@ -379,7 +372,7 @@ public class PropertyValueTest extends Q
}
else
{
- q = new AMQQueue(_connection, "TestReply");
+ q = _session.createQueue("TestReply");
}
m.setJMSReplyTo(q);
@@ -415,7 +408,7 @@ public class PropertyValueTest extends Q
void check() throws JMSException, URISyntaxException
{
List<String> actual = new ArrayList<String>();
- for (JMSTextMessage m : received)
+ for (TextMessage m : received)
{
actual.add(m.getText());
@@ -504,14 +497,10 @@ public class PropertyValueTest extends Q
{
synchronized (received)
{
- received.add((JMSTextMessage) message);
+ received.add((TextMessage) message);
received.notify();
}
}
- private static String randomize(String in)
- {
- return in + System.currentTimeMillis();
- }
}
Modified: qpid/java/trunk/test-profiles/Java10Excludes
URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10Excludes?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10Excludes (original)
+++ qpid/java/trunk/test-profiles/Java10Excludes Sat Nov 26 23:30:22 2016
@@ -98,6 +98,18 @@ org.apache.qpid.transport.MaxFrameSizeTe
// This test is concerned with the 0-x client establishing a connection to a supported version
org.apache.qpid.transport.ProtocolNegotiationTest#testProtocolNegotiationFromUnsupportedVersion
+// These tests are testing extensions to JMS on the 0-x client to manipulate AMQP 0-x model objects like Queues and Exchanges
+org.apache.qpid.client.session.ExchangeDeleteTest#*
+org.apache.qpid.client.session.QueueDeclareTest#*
+org.apache.qpid.client.session.QueueDeleteTest#*
+
+// The tests are Protocol version specific constraints on total header property size
+org.apache.qpid.test.unit.basic.PropertyValueTest#testOverlyLargeHeaderRejected_08091
+org.apache.qpid.test.unit.basic.PropertyValueTest#testLargeHeader_08091_HeadersFillContentHeaderFrame
+org.apache.qpid.test.unit.basic.PropertyValueTest#testLargeHeader_010_HeadersFillContentHeaderFrame
+
+
+
Modified: qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes?rev=1771521&r1=1771520&r2=1771521&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes (original)
+++ qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes Sat Nov 26 23:30:22 2016
@@ -35,9 +35,6 @@ org.apache.qpid.client.prefetch.Prefetch
org.apache.qpid.client.redelivered.RedeliveredMessageTest#*
org.apache.qpid.client.SynchReceiveTest#*
org.apache.qpid.client.SyncPublishTest#*
-org.apache.qpid.client.session.ExchangeDeleteTest#*
-org.apache.qpid.client.session.QueueDeclareTest#*
-org.apache.qpid.client.session.QueueDeleteTest#*
org.apache.qpid.test.client.failover.FailoverTest#*
org.apache.qpid.systest.prefetch.ZeroPrefetchTest#*
org.apache.qpid.systest.messageencryption.MessageEncryptionTest#*
@@ -47,8 +44,6 @@ org.apache.qpid.server.stats.StatisticsR
org.apache.qpid.server.security.acl.ExternalACLTest#*
org.apache.qpid.server.security.acl.ExhaustiveACLTest#*
org.apache.qpid.server.queue.TimeToLiveTest#*
-org.apache.qpid.server.queue.SortedQueueTest#*
-org.apache.qpid.server.queue.QueueDepthWithSelectorTest#*
org.apache.qpid.server.queue.QueueBindTest#*
org.apache.qpid.server.queue.ProducerFlowControlTest#*
org.apache.qpid.server.queue.PriorityQueueTest#*
@@ -73,7 +68,6 @@ org.apache.qpid.test.unit.client.connect
org.apache.qpid.test.unit.client.channelclose.CloseWithBlockingReceiveTest#*
org.apache.qpid.test.unit.client.AMQSessionTest#*
org.apache.qpid.test.unit.basic.SessionStartTest#*
-org.apache.qpid.test.unit.basic.PropertyValueTest#*
org.apache.qpid.test.unit.basic.InvalidDestinationTest#*
org.apache.qpid.test.unit.basic.FieldTableMessageTest#*
org.apache.qpid.test.unit.basic.close.CloseTest#*
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org