[jboss-cvs] JBossAS SVN: r64395 - in branches/Branch_4_4/testsuite: src/main/org/jboss/test/messagedriven/mbeans and 1 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Aug 1 00:23:15 EDT 2007
Author: clebert.suconic at jboss.com
Date: 2007-08-01 00:23:15 -0400 (Wed, 01 Aug 2007)
New Revision: 64395
Modified:
branches/Branch_4_4/testsuite/build.xml
branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/mbeans/TestMessageDrivenManagement.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/CheckJMSDestinationOperation.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java
branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SimpleMessageDrivenUnitTest.java
Log:
Fixing test - making MDB tests more generic
Modified: branches/Branch_4_4/testsuite/build.xml
===================================================================
--- branches/Branch_4_4/testsuite/build.xml 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/build.xml 2007-08-01 04:23:15 UTC (rev 64395)
@@ -2560,6 +2560,7 @@
<sysproperty key="log4j.configuration" value="file:${build.resources}/log4j.xml"/>
<sysproperty key="java.naming.provider.url" value="${node0.jndi.url}"/>
<sysproperty key="jbosstest.server.host" value="${node0}"/>
+ <sysproperty key="jbosstest.useJBM" value="true"/>
<!-- Pass along any jbosstest.* system properties -->
<syspropertyset>
<propertyref prefix="jbosstest."/>
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/mbeans/TestMessageDrivenManagement.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/mbeans/TestMessageDrivenManagement.java 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/mbeans/TestMessageDrivenManagement.java 2007-08-01 04:23:15 UTC (rev 64395)
@@ -21,11 +21,16 @@
*/
package org.jboss.test.messagedriven.mbeans;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Properties;
import javax.jms.Message;
+import javax.jms.TextMessage;
import javax.naming.InitialContext;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
@@ -76,10 +81,10 @@
{
synchronized (messages)
{
- messages.add(message);
+ messages.add(cloneMessage(message));
}
}
-
+
public ArrayList getMessages()
{
synchronized (messages)
@@ -111,4 +116,29 @@
System.setProperty("test.messagedriven." + key, props.getProperty(key));
}
}
+
+ /**
+ * JBossMessage will resend the send message, and because of that the message needs to be cloned before being stored
+ * @param message
+ * @return
+ */
+ private Message cloneMessage(Message message)
+ {
+ try
+ {
+ ByteArrayOutputStream byteOut = new ByteArrayOutputStream();
+ ObjectOutputStream cloneOut = new ObjectOutputStream(byteOut);
+ cloneOut.writeObject(message);
+ cloneOut.close();
+ ObjectInputStream inputArray = new ObjectInputStream (new ByteArrayInputStream(byteOut.toByteArray()));
+ message = (Message)inputArray.readObject();
+ }
+ catch (Exception e)
+ {
+ log.error(e.toString(), e);
+ }
+ return message;
+ }
+
+
}
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/BasicMessageDrivenUnitTest.java 2007-08-01 04:23:15 UTC (rev 64395)
@@ -33,6 +33,7 @@
import javax.jms.Message;
import javax.jms.MessageProducer;
import javax.jms.Session;
+import javax.jms.TextMessage;
import javax.management.ObjectName;
import org.jboss.mx.util.ObjectNameFactory;
@@ -51,17 +52,29 @@
protected static final long WAIT_TIME = 5000L;
protected static final long REPEATED_WAIT = 4;
- protected static final ObjectName testQueue = ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=testQueue");
- protected static final Properties testQueueProps = new Properties();
+ protected static ObjectName testQueue = ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=testQueue");
+ protected static Properties testQueueProps = new Properties();
- protected static final ObjectName testTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testTopic");
- protected static final Properties testTopicProps = new Properties();
+ protected static ObjectName testTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testTopic");
+ protected static Properties testTopicProps = new Properties();
- protected static final ObjectName testDurableTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testDurableTopic");
- protected static final Properties testDurableTopicProps = new Properties();
+ protected static ObjectName testDurableTopic = ObjectNameFactory.create("jboss.mq.destination:service=Topic,name=testDurableTopic");
+ protected static Properties testDurableTopicProps = new Properties();
+
+ protected static ObjectName dlqJMXDestination = ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=DLQ");
static
{
+
+
+ if (System.getProperty("jbosstest.useJBM") != null)
+ {
+ testQueue = ObjectNameFactory.create("jboss.messaging.destination:service=Queue,name=testQueue");
+ testTopic = ObjectNameFactory.create("jboss.messaging.destination:service=Topic,name=testTopic");
+ testDurableTopic = ObjectNameFactory.create("jboss.messaging.destination:service=Topic,name=testDurableTopic");
+ dlqJMXDestination = ObjectNameFactory.create("jboss.messaging.destination:service=Queue,name=DLQ");
+ }
+
testQueueProps.put("destination", "queue/testQueue");
testQueueProps.put("destinationType", "javax.jms.Queue");
@@ -84,7 +97,6 @@
protected String mbeansar = "testmessagedriven.sar";
protected ObjectName jmxDestination = ObjectNameFactory.create("does:not=exist");
- protected ObjectName dlqJMXDestination = ObjectNameFactory.create("jboss.mq.destination:service=Queue,name=DLQ");
protected String connectionFactoryJNDI = "ConnectionFactory";
protected Destination destination;
protected Destination dlqDestination;
@@ -209,9 +221,9 @@
}
}
- public Message getTestMessage() throws Exception
+ public TextMessage getTestMessage() throws Exception
{
- return getSession().createMessage();
+ return getSession().createTextMessage();
}
protected void setUp() throws Exception
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/CheckJMSDestinationOperation.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/CheckJMSDestinationOperation.java 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/CheckJMSDestinationOperation.java 2007-08-01 04:23:15 UTC (rev 64395)
@@ -21,7 +21,9 @@
*/
package org.jboss.test.messagedriven.support;
+import javax.jms.Destination;
import javax.jms.Message;
+import javax.jms.TextMessage;
/**
* Check a message property
@@ -32,20 +34,28 @@
public class CheckJMSDestinationOperation extends Operation
{
protected int msgNo;
- protected String destination;
+ protected Destination destination;
+ String expectedValue;
- public CheckJMSDestinationOperation(BasicMessageDrivenUnitTest test, int msgNo, String destination)
+ public CheckJMSDestinationOperation(BasicMessageDrivenUnitTest test, int msgNo, Destination destination, String expectedValue)
{
super(test);
this.msgNo = msgNo;
this.destination = destination;
+ this.expectedValue = expectedValue;
}
public void run() throws Exception
{
- Message message = (Message) test.getMessages().get(msgNo);
- String actual = message.getJMSDestination().toString();
- if (actual == null || actual.startsWith(destination) == false)
- throw new Exception("For msgNo=" + msgNo + " destination=" + actual + " Expected=" + destination + " msg=" + message);
+ TextMessage message = (TextMessage) test.getMessages().get(msgNo);
+ Destination msgdest = message.getJMSDestination();
+
+ if (message == null || !msgdest.equals(destination))
+ throw new Exception("**** For msgNo=" + msgNo + " destination=" + destination.toString() + " received=" + msgdest.toString());
+
+ if (!message.getText().equals(expectedValue))
+ {
+ throw new Exception(expectedValue + " != " + message.getText());
+ }
}
}
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SendMessageOperation.java 2007-08-01 04:23:15 UTC (rev 64395)
@@ -24,6 +24,7 @@
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageProducer;
+import javax.jms.TextMessage;
/**
* Send a message
@@ -51,7 +52,8 @@
try
{
MessageProducer producer = test.getMessageProducer();
- Message message = test.getTestMessage();
+ TextMessage message = test.getTestMessage();
+ message.setText(id);
message.setStringProperty(MESSAGEID, id);
producer.send(message);
// DONE
Modified: branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SimpleMessageDrivenUnitTest.java
===================================================================
--- branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SimpleMessageDrivenUnitTest.java 2007-08-01 03:57:27 UTC (rev 64394)
+++ branches/Branch_4_4/testsuite/src/main/org/jboss/test/messagedriven/support/SimpleMessageDrivenUnitTest.java 2007-08-01 04:23:15 UTC (rev 64395)
@@ -70,7 +70,7 @@
{
new SendMessageOperation(this, "1"),
new CheckMessageSizeOperation(this, 1, 0),
- new CheckJMSDestinationOperation(this, 0, getDestination().toString()),
+ new CheckJMSDestinationOperation(this, 0, getDestination(), "1"),
new CheckMessageIDOperation(this, 0, "1"),
};
}
@@ -80,14 +80,14 @@
return new Operation[]
{
new SendMessageOperation(this, "1"),
- new CheckMessageSizeOperation(this, 7, 0),
- new CheckJMSDestinationOperation(this, 0, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 1, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 2, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 3, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 4, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 5, getDestination().toString()),
- new CheckJMSDestinationOperation(this, 6, getDLQDestination().toString()),
+ new CheckMessageSizeOperation(this, 7, 500),
+ new CheckJMSDestinationOperation(this, 0, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 1, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 2, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 3, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 4, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 5, getDestination(), "1"),
+ new CheckJMSDestinationOperation(this, 6, getDLQDestination(), "1"),
new CheckMessageIDOperation(this, 0, "1"),
new CheckMessageIDOperation(this, 1, "1"),
new CheckMessageIDOperation(this, 2, "1"),
More information about the jboss-cvs-commits
mailing list