qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgodf...@apache.org
Subject svn commit: r1771180 - in /qpid/java/trunk: systests/src/test/java/org/apache/qpid/client/message/ systests/src/test/java/org/apache/qpid/test/unit/basic/ systests/src/test/java/org/apache/qpid/test/unit/message/ test-profiles/
Date Thu, 24 Nov 2016 16:27:22 GMT
Author: rgodfrey
Date: Thu Nov 24 16:27:22 2016
New Revision: 1771180

URL: http://svn.apache.org/viewvc?rev=1771180&view=rev
Log:
QPID-7546 : Make some more tests run under AMQP 1.0

Added:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/ObjectMessageClassWhitelistingTest.java
      - copied, changed from r1771179, qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/JmsObjectMessageTest.java
Removed:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/JmsObjectMessageTest.java
Modified:
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
    qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
    qpid/java/trunk/test-profiles/Java10Excludes
    qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes

Copied: qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/ObjectMessageClassWhitelistingTest.java
(from r1771179, qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/JmsObjectMessageTest.java)
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/ObjectMessageClassWhitelistingTest.java?p2=qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/ObjectMessageClassWhitelistingTest.java&p1=qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/JmsObjectMessageTest.java&r1=1771179&r2=1771180&rev=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/JmsObjectMessageTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/client/message/ObjectMessageClassWhitelistingTest.java
Thu Nov 24 16:27:22 2016
@@ -38,7 +38,7 @@ import org.apache.qpid.configuration.Com
 import org.apache.qpid.jms.ConnectionURL;
 import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
-public class JmsObjectMessageTest extends QpidBrokerTestCase
+public class ObjectMessageClassWhitelistingTest extends QpidBrokerTestCase
 {
     public static final int TIMEOUT = 10000;
     public static final int TEST_VALUE = 37;
@@ -172,7 +172,7 @@ public class JmsObjectMessageTest extend
     public void testWhiteListedAnonymousClassByConnectionUrlObjectMessage() throws Exception
     {
         Map<String, String> connectionOptions = new HashMap<>();
-        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
JmsObjectMessageTest.class.getCanonicalName());
+        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
ObjectMessageClassWhitelistingTest.class.getCanonicalName());
         final Connection c = getConnectionWithOptions(connectionOptions);
         doTestWhiteListedEnclosedClassTest(c, createAnonymousObject(TEST_VALUE));
     }
@@ -180,8 +180,8 @@ public class JmsObjectMessageTest extend
     public void testBlackListedAnonymousClassByConnectionUrlObjectMessage() throws Exception
     {
         Map<String, String> connectionOptions = new HashMap<>();
-        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
JmsObjectMessageTest.class.getPackage().getName());
-        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_BLACK_LIST,
JmsObjectMessageTest.class.getCanonicalName());
+        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
ObjectMessageClassWhitelistingTest.class.getPackage().getName());
+        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_BLACK_LIST,
ObjectMessageClassWhitelistingTest.class.getCanonicalName());
 
         final Connection c = getConnectionWithOptions(connectionOptions);
         doTestBlackListedEnclosedClassTest(c, createAnonymousObject(TEST_VALUE));
@@ -190,7 +190,7 @@ public class JmsObjectMessageTest extend
     public void testWhiteListedNestedClassByConnectionUrlObjectMessage() throws Exception
     {
         Map<String, String> connectionOptions = new HashMap<>();
-        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
JmsObjectMessageTest.NestedClass.class.getCanonicalName());
+        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
ObjectMessageClassWhitelistingTest.NestedClass.class.getCanonicalName());
         final Connection c = getConnectionWithOptions(connectionOptions);
         doTestWhiteListedEnclosedClassTest(c, new NestedClass(TEST_VALUE));
     }
@@ -198,7 +198,7 @@ public class JmsObjectMessageTest extend
     public void testBlackListedNestedClassByConnectionUrlObjectMessage() throws Exception
     {
         Map<String, String> connectionOptions = new HashMap<>();
-        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
JmsObjectMessageTest.class.getCanonicalName());
+        connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_WHITE_LIST,
ObjectMessageClassWhitelistingTest.class.getCanonicalName());
         connectionOptions.put(ConnectionURL.OPTIONS_OBJECT_MESSAGE_CLASS_HIERARCHY_BLACK_LIST,
NestedClass.class.getCanonicalName());
 
         final Connection c = getConnectionWithOptions(connectionOptions);

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/BytesMessageTest.java
Thu Nov 24 16:27:22 2016
@@ -19,17 +19,9 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-import org.junit.Assert;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQDestination;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.message.JMSBytesMessage;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.transport.util.Waiter;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
 import javax.jms.BytesMessage;
 import javax.jms.Connection;
@@ -42,10 +34,13 @@ import javax.jms.MessageNotReadableExcep
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-import java.nio.ByteBuffer;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+
+import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import org.apache.qpid.transport.util.Waiter;
 
 public class BytesMessageTest extends QpidBrokerTestCase implements MessageListener
 {
@@ -54,15 +49,20 @@ public class BytesMessageTest extends Qp
     private Connection _connection;
     private Destination _destination;
     private Session _session;
-    private final List<JMSBytesMessage> received = new ArrayList<JMSBytesMessage>();
+    private final List<Message> received = new ArrayList<>();
     private final List<byte[]> messages = new ArrayList<byte[]>();
     private int _count = 100;
-    public String _connectionString = "vm://:1";
 
     protected void setUp() throws Exception
     {
         super.setUp();
-        init((AMQConnection) getConnection("guest", "guest"));
+        _connection = getConnection("guest", "guest");
+        _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        _destination = createTestQueue(_session);
+
+        // Set up a slow consumer.
+        _session.createConsumer(_destination).setMessageListener(this);
+        _connection.start();
     }
 
     protected void tearDown() throws Exception
@@ -70,22 +70,6 @@ public class BytesMessageTest extends Qp
         super.tearDown();
     }
 
-    void init(AMQConnection connection) throws Exception
-    {
-        init(connection, new AMQQueue(connection, randomize("BytesMessageTest"), true));
-    }
-
-    void init(AMQConnection connection, AMQDestination destination) throws Exception
-    {
-        _connection = connection;
-        _destination = destination;
-        _session = connection.createSession(false, AMQSession.NO_ACKNOWLEDGE);
-
-        // Set up a slow consumer.
-        _session.createConsumer(destination).setMessageListener(this);
-        connection.start();
-    }
-
     public void test() throws Exception
     {
         try
@@ -140,18 +124,20 @@ public class BytesMessageTest extends Qp
 
     void check() throws JMSException
     {
-        List<byte[]> actual = new ArrayList<byte[]>();
-        for (JMSBytesMessage m : received)
+        List<byte[]> actual = new ArrayList<>();
+        for (Message message : received)
         {
-            ByteBuffer buffer = m.getData();
-            byte[] data = new byte[buffer.remaining()];
-            buffer.get(data);
+
+            BytesMessage bytesMessage = (BytesMessage)message;
+
+            byte[] data = new byte[(int) bytesMessage.getBodyLength()];
+            bytesMessage.readBytes(data);
             actual.add(data);
 
             // Check Body Write Status
             try
             {
-                m.writeBoolean(true);
+                bytesMessage.writeBoolean(true);
                 Assert.fail("Message should not be writeable");
             }
             catch (MessageNotWriteableException mnwe)
@@ -159,11 +145,11 @@ public class BytesMessageTest extends Qp
                 // normal execution
             }
 
-            m.clearBody();
+            bytesMessage.clearBody();
 
             try
             {
-                m.writeBoolean(true);
+                bytesMessage.writeBoolean(true);
             }
             catch (MessageNotWriteableException mnwe)
             {
@@ -173,7 +159,7 @@ public class BytesMessageTest extends Qp
             // Check property write status
             try
             {
-                m.setStringProperty("test", "test");
+                bytesMessage.setStringProperty("test", "test");
                 Assert.fail("Message should not be writeable");
             }
             catch (MessageNotWriteableException mnwe)
@@ -181,11 +167,11 @@ public class BytesMessageTest extends Qp
                 // normal execution
             }
 
-            m.clearProperties();
+            bytesMessage.clearProperties();
 
             try
             {
-                m.setStringProperty("test", "test");
+                bytesMessage.setStringProperty("test", "test");
             }
             catch (MessageNotWriteableException mnwe)
             {
@@ -246,39 +232,12 @@ public class BytesMessageTest extends Qp
     {
         synchronized (received)
         {
-            received.add((JMSBytesMessage) message);
+            received.add(message);
             received.notify();
         }
     }
 
-    private static String randomize(String in)
-    {
-        return in + System.currentTimeMillis();
-    }
-
-    public static void main(String[] argv) throws Exception
-    {
-        final String connectionString;
-        final int count;
-        if (argv.length == 0)
-        {
-            connectionString = "vm://:1";
-            count = 100;
-        }
-        else
-        {
-            connectionString = argv[0];
-            count = Integer.parseInt(argv[1]);
-        }
 
-        _logger.info("connectionString = " + connectionString);
-        _logger.info("count = " + count);
-
-        BytesMessageTest test = new BytesMessageTest();
-        test._connectionString = connectionString;
-        test._count = count;
-        test.test();
-    }
 
     public void testModificationAfterSend() throws Exception
     {

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/MapMessageTest.java
Thu Nov 24 16:27:22 2016
@@ -20,16 +20,11 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-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.JMSMapMessage;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
 
+import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.MapMessage;
@@ -39,22 +34,24 @@ import javax.jms.MessageListener;
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
+
+import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class MapMessageTest extends QpidBrokerTestCase implements MessageListener
 {
     private static final Logger _logger = LoggerFactory.getLogger(MapMessageTest.class);
 
-    private AMQConnection _connection;
+    private Connection _connection;
     private Destination _destination;
-    private AMQSession _session;
-    private final List<JMSMapMessage> received = new ArrayList<JMSMapMessage>();
+    private Session _session;
+    private final List<Message> received = new ArrayList<>();
 
     private static final String MESSAGE = "Message ";
     private int _count = 100;
-    public String _connectionString = "vm://:1";
     private byte[] _bytes = { 99, 98, 97, 96, 95 };
     private static final float _smallfloat = 100.0f;
 
@@ -63,7 +60,13 @@ public class MapMessageTest extends Qpid
         super.setUp();
         try
         {
-            init((AMQConnection) getConnection("guest", "guest"));
+            _connection = getConnection("guest", "guest");
+            _session = _connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+            _destination = createTestQueue(_session);
+
+            // set up a slow consumer
+            _session.createConsumer(_destination).setMessageListener(this);
+            _connection.start();
         }
         catch (Exception e)
         {
@@ -77,23 +80,6 @@ public class MapMessageTest extends Qpid
         super.tearDown();
     }
 
-    private void init(AMQConnection connection) throws Exception
-    {
-        Destination destination = new AMQQueue(connection, randomize("MapMessageTest"), true);
-        init(connection, destination);
-    }
-
-    private void init(AMQConnection connection, Destination destination) throws Exception
-    {
-        _connection = connection;
-        _destination = destination;
-        _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
-
-        // set up a slow consumer
-        _session.createConsumer(destination).setMessageListener(this);
-        connection.start();
-    }
-
     public void test() throws Exception
     {
         int count = _count;
@@ -179,22 +165,26 @@ public class MapMessageTest extends Qpid
 
     void check() throws JMSException
     {
-         int count = 0;
-        for (JMSMapMessage m : received)
+        int count = 0;
+        for (Message message : received)
         {
-             testMapValues(m, count);
+            assertTrue("Message is not a MapMessage", message instanceof MapMessage);
 
-            testCorrectExceptions(m);
+            MapMessage mapMessage = (MapMessage) message;
 
-            testMessageWriteStatus(m);
+            testMapValues(mapMessage, count);
 
-            testPropertyWriteStatus(m);
+            testCorrectExceptions(mapMessage);
+
+            testMessageWriteStatus(mapMessage);
+
+            testPropertyWriteStatus(mapMessage);
 
             count++;
         }
     }
 
-    private void testCorrectExceptions(JMSMapMessage m) throws JMSException
+    private void testCorrectExceptions(MapMessage m) throws JMSException
     {
         testBoolean(m);
 
@@ -217,7 +207,7 @@ public class MapMessageTest extends Qpid
         testString(m);
     }
 
-    private void testString(JMSMapMessage m) throws JMSException
+    private void testString(MapMessage m) throws JMSException
     {
 
         Assert.assertFalse(m.getBoolean("message"));
@@ -307,7 +297,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals(MESSAGE + m.getInt("messageNumber"), m.getString("message"));
     }
 
-    private void testShort(JMSMapMessage m) throws JMSException
+    private void testShort(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -382,7 +372,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + Short.MAX_VALUE, m.getString("short"));
     }
 
-    private void testLong(JMSMapMessage m) throws JMSException
+    private void testLong(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -473,7 +463,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + Long.MAX_VALUE, m.getString("long"));
     }
 
-    private void testDouble(JMSMapMessage m) throws JMSException
+    private void testDouble(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -565,7 +555,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + Double.MAX_VALUE, m.getString("double"));
     }
 
-    private void testFloat(JMSMapMessage m) throws JMSException
+    private void testFloat(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -648,7 +638,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + Float.MAX_VALUE, m.getString("float"));
     }
 
-    private void testInt(JMSMapMessage m) throws JMSException
+    private void testInt(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -731,7 +721,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + Integer.MAX_VALUE, m.getString("int"));
     }
 
-    private void testChar(JMSMapMessage m) throws JMSException
+    private void testChar(MapMessage m) throws JMSException
     {
 
         // Try bad reads
@@ -821,7 +811,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + 'c', m.getString("char"));
     }
 
-    private void testBytes(JMSMapMessage m) throws JMSException
+    private void testBytes(MapMessage m) throws JMSException
     {
         // Try bad reads
         try
@@ -920,7 +910,7 @@ public class MapMessageTest extends Qpid
 
     }
 
-    private void testByte(JMSMapMessage m) throws JMSException
+    private void testByte(MapMessage m) throws JMSException
     {
         // Try bad reads
         try
@@ -988,7 +978,7 @@ public class MapMessageTest extends Qpid
 
     }
 
-    private void testBoolean(JMSMapMessage m) throws JMSException
+    private void testBoolean(MapMessage m) throws JMSException
     {
 
         Assert.assertEquals((m.getInt("messageNumber") / 2) == 0, m.getBoolean("odd"));
@@ -1078,7 +1068,7 @@ public class MapMessageTest extends Qpid
         Assert.assertEquals("" + ((m.getInt("messageNumber") / 2) == 0), m.getString("odd"));
     }
 
-    private void testPropertyWriteStatus(JMSMapMessage m) throws JMSException
+    private void testPropertyWriteStatus(MapMessage m) throws JMSException
     {
         // Check property write status
         try
@@ -1103,7 +1093,7 @@ public class MapMessageTest extends Qpid
         }
     }
 
-    private void testMessageWriteStatus(JMSMapMessage m) throws JMSException
+    private void testMessageWriteStatus(MapMessage m) throws JMSException
     {
         try
         {
@@ -1127,7 +1117,7 @@ public class MapMessageTest extends Qpid
         }
     }
 
-    private void testMapValues(JMSMapMessage m, int count) throws JMSException
+    private void testMapValues(MapMessage m, int count) throws JMSException
     {
         // Test get<Primiative>
 
@@ -1239,31 +1229,9 @@ public class MapMessageTest extends Qpid
         synchronized (received)
         {
             _logger.info("****************** Recevied Messgage:" + message);
-            received.add((JMSMapMessage) message);
+            received.add(message);
             received.notify();
         }
     }
 
-    private static String randomize(String in)
-    {
-        return in + System.currentTimeMillis();
-    }
-
-    public static void main(String[] argv) throws Exception
-    {
-        MapMessageTest test = new MapMessageTest();
-        test._connectionString = (argv.length == 0) ? "vm://:1" : argv[0];
-        test.setUp();
-        if (argv.length > 1)
-        {
-            test._count = Integer.parseInt(argv[1]);
-        }
-
-        test.test();
-    }
-
-    public static junit.framework.Test suite()
-    {
-        return new junit.framework.TestSuite(MapMessageTest.class);
-    }
 }

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/basic/TextMessageTest.java
Thu Nov 24 16:27:22 2016
@@ -20,48 +20,48 @@
  */
 package org.apache.qpid.test.unit.basic;
 
-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 java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
 
+import javax.jms.Connection;
 import javax.jms.Destination;
 import javax.jms.JMSException;
 import javax.jms.Message;
+import javax.jms.MessageConsumer;
 import javax.jms.MessageListener;
 import javax.jms.MessageNotWriteableException;
 import javax.jms.MessageProducer;
 import javax.jms.Session;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
+import javax.jms.TextMessage;
+
+import org.junit.Assert;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 public class TextMessageTest extends QpidBrokerTestCase implements MessageListener
 {
     private static final Logger _logger = LoggerFactory.getLogger(TextMessageTest.class);
 
-    private AMQConnection _connection;
+    private Connection _connection;
     private Destination _destination;
-    private AMQSession _session;
-    private final List<JMSTextMessage> received = new ArrayList<JMSTextMessage>();
+    private Session _session;
+    private final List<Message> received = new ArrayList<>();
     private final List<String> messages = new ArrayList<String>();
     private int _count = 100;
-    public String _connectionString = "vm://:1";
     private CountDownLatch _waitForCompletion;
+    private MessageConsumer _consumer;
 
     protected void setUp() throws Exception
     {
         super.setUp();
         try
         {
-            init((AMQConnection) getConnection("guest", "guest"));
+            init(getConnection("guest", "guest"));
         }
         catch (Exception e)
         {
@@ -74,29 +74,26 @@ public class TextMessageTest extends Qpi
         super.tearDown();
     }
 
-    private void init(AMQConnection connection) throws Exception
-    {
-        Destination destination =
-            new AMQQueue(connection.getDefaultQueueExchangeName(), randomize("TextMessageTest"),
true);
-        init(connection, destination);
-    }
-
-    private void init(AMQConnection connection, Destination destination) throws Exception
+    private void init(Connection connection) throws Exception
     {
         _connection = connection;
+        connection.start();
+        final Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Destination destination = createTestQueue(session);
+        session.close();
+        _session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
         _destination = destination;
-        _session = (AMQSession) connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
 
         // set up a slow consumer
         try
         {
-            _session.createConsumer(destination).setMessageListener(this);
+            _consumer = _session.createConsumer(destination);
+            _consumer.setMessageListener(this);
         }
         catch (Throwable  e)
         {
             _logger.error("Error creating consumer", e);
         }
-        connection.start();
     }
 
     public void test() throws Exception
@@ -131,14 +128,16 @@ public class TextMessageTest extends Qpi
     void check() throws JMSException
     {
         List<String> actual = new ArrayList<String>();
-        for (JMSTextMessage m : received)
+        for (Message message : received)
         {
-            actual.add(m.getText());
+            assertTrue("Message is not a text message", message instanceof TextMessage);
+            TextMessage textMessage = (TextMessage)message;
+            actual.add(textMessage.getText());
 
             // Check body write status
             try
             {
-                m.setText("Test text");
+                textMessage.setText("Test text");
                 Assert.fail("Message should not be writeable");
             }
             catch (MessageNotWriteableException mnwe)
@@ -146,11 +145,11 @@ public class TextMessageTest extends Qpi
                 // normal execution
             }
 
-            m.clearBody();
+            textMessage.clearBody();
 
             try
             {
-                m.setText("Test text");
+                textMessage.setText("Test text");
             }
             catch (MessageNotWriteableException mnwe)
             {
@@ -160,7 +159,7 @@ public class TextMessageTest extends Qpi
             // Check property write status
             try
             {
-                m.setStringProperty("test", "test");
+                textMessage.setStringProperty("test", "test");
                 Assert.fail("Message should not be writeable");
             }
             catch (MessageNotWriteableException mnwe)
@@ -168,11 +167,11 @@ public class TextMessageTest extends Qpi
                 // normal execution
             }
 
-            m.clearProperties();
+            textMessage.clearProperties();
 
             try
             {
-                m.setStringProperty("test", "test");
+                textMessage.setStringProperty("test", "test");
             }
             catch (MessageNotWriteableException mnwe)
             {
@@ -226,20 +225,9 @@ public class TextMessageTest extends Qpi
         synchronized (received)
         {
             _logger.info("===== received one message");
-            received.add((JMSTextMessage) message);
+            received.add(message);
             _waitForCompletion.countDown();
         }
     }
 
-    private static String randomize(String in)
-    {
-        return in + System.currentTimeMillis();
-    }
-
-
-
-    public static junit.framework.Test suite()
-    {
-         return new junit.framework.TestSuite(TextMessageTest.class);
-    }
 }

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/JMSPropertiesTest.java
Thu Nov 24 16:27:22 2016
@@ -20,16 +20,9 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.AMQPInvalidClassException;
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.client.message.NonQpidObjectMessage;
-import org.apache.qpid.client.message.QpidMessageProperties;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.jms.Connection;
 import javax.jms.Destination;
@@ -41,9 +34,13 @@ import javax.jms.ObjectMessage;
 import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.Topic;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Map;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.client.message.NonQpidObjectMessage;
+import org.apache.qpid.client.message.QpidMessageProperties;
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 /**
  * @author Apache Software Foundation
@@ -53,8 +50,6 @@ public class JMSPropertiesTest extends Q
 
     private static final Logger _logger = LoggerFactory.getLogger(JMSPropertiesTest.class);
 
-    public String _connectionString = "vm://:1";
-
     public static final String JMS_CORR_ID = "QPIDID_01";
     public static final int JMS_DELIV_MODE = 1;
     public static final String JMS_TYPE = "test.jms.type";
@@ -73,16 +68,16 @@ public class JMSPropertiesTest extends Q
 
     public void testJMSProperties() throws Exception
     {
-        AMQConnection con = (AMQConnection) getConnection("guest", "guest");
-        AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-        Queue queue =
-            new AMQQueue(con.getDefaultQueueExchangeName(), "someQ", "someQ", false, true);
+        Connection con = getConnection("guest", "guest");
+        Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+
+        Queue queue = createTestQueue(consumerSession, "someQ");
         MessageConsumer consumer = consumerSession.createConsumer(queue);
 
-        AMQConnection con2 = (AMQConnection) getConnection("guest", "guest");
+        Connection con2 = getConnection("guest", "guest");
         Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
         MessageProducer producer = producerSession.createProducer(queue);
-        Destination JMS_REPLY_TO = new AMQQueue(con2, "my.replyto");
+        Destination JMS_REPLY_TO = createTestQueue(producerSession, "my.replyto");
         // create a test message to send
         ObjectMessage sentMsg = new NonQpidObjectMessage(producerSession);
         sentMsg.setJMSCorrelationID(JMS_CORR_ID);
@@ -98,24 +93,13 @@ public class JMSPropertiesTest extends Q
 
         try
         {
-            sentMsg.setObjectProperty(NULL_OBJECT_PROPERTY, null);
-            fail("Null Object Property value set");
-        }
-        catch (MessageFormatException mfe)
-        {
-            // Check the error message
-            assertEquals("Incorrect error message", AMQPInvalidClassException.INVALID_OBJECT_MSG
+ "null", mfe.getMessage());
-        }
-
-        try
-        {
             sentMsg.setObjectProperty(INVALID_OBJECT_PROPERTY, new Exception());
             fail("Non primitive Object Property value set");
         }
         catch (MessageFormatException mfe)
         {
-            // Check the error message
-            assertEquals("Incorrect error message: " + mfe.getMessage(), AMQPInvalidClassException.INVALID_OBJECT_MSG
+ Exception.class, mfe.getMessage());
+            // pass
+
         }
 
         // send it
@@ -173,10 +157,10 @@ public class JMSPropertiesTest extends Q
     public void testQpidExtensionProperties() throws Exception
     {
         Connection con = getConnection("guest", "guest");
-        Session ssn = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        Session ssn = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
         con.start();
 
-        Topic topic = ssn.createTopic("test");
+        Topic topic = createTopic(con, "test");
         MessageConsumer consumer = ssn.createConsumer(topic);
         MessageProducer prod = ssn.createProducer(topic);
         Message m = ssn.createMessage();

Modified: qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
URL: http://svn.apache.org/viewvc/qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
(original)
+++ qpid/java/trunk/systests/src/test/java/org/apache/qpid/test/unit/message/StreamMessageTest.java
Thu Nov 24 16:27:22 2016
@@ -20,17 +20,9 @@
  */
 package org.apache.qpid.test.unit.message;
 
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import org.apache.qpid.client.AMQConnection;
-import org.apache.qpid.client.AMQHeadersExchange;
-import org.apache.qpid.client.AMQQueue;
-import org.apache.qpid.client.AMQSession;
-import org.apache.qpid.exchange.ExchangeDefaults;
-import org.apache.qpid.test.utils.QpidBrokerTestCase;
-import org.apache.qpid.url.AMQBindingURL;
-import org.apache.qpid.url.BindingURL;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
 
 import javax.jms.Connection;
 import javax.jms.Message;
@@ -38,14 +30,14 @@ import javax.jms.MessageConsumer;
 import javax.jms.MessageEOFException;
 import javax.jms.MessageListener;
 import javax.jms.MessageProducer;
+import javax.jms.Queue;
 import javax.jms.Session;
 import javax.jms.StreamMessage;
 
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.atomic.AtomicReference;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.apache.qpid.test.utils.QpidBrokerTestCase;
 
 /**
  * @author Apache Software Foundation
@@ -56,26 +48,14 @@ public class StreamMessageTest extends Q
 
     public void testStreamMessageEOF() throws Exception
     {
-        AMQConnection con = (AMQConnection) getConnection("guest", "guest");
-        AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-
-        AMQHeadersExchange queue =
-            new AMQHeadersExchange(new AMQBindingURL(
-                    ExchangeDefaults.HEADERS_EXCHANGE_CLASS + "://" + ExchangeDefaults.HEADERS_EXCHANGE_NAME
-                    + "/test/queue1?" + BindingURL.OPTION_ROUTING_KEY + "='F0000=1'"));
-
-        Map<String,Object> ft = new HashMap<>();
-        ft.put("x-match", "any");
-        ft.put("F1000", "1");
-        consumerSession.declareAndBind(queue, ft);
+        Connection con = getConnection("guest", "guest");
+        Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        Queue queue = createTestQueue(consumerSession);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
-        // force synch to ensure the consumer has resulted in a bound queue
-        // ((AMQSession) consumerSession).declareExchangeSynch(ExchangeDefaults.HEADERS_EXCHANGE_NAME,
ExchangeDefaults.HEADERS_EXCHANGE_CLASS);
-        // This is the default now
 
-        Connection con2 = (AMQConnection) getConnection("guest", "guest");
+        Connection con2 = getConnection("guest", "guest");
 
-        AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
 
         // Need to start the "producer" connection in order to receive bounced messages
         _logger.info("Starting producer connection");
@@ -84,11 +64,8 @@ public class StreamMessageTest extends Q
         MessageProducer mandatoryProducer = producerSession.createProducer(queue);
 
         // Third test - should be routed
-        _logger.info("Sending isBound message");
         StreamMessage msg = producerSession.createStreamMessage();
 
-        msg.setStringProperty("F1000", "1");
-
         msg.writeByte((byte) 42);
 
         mandatoryProducer.send(msg);
@@ -118,9 +95,12 @@ public class StreamMessageTest extends Q
         final CountDownLatch awaitMessages = new CountDownLatch(1);
         final AtomicReference<Throwable> listenerCaughtException = new AtomicReference<Throwable>();
 
-        AMQConnection con = (AMQConnection) getConnection("guest", "guest");
-        AMQSession consumerSession = (AMQSession) con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
-        AMQQueue queue = new AMQQueue(con.getDefaultQueueExchangeName(), "testQ");
+        Connection con = getConnection("guest", "guest");
+        Session session = con.createSession(false, Session.AUTO_ACKNOWLEDGE);
+        Queue queue = createTestQueue(session);
+        session.close();
+
+        Session consumerSession = con.createSession(false, Session.CLIENT_ACKNOWLEDGE);
         MessageConsumer consumer = consumerSession.createConsumer(queue);
         consumer.setMessageListener(new MessageListener()
             {
@@ -145,8 +125,8 @@ public class StreamMessageTest extends Q
                 }
             });
 
-        Connection con2 = (AMQConnection) getConnection("guest", "guest");
-        AMQSession producerSession = (AMQSession) con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
+        Connection con2 = getConnection("guest", "guest");
+        Session producerSession = con2.createSession(false, Session.CLIENT_ACKNOWLEDGE);
         MessageProducer producer = producerSession.createProducer(queue);
         con.start();
         StreamMessage sm = producerSession.createStreamMessage();

Modified: qpid/java/trunk/test-profiles/Java10Excludes
URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10Excludes?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10Excludes (original)
+++ qpid/java/trunk/test-profiles/Java10Excludes Thu Nov 24 16:27:22 2016
@@ -28,4 +28,10 @@ org.apache.qpid.test.unit.topic.TopicSes
 // These tests explicitly meddle with prefetch - maybe there should be equivalents for AMQP
1.0
 org.apache.qpid.test.unit.transacted.CommitRollbackTest#testRollbackSessionAfterCreditExhausted
 
+// This test covers the client version specific mechanisms for restricting the types of Object
which can be sent via an ObjectMessage
+org.apache.qpid.client.message.ObjectMessageClassWhitelistingTest#*
+
+// This test checks that the client behaves in a non-JMS spec compliant way
+org.apache.qpid.test.unit.message.JMSPropertiesTest#testQpidExtensionProperties
+
 

Modified: qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes
URL: http://svn.apache.org/viewvc/qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes?rev=1771180&r1=1771179&r2=1771180&view=diff
==============================================================================
--- qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes (original)
+++ qpid/java/trunk/test-profiles/Java10UninvestigatedTestsExcludes Thu Nov 24 16:27:22 2016
@@ -32,7 +32,6 @@ org.apache.qpid.test.client.QueueBrowser
 org.apache.qpid.test.client.QueueBrowserTransactedTest#*
 org.apache.qpid.client.HeartbeatTest#*
 org.apache.qpid.client.message.AMQPEncodedMapMessageTest#*
-org.apache.qpid.client.message.JmsObjectMessageTest#*
 org.apache.qpid.client.prefetch.PrefetchBehaviourTest#*
 org.apache.qpid.client.redelivered.RedeliveredMessageTest#*
 org.apache.qpid.client.SynchReceiveTest#*
@@ -40,7 +39,6 @@ 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.client.message.JmsObjectMessageTest#*
 org.apache.qpid.test.client.failover.FailoverTest#*
 org.apache.qpid.test.client.DupsOkTest#*
 org.apache.qpid.systest.prefetch.ZeroPrefetchTest#*
@@ -68,8 +66,6 @@ org.apache.qpid.server.queue.ArrivalTime
 org.apache.qpid.server.message.MessageProtocolConversionTest#*
 org.apache.qpid.test.unit.topic.DurableSubscriptionTest#*
 org.apache.qpid.test.unit.message.UTF8Test#*
-org.apache.qpid.test.unit.message.StreamMessageTest#*
-org.apache.qpid.test.unit.message.JMSPropertiesTest#*
 org.apache.qpid.test.unit.close.MessageConsumerCloseTest#*
 org.apache.qpid.test.unit.close.JavaServerCloseRaceConditionTest#*
 org.apache.qpid.test.unit.client.message.ObjectMessageTest#*
@@ -79,17 +75,14 @@ org.apache.qpid.test.unit.client.connect
 org.apache.qpid.test.unit.client.connection.BrokerClosesClientConnectionTest#*
 org.apache.qpid.test.unit.client.channelclose.CloseWithBlockingReceiveTest#*
 org.apache.qpid.test.unit.client.AMQSessionTest#*
-org.apache.qpid.test.unit.basic.TextMessageTest#*
 org.apache.qpid.test.unit.basic.SessionStartTest#*
 org.apache.qpid.test.unit.basic.PubSubTwoConnectionTest#*
 org.apache.qpid.test.unit.basic.PropertyValueTest#*
 org.apache.qpid.test.unit.basic.ObjectMessageTest#*
 org.apache.qpid.test.unit.basic.MultipleConnectionTest#*
-org.apache.qpid.test.unit.basic.MapMessageTest#*
 org.apache.qpid.test.unit.basic.InvalidDestinationTest#*
 org.apache.qpid.test.unit.basic.FieldTableMessageTest#*
 org.apache.qpid.test.unit.basic.close.CloseTest#*
-org.apache.qpid.test.unit.basic.BytesMessageTest#*
 org.apache.qpid.test.unit.ack.RecoverTest#*
 org.apache.qpid.test.unit.ack.AcknowledgeTest#*
 org.apache.qpid.test.unit.ack.AcknowledgeOnMessageTest#*




---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@qpid.apache.org
For additional commands, e-mail: commits-help@qpid.apache.org


Mime
View raw message