[jboss-cvs] JBoss Messaging SVN: r7867 - in branches/JBMESSAGING-1742: tests/src/org/jboss/test/messaging/jms/clustering and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Oct 26 04:14:10 EDT 2009
Author: gaohoward
Date: 2009-10-26 04:14:10 -0400 (Mon, 26 Oct 2009)
New Revision: 7867
Modified:
branches/JBMESSAGING-1742/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/DestinationRedeployTest.java
branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/FakeClusterConnectionManager.java
Log:
test
Modified: branches/JBMESSAGING-1742/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java
===================================================================
--- branches/JBMESSAGING-1742/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java 2009-10-23 14:09:41 UTC (rev 7866)
+++ branches/JBMESSAGING-1742/src/main/org/jboss/messaging/core/impl/JDBCPersistenceManager.java 2009-10-26 08:14:10 UTC (rev 7867)
@@ -2831,6 +2831,8 @@
map.put("MESSAGE_ID_COLUMN", "MESSAGE_ID");
map.put("DELETE_MESSAGE",
"DELETE FROM JBM_MSG WHERE MESSAGE_ID = ? AND NOT EXISTS (SELECT JBM_MSG_REF.MESSAGE_ID FROM JBM_MSG_REF WHERE JBM_MSG_REF.MESSAGE_ID = ?)");
+ map.put("DELETE_CHANNEL_MESSAGE_REF", "DELETE FROM JBM_MSG_REF WHERE CHANNEL_ID=?");
+ map.put("DELETE_CHANNEL_MESSAGE", "DELETE FROM JBM_MSG WHERE MESSAGE_ID = ?");
// Transaction
Modified: branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/DestinationRedeployTest.java
===================================================================
--- branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/DestinationRedeployTest.java 2009-10-23 14:09:41 UTC (rev 7866)
+++ branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/DestinationRedeployTest.java 2009-10-26 08:14:10 UTC (rev 7867)
@@ -35,10 +35,12 @@
import javax.jms.XAConnectionFactory;
import javax.jms.XASession;
import javax.naming.InitialContext;
+import javax.naming.NamingException;
import javax.transaction.Transaction;
import javax.transaction.TransactionManager;
import javax.transaction.xa.XAResource;
+import org.jboss.jms.client.JBossConnectionFactory;
import org.jboss.test.messaging.jms.clustering.XAFailoverTest.DummyXAResource;
import org.jboss.test.messaging.tools.ServerManagement;
import org.jboss.test.messaging.tools.container.InVMInitialContextFactory;
@@ -102,9 +104,9 @@
}
}
- public void testRedeploy0() throws Exception
+ public void testRedeployQueue() throws Exception
{
- String msgBase = "testRedeploy0";
+ String msgBase = "testRedeployQueue";
int numMsg = 50;
deployDestinations();
@@ -112,14 +114,54 @@
sendMessages(0, cQueue, msgBase, numMsg);
sendMessages(1, nQueue, msgBase, numMsg);
- sendMessages(0, cTopic, msgBase, numMsg);
- sendMessages(1, nTopic, msgBase, numMsg);
receiveMessages(0, cQueue, msgBase, 0, numMsg, null, Session.AUTO_ACKNOWLEDGE, false);
- receiveMessages(2, cQueue, msgBase, 0, numMsg, null, Session.CLIENT_ACKNOWLEDGE, false);
- receiveMessages(0, cQueue, msgBase, 0, numMsg, null, Session.CLIENT_ACKNOWLEDGE, false);
- receiveMessages(3, cQueue, msgBase, 0, numMsg, null, Session.AUTO_ACKNOWLEDGE, false);
+ receiveMessages(2, nQueue, msgBase, 0, numMsg, null, Session.CLIENT_ACKNOWLEDGE, false);
+ }
+
+ public void testRedeployTopic() throws Exception
+ {
+ String msgBase = "testRedeployTopic";
+ int numMsg = 50;
+
+ deployDestinations();
+ redeployDestinations(false);
+ Connection conn = null;
+ Session sess = null;
+ try
+ {
+ conn = createConnectionOnServer(cf, 0);
+ conn.setClientID("client-id-0");
+ sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
+
+ MessageConsumer sub1 = sess.createConsumer(cTopic);
+ MessageConsumer sub2 = sess.createDurableSubscriber(nTopic, "sub2");
+
+ conn.start();
+
+ sendMessages(0, cTopic, msgBase, numMsg);
+ sendMessages(1, nTopic, msgBase, numMsg);
+
+ for (int i = 0; i < numMsg; i++)
+ {
+ TextMessage rm = (TextMessage)sub1.receive(5000);
+ assertEquals(msgBase + i, rm.getText());
+ rm = (TextMessage)sub2.receive(5000);
+ assertEquals(msgBase + i, rm.getText());
+ }
+
+ sub2.close();
+ sess.unsubscribe("sub2");
+ }
+ finally
+ {
+ if (conn != null)
+ {
+ conn.close();
+ }
+ }
+
}
/*
@@ -140,7 +182,33 @@
}
ServerManagement.deployQueue("nonclustered2ClusteredQueue");
ServerManagement.deployTopic("nonclustered2ClusteredTopic");
+
+ cQueue = (Queue)ic[0].lookup("queue/clustered2NonclusteredQueue");
+ nQueue = (Queue)ic[0].lookup("queue/nonclustered2ClusteredQueue");
+ cTopic = (Topic)ic[0].lookup("topic/clustered2NonclusteredTopic");
+ nTopic = (Topic)ic[0].lookup("topic/nonclustered2ClusteredTopic");
+
+ Queue anotherQueue = null;
+ try
+ {
+ anotherQueue = (Queue)ic[1].lookup("queue/clustered2NonclusteredQueue");
+ assertNotNull(anotherQueue);
+ }
+ catch (NamingException e)
+ {
+ fail("The queue " + anotherQueue + " should not exist after redeploy");
+ }
+ Topic anotherTopic = null;
+ try
+ {
+ anotherTopic = (Topic)ic[1].lookup("topic/clustered2NonclusteredTopic");
+ assertNotNull(anotherTopic);
+ }
+ catch (NamingException e)
+ {
+ fail("The topic " + anotherTopic + " should not exist after redeploy");
+ }
}
private void redeployDestinations(boolean keepMessage) throws Exception
@@ -154,8 +222,10 @@
for (int i = 0; i < nodeCount; i++)
{
startDefaultServer(i, overrides, false);
+ ic[i] = new InitialContext(ServerManagement.getJNDIEnvironment(i));
}
+ log.error("-----------------------------------------redeploying.......");
//redeploy
for (int i = 0; i < nodeCount; i++)
{
@@ -164,6 +234,37 @@
}
ServerManagement.deployQueue("clustered2NonclusteredQueue");
ServerManagement.deployTopic("clustered2NonclusteredTopic");
+
+
+ cQueue = (Queue)ic[0].lookup("queue/clustered2NonclusteredQueue");
+ nQueue = (Queue)ic[0].lookup("queue/nonclustered2ClusteredQueue");
+ cTopic = (Topic)ic[0].lookup("topic/clustered2NonclusteredTopic");
+ nTopic = (Topic)ic[0].lookup("topic/nonclustered2ClusteredTopic");
+
+ log.error("-----------------------------------------redeploying.......done");
+ cf = (JBossConnectionFactory)ic[0].lookup("/ClusteredConnectionFactory");
+
+ try
+ {
+ Queue nonExistQueue = (Queue)ic[1].lookup("queue/clustered2NonclusteredQueue");
+ fail("The queue " + nonExistQueue + " should not exist after redeploy");
+ }
+ catch (NamingException e)
+ {
+ //ok
+ }
+
+ try
+ {
+ Topic nonExistTopic = (Topic)ic[1].lookup("topic/clustered2NonclusteredTopic");
+ fail("The topic " + nonExistTopic + " should not exist after redeploy");
+ }
+ catch (NamingException e)
+ {
+ //ok
+ }
+
+
}
private void sendMessages(int serverIndex, Destination dest, String msgBase, int numMsg) throws Exception
@@ -174,6 +275,7 @@
conn = createConnectionOnServer(cf, serverIndex);
Session sess = conn.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer producer = sess.createProducer(dest);
+ log.info("-----Sending messages to: " + dest);
for (int i = 0; i < numMsg; i++)
{
TextMessage msg = sess.createTextMessage(msgBase + i);
@@ -203,6 +305,8 @@
XASession xasess = null;
XAResource res = null;
+ boolean xa = false;
+
if (isXA == null)
{
//no tx
@@ -219,6 +323,7 @@
sess = xasess.getSession();
xaconn.start();
+ xa = true;
}
else
{
@@ -228,7 +333,7 @@
conn.start();
}
- if (isXA.booleanValue())
+ if (xa)
{
tm.begin();
@@ -281,8 +386,14 @@
}
finally
{
- conn.close();
- xaconn.close();
+ if (conn != null)
+ {
+ conn.close();
+ }
+ if (xaconn != null)
+ {
+ xaconn.close();
+ }
}
}
}
Modified: branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/FakeClusterConnectionManager.java
===================================================================
--- branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/FakeClusterConnectionManager.java 2009-10-23 14:09:41 UTC (rev 7866)
+++ branches/JBMESSAGING-1742/tests/src/org/jboss/test/messaging/jms/clustering/FakeClusterConnectionManager.java 2009-10-26 08:14:10 UTC (rev 7867)
@@ -396,6 +396,10 @@
public void setClustered(boolean isClustered)
{
}
+
+ public void staticMerge(org.jboss.messaging.core.contract.Queue queue) throws Exception
+ {
+ }
}
// Inner classes -------------------------------------------------
More information about the jboss-cvs-commits
mailing list