You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ru...@apache.org on 2007/09/27 17:32:33 UTC

svn commit: r580066 - in /incubator/qpid/branches/M2.1/java: perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java

Author: rupertlssmith
Date: Thu Sep 27 08:32:31 2007
New Revision: 580066

URL: http://svn.apache.org/viewvc?rev=580066&view=rev
Log:
Added test cases 4 and 5, from the updated interop spec.

Modified:
    incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
    incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java

Modified: incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java?rev=580066&r1=580065&r2=580066&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java (original)
+++ incubator/qpid/branches/M2.1/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java Thu Sep 27 08:32:31 2007
@@ -1213,7 +1213,7 @@
             // log.info("Message " + num + " sent.");
         }
 
-        // Increase the unreceived size, this may actually happen aftern the message is recevied.
+        // Increase the unreceived size, this may actually happen aftern the message is received.
         _unreceived.getAndIncrement();
 
         // Apply message rate throttling if a rate limit has been set up.

Modified: incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
URL: http://svn.apache.org/viewvc/incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java?rev=580066&r1=580065&r2=580066&view=diff
==============================================================================
--- incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java (original)
+++ incubator/qpid/branches/M2.1/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java Thu Sep 27 08:32:31 2007
@@ -26,16 +26,13 @@
 
 import uk.co.thebadgerset.junit.extensions.util.ParsedProperties;
 
-import javax.jms.Connection;
-import javax.jms.ConnectionFactory;
-import javax.jms.JMSException;
-import javax.jms.Message;
+import javax.jms.*;
 import javax.naming.Context;
 import javax.naming.InitialContext;
 import javax.naming.NamingException;
 
-import java.util.Properties;
 import java.util.Map;
+import java.util.Properties;
 
 /**
  * TestUtils provides static helper methods that are usefull for writing tests against QPid.
@@ -51,6 +48,10 @@
     /** Used for debugging. */
     private static Logger log = Logger.getLogger(TestUtils.class);
 
+    private static byte[] MESSAGE_DATA_BYTES =
+        "Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- Test Message -- "
+        .getBytes();
+
     /**
      * Establishes a JMS connection using a set of properties and qpids built in JNDI implementation. This is a simple
      * convenience method for code that does not anticipate handling connection failures. All exceptions that indicate
@@ -96,9 +97,8 @@
             Context ctx = new InitialContext(messagingProps);
 
             ConnectionFactory cf = (ConnectionFactory) ctx.lookup(CONNECTION_NAME);
-            Connection connection = cf.createConnection();
 
-            return connection;
+            return cf.createConnection();
         }
         catch (NamingException e)
         {
@@ -108,6 +108,39 @@
         {
             throw new RuntimeException("Could not establish connection due to JMSException.", e);
         }
+    }
+
+    /**
+     * Creates a test message of the specified size, on the given JMS session.
+     *
+     * @param session The JMS session.
+     * @param size    The size of the message in bytes.
+     *
+     * @return A bytes message, of the specified size, filled with dummy data.
+     *
+     *
+     */
+    public static Message createTestMessageOfSize(Session session, int size) throws JMSException
+    {
+        BytesMessage message = session.createBytesMessage();
+
+        if (size > 0)
+        {
+            int div = MESSAGE_DATA_BYTES.length / size;
+            int mod = MESSAGE_DATA_BYTES.length % size;
+
+            for (int i = 0; i < div; i++)
+            {
+                message.writeBytes(MESSAGE_DATA_BYTES);
+            }
+
+            if (mod != 0)
+            {
+                message.writeBytes(MESSAGE_DATA_BYTES, 0, mod);
+            }
+        }
+
+        return message;
     }
 
     /**