summaryrefslogtreecommitdiff
path: root/java
diff options
context:
space:
mode:
authorRupert Smith <rupertlssmith@apache.org>2007-09-27 15:32:31 +0000
committerRupert Smith <rupertlssmith@apache.org>2007-09-27 15:32:31 +0000
commit7e1ac76588d8a335e5ea64edbb127d53f1ef57be (patch)
tree5d2a92d1dbf26a7c1ed84f88b63a05680b17ed36 /java
parente2a88b4171f61ab4832ee4081041746b8ce5eef5 (diff)
downloadqpid-python-7e1ac76588d8a335e5ea64edbb127d53f1ef57be.tar.gz
Added test cases 4 and 5, from the updated interop spec.
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/branches/M2.1@580066 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java2
-rw-r--r--java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java47
2 files changed, 41 insertions, 8 deletions
diff --git a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
index 1e01f6bc8e..6bb531e24f 100644
--- a/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
+++ b/java/perftests/src/main/java/org/apache/qpid/requestreply/PingPongProducer.java
@@ -1213,7 +1213,7 @@ public class PingPongProducer implements Runnable /*, MessageListener*/, Excepti
// 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.
diff --git a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java b/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
index 8b3e72ef08..569eac425c 100644
--- a/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
+++ b/java/systests/src/main/java/org/apache/qpid/test/framework/TestUtils.java
@@ -26,16 +26,13 @@ import static org.apache.qpid.test.framework.MessagingTestConfigProperties.*;
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 @@ public class TestUtils
/** 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 @@ public class TestUtils
Context ctx = new InitialContext(messagingProps);
ConnectionFactory cf = (ConnectionFactory) ctx.lookup(CONNECTION_NAME);
- Connection connection = cf.createConnection();
- return connection;
+ return cf.createConnection();
}
catch (NamingException e)
{
@@ -111,6 +111,39 @@ public class TestUtils
}
/**
+ * 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;
+ }
+
+ /**
* Pauses for the specified length of time. In the event of failing to pause for at least that length of time
* due to interuption of the thread, a RutimeException is raised to indicate the failure. The interupted status
* of the thread is restores in that case. This method should only be used when it is expected that the pause