[jboss-cvs] JBoss Messaging SVN: r1953 - in branches/Branch_1_0_1_SP: tests/bin and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Jan 10 22:25:13 EST 2007
Author: clebert.suconic at jboss.com
Date: 2007-01-10 22:25:09 -0500 (Wed, 10 Jan 2007)
New Revision: 1953
Modified:
branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
branches/Branch_1_0_1_SP/tests/bin/runtest
branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/QueueTest.java
branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
Log:
http://jira.jboss.org/jira/browse/JBMESSAGING-741
Modified: branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java
===================================================================
--- branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java 2007-01-10 20:51:02 UTC (rev 1952)
+++ branches/Branch_1_0_1_SP/src/main/org/jboss/jms/server/plugin/JDBCChannelMapper.java 2007-01-11 03:25:09 UTC (rev 1953)
@@ -281,6 +281,21 @@
id = l.longValue();
}
+ // Put in id map too
+
+ JBossDestination jbd ;
+
+ if (isQueue)
+ {
+ jbd = new JBossQueue(destName);
+ }
+ else
+ {
+ jbd = new JBossTopic(destName);
+ }
+
+ idMap.put(new Long(id), jbd);
+
// TODO I am using LocalQueues for the time being, switch to distributed Queues
if (isQueue)
{
@@ -338,21 +353,6 @@
}
}
- // Put in id map too
-
- JBossDestination jbd ;
-
- if (isQueue)
- {
- jbd = new JBossQueue(destName);
- }
- else
- {
- jbd = new JBossTopic(destName);
- }
-
- idMap.put(new Long(id), jbd);
-
log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
pageSize + ", downCacheSize=" + downCacheSize + ") deployed");
}
@@ -411,6 +411,21 @@
{
if (log.isTraceEnabled()) { log.trace("creating temporary core destination for " + destName); }
+ //Put in id map too
+
+ JBossDestination jbd ;
+
+ if (isQueue)
+ {
+ jbd = new JBossQueue(destName);
+ }
+ else
+ {
+ jbd = new JBossTopic(destName);
+ }
+
+ idMap.put(new Long(id), jbd);
+
CoreDestination cd = getCoreDestinationInternal(isQueue, destName);
if (cd != null)
{
@@ -433,21 +448,6 @@
topics.put(destName, cd);
}
- //Put in id map too
-
- JBossDestination jbd ;
-
- if (isQueue)
- {
- jbd = new JBossQueue(destName);
- }
- else
- {
- jbd = new JBossTopic(destName);
- }
-
- idMap.put(new Long(id), jbd);
-
log.debug("core destination " + cd + " (fullSize=" + fullSize + ", pageSize=" +
pageSize + ", downCacheSize=" + downCacheSize + ") deployed");
}
Modified: branches/Branch_1_0_1_SP/tests/bin/runtest
===================================================================
--- branches/Branch_1_0_1_SP/tests/bin/runtest 2007-01-10 20:51:02 UTC (rev 1952)
+++ branches/Branch_1_0_1_SP/tests/bin/runtest 2007-01-11 03:25:09 UTC (rev 1953)
@@ -43,7 +43,7 @@
# it from there.
#
-ant -Dtest.execution.classpath.file=bin/.test.execution.classpath -f $reldir/../build.xml get-test-execution-classpath
+ant -Dtest.execution.classpath.file=bin/.test.execution.classpath -f $reldir/../build.xml compile get-test-execution-classpath
CLASSPATH=`cat $reldir/.test.execution.classpath`
outputdir="$reldir/../output"
Modified: branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/QueueTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-01-10 20:51:02 UTC (rev 1952)
+++ branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/QueueTest.java 2007-01-11 03:25:09 UTC (rev 1953)
@@ -31,6 +31,7 @@
import javax.naming.InitialContext;
import org.jboss.jms.client.JBossConnectionFactory;
+import org.jboss.jms.message.JBossMessage;
import org.jboss.test.messaging.MessagingTestCase;
import org.jboss.test.messaging.tools.ServerManagement;
@@ -43,39 +44,39 @@
public class QueueTest extends MessagingTestCase
{
// Constants -----------------------------------------------------
-
+
// Static --------------------------------------------------------
-
+
// Attributes ----------------------------------------------------
protected InitialContext ic;
protected ConnectionFactory cf;
// Constructors --------------------------------------------------
-
+
public QueueTest(String name)
{
super(name);
}
-
+
// TestCase overrides -------------------------------------------
-
+
public void setUp() throws Exception
{
- super.setUp();
-
+ super.setUp();
+
ServerManagement.start("all");
-
-
+
+
ic = new InitialContext(ServerManagement.getJNDIEnvironment());
cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
-
+
ServerManagement.undeployQueue("TestQueue");
ServerManagement.deployQueue("TestQueue");
log.debug("setup done");
}
-
+
public void tearDown() throws Exception
{
ServerManagement.undeployQueue("TestQueue");
@@ -83,8 +84,8 @@
log.debug("tear down done");
}
-
-
+
+
// Public --------------------------------------------------------
/**
@@ -117,6 +118,62 @@
}
}
+ /**
+ * The simplest possible queue test.
+ */
+ public void testRedeployQueue() throws Exception
+ {
+ Queue queue = (Queue)ic.lookup("/queue/TestQueue");
+
+ Connection conn = cf.createConnection();
+
+ try
+ {
+ Session s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ MessageProducer p = s.createProducer(queue);
+ MessageConsumer c = s.createConsumer(queue);
+ conn.start();
+
+ for (int i = 0; i < 500; i++)
+ {
+ p.send(s.createTextMessage("payload " + i));
+ }
+
+ //ServerManagement.undeployQueue("TestQueue");
+
+ log.info("Stopping server");
+ ServerManagement.stopServerPeer();
+
+ log.info("Starting server");
+ ServerManagement.startServerPeer();
+ ServerManagement.deployQueue("TestQueue");
+
+ ic = new InitialContext(ServerManagement.getJNDIEnvironment());
+ cf = (JBossConnectionFactory)ic.lookup("/ConnectionFactory");
+
+ conn = cf.createConnection();
+ s = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+ p = s.createProducer(queue);
+ c = s.createConsumer(queue);
+ conn.start();
+
+ for (int i = 0; i < 500; i++)
+ {
+ TextMessage message = (TextMessage)c.receive(3000);
+ assertNotNull(message);
+ assertNotNull(message.getJMSDestination());
+ }
+
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+ }
+
public void testQueueName() throws Exception
{
Queue queue = (Queue)ic.lookup("/queue/TestQueue");
@@ -124,12 +181,12 @@
}
// Package protected ---------------------------------------------
-
+
// Protected -----------------------------------------------------
-
+
// Private -------------------------------------------------------
-
+
// Inner classes -------------------------------------------------
-
+
}
Modified: branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
===================================================================
--- branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java 2007-01-10 20:51:02 UTC (rev 1952)
+++ branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java 2007-01-11 03:25:09 UTC (rev 1953)
@@ -23,6 +23,9 @@
import java.sql.Connection;
import java.sql.PreparedStatement;
+import java.util.List;
+import java.util.ArrayList;
+import java.util.HashMap;
import javax.naming.InitialContext;
import javax.sql.DataSource;
@@ -35,13 +38,18 @@
import org.jboss.jms.server.DestinationManager;
import org.jboss.jms.server.plugin.contract.ChannelMapper;
import org.jboss.jms.server.subscription.DurableSubscription;
+import org.jboss.jms.message.JBossTextMessage;
import org.jboss.messaging.core.local.CoreDestination;
import org.jboss.messaging.core.local.Queue;
import org.jboss.messaging.core.local.Topic;
import org.jboss.messaging.core.persistence.JDBCUtil;
import org.jboss.messaging.core.plugin.contract.MessageStore;
import org.jboss.messaging.core.plugin.contract.PersistenceManager;
+import org.jboss.messaging.core.Channel;
+import org.jboss.messaging.core.Message;
+import org.jboss.messaging.core.MessageReference;
import org.jboss.test.messaging.MessagingTestCase;
+import org.jboss.test.messaging.core.SimpleChannel;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.tm.TransactionManagerService;
import org.jboss.util.id.GUID;
@@ -50,9 +58,10 @@
* These tests must not be run in remote mode!
*
* @author <a href="mailto:tim.fox at jboss.com">Tim Fox</a>
- * @version <tt>1.1</tt>
+ * @author <a href="mailto:Galder.Zamarreno at jboss.com">Galder Zamarreno</a>
+ * @version <tt>$Release$</tt>
*
- * JDBCChannelMapperTest.java,v 1.1 2006/02/28 16:48:15 timfox Exp
+ * $Id$
*/
public class JDBCChannelMapperTest extends MessagingTestCase
{
@@ -340,14 +349,86 @@
assertEquals(cd4.getId(), cd2.getId());
}
-
+ public void testSendRedeployAndConsume() throws Throwable
+ {
+ /* Deploy 'paradise' as destination queue */
+ channelMapper.deployCoreDestination(true, "paradise", ms, pm, null, 100, 20, 10);
+ /* Deploy 'earth' as queue to reply to */
+ channelMapper.deployCoreDestination(true, "earth", ms, pm, null, 100, 20, 10);
+ Channel channel = new SimpleChannel(0, ms);
+ /* Create a message for 'paradise' queue destination */
+ Message[] m = createMessages(1);
+ List refs = new ArrayList();
+ MessageReference ref1 = ms.reference(m[0]);
+
+ ref1.setOrdering(11);
+ refs.add(ref1);
+
+ /* We persist the message */
+ pm.addReferences(channel.getChannelID(), refs, false);
+
+ /* Delete the message from memory so that on redeployment, messaging is forced
+ * to retrieve it from the database */
+ ms.forgetMessage(0);
+
+ log.info("********************** UnDeploying coreDestination");
+ channelMapper.undeployCoreDestination(true, "paradise");
+ channelMapper.undeployCoreDestination(true, "earth");
+
+ log.info("********************** Deploying coreDestination");
+
+ /* We redeploy the target destination which will load the message from the database */
+ channelMapper.deployCoreDestination(true, "paradise", ms, pm, null, 100, 20, 10);
+
+ JBossDestination jd = channelMapper.getJBossDestination(0);
+ Queue q = (Queue) channelMapper.getCoreDestination(jd);
+
+ /* Browse the pending messages */
+ List l = q.browse();
+ JBossTextMessage message = (JBossTextMessage)l.get(0);
+ /* Browse the pending messages. There's only one and its destination should not be
+ * null, in fact, it should be 'paradise' */
+ assertNotNull(message.getJMSDestination());
+ assertEquals("Destination should be 'paradise'","paradise",
+ ((JBossDestination)message.getJMSDestination()).getName());
+ }
+
// Package protected ---------------------------------------------
// Protected -----------------------------------------------------
// Private -------------------------------------------------------
+ private Message[] createMessages(int num) throws Throwable
+ {
+ //Generate some messages with a good range of attribute values
+ Message[] messages = new Message[num];
+ for (int i = 0; i < num; i++)
+ {
+ messages[i] = createMessage((byte)i, true);
+ }
+ return messages;
+ }
+
+ private Message createMessage(byte i, boolean reliable) throws Throwable
+ {
+ return new JBossTextMessage(i,
+ reliable,
+ System.currentTimeMillis() + 1000 * 60 * 60,
+ System.currentTimeMillis(),
+ (byte)(i % 10),
+ new HashMap(),
+ "hello".getBytes(),
+ 0,
+ "msg",
+ "1",
+ "1".getBytes(),
+ new JBossQueue("paradise"),
+ new JBossQueue("earth"),
+ new HashMap());
+ }
+
// Inner classes -------------------------------------------------
}
Property changes on: branches/Branch_1_0_1_SP/tests/src/org/jboss/test/messaging/jms/server/plugin/JDBCChannelMapperTest.java
___________________________________________________________________
Name: svn:keywords
+ Id LastChangedDate Author Revision
More information about the jboss-cvs-commits
mailing list