[Jboss-cvs] JBossAS SVN: r57046 - in trunk/testsuite/src: main/org/jboss/test/jbossmq main/org/jboss/test/jbossmq/support main/org/jboss/test/jbossmq/test resources/org/jboss/test resources/org/jboss/test/jbossmq resources/org/jboss/test/jbossmq/test
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 21 01:08:35 EDT 2006
Author: adrian at jboss.org
Date: 2006-09-21 01:08:25 -0400 (Thu, 21 Sep 2006)
New Revision: 57046
Added:
trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTest.java
trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTestDelegate.java
trunk/testsuite/src/main/org/jboss/test/jbossmq/support/
trunk/testsuite/src/main/org/jboss/test/jbossmq/support/MockClientIL.java
trunk/testsuite/src/main/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.java
trunk/testsuite/src/main/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.java
trunk/testsuite/src/resources/org/jboss/test/jbossmq/
trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/
trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.xml
trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.xml
Log:
Tests for latest JBossMQ fixes.
Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTest.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTest.java 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTest.java 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,86 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmq;
+
+import javax.jms.Connection;
+import javax.jms.ConnectionFactory;
+
+import org.jboss.mq.SpyQueue;
+import org.jboss.mq.server.JMSDestinationManager;
+import org.jboss.mq.server.JMSQueue;
+import org.jboss.test.AbstractTestDelegate;
+import org.jboss.test.kernel.junit.MicrocontainerTest;
+
+/**
+ * JBossMQMicrocontainerTest.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossMQMicrocontainerTest extends MicrocontainerTest
+{
+ /**
+ * Get the test delegate
+ *
+ * @param clazz the test class
+ * @return the delegate
+ * @throws Exception for any error
+ */
+ public static AbstractTestDelegate getDelegate(Class clazz) throws Exception
+ {
+ return new JBossMQMicrocontainerTestDelegate(clazz);
+ }
+
+ /**
+ * Create a new JBossMQMicrocontainer test
+ *
+ * @param name the test name
+ */
+ public JBossMQMicrocontainerTest(String name)
+ {
+ super(name);
+ }
+
+ protected ConnectionFactory getConnectionFactory() throws Exception
+ {
+ return (ConnectionFactory) getBean("ConnectionFactory");
+ }
+
+ protected Connection createConnection() throws Exception
+ {
+ return getConnectionFactory().createConnection();
+ }
+
+ protected JMSDestinationManager getJMSServer() throws Exception
+ {
+ return (JMSDestinationManager) getBean("JMSServer");
+ }
+
+ protected SpyQueue createQueue(String name) throws Exception
+ {
+ SpyQueue queue = new SpyQueue(name);
+ JMSDestinationManager server = getJMSServer();
+ JMSQueue realQueue = new JMSQueue(queue, null, server, server.getParameters());
+ server.addDestination(realQueue);
+ return queue;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTestDelegate.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTestDelegate.java 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/JBossMQMicrocontainerTestDelegate.java 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,44 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmq;
+
+import org.jboss.test.kernel.junit.MicrocontainerTestDelegate;
+
+/**
+ * JBossMQMicrocontainerTestDelegate.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JBossMQMicrocontainerTestDelegate extends MicrocontainerTestDelegate
+{
+ /**
+ * Create a new JBossMQMicrocontainerTestDelegate.
+ *
+ * @param clazz the class
+ * @throws Exception for any error
+ */
+ public JBossMQMicrocontainerTestDelegate(Class clazz) throws Exception
+ {
+ super(clazz);
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/support/MockClientIL.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/support/MockClientIL.java 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/support/MockClientIL.java 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,79 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2005, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmq.support;
+
+import java.util.ArrayList;
+
+import org.jboss.mq.ReceiveRequest;
+import org.jboss.mq.SpyDestination;
+import org.jboss.mq.il.ClientIL;
+
+import EDU.oswego.cs.dl.util.concurrent.SynchronizedBoolean;
+
+/**
+ * MonitorCloseTestClientIL.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class MockClientIL implements ClientIL
+{
+ public SynchronizedBoolean closed = new SynchronizedBoolean(false);
+
+ public ArrayList deletedDestinations = new ArrayList();
+
+ public ArrayList pongs = new ArrayList();
+
+ public ArrayList received = new ArrayList();
+
+ public void close() throws Exception
+ {
+ closed.set(true);
+ }
+
+ public void deleteTemporaryDestination(SpyDestination dest) throws Exception
+ {
+ deletedDestinations.add(dest);
+ }
+
+ public void pong(long serverTime) throws Exception
+ {
+ pongs.add(new Long(serverTime));
+ }
+
+ public void receive(ReceiveRequest[] messages) throws Exception
+ {
+ for (int i = 0; i < messages.length; ++i)
+ received.add(messages);
+ }
+
+ public ArrayList getReceivedMessages()
+ {
+ ArrayList result = new ArrayList();
+ for (int i = 0; i < received.size(); ++i)
+ {
+ ReceiveRequest request = (ReceiveRequest) received.get(i);
+ result.add(request.message);
+ }
+ return result;
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.java 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.java 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmq.test;
+
+import org.jboss.mq.ConnectionToken;
+import org.jboss.mq.il.ClientIL;
+import org.jboss.mq.server.ClientMonitorInterceptor;
+import org.jboss.test.jbossmq.JBossMQMicrocontainerTest;
+import org.jboss.test.jbossmq.support.MockClientIL;
+
+/**
+ * ClientMonitorConnectionRaceUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class ClientMonitorConnectionRaceUnitTestCase extends JBossMQMicrocontainerTest
+{
+ public ClientMonitorConnectionRaceUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testRace() throws Exception
+ {
+ ClientMonitorInterceptor monitor = (ClientMonitorInterceptor) getBean("ClientMonitorInterceptor");
+ ClientIL client = new MockClientIL();
+
+ // First ping without an id
+ ConnectionToken original = new ConnectionToken(null, client, "session");
+ monitor.ping(original, System.currentTimeMillis());
+ assertNotNull(monitor.peekClientStats(original));
+
+ // Ping with an id
+ ConnectionToken withID = new ConnectionToken("test", client, "session");
+ monitor.ping(withID, System.currentTimeMillis());
+ assertNull("Token without id should be removed", monitor.peekClientStats(original));
+ assertNotNull(monitor.peekClientStats(withID));
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.java 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/main/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.java 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,99 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.jbossmq.test;
+
+import javax.jms.DeliveryMode;
+
+import org.jboss.mq.AcknowledgementRequest;
+import org.jboss.mq.ConnectionToken;
+import org.jboss.mq.SpyMessage;
+import org.jboss.mq.SpyQueue;
+import org.jboss.mq.Subscription;
+import org.jboss.mq.TransactionRequest;
+import org.jboss.mq.server.JMSDestinationManager;
+import org.jboss.test.jbossmq.JBossMQMicrocontainerTest;
+import org.jboss.test.jbossmq.support.MockClientIL;
+
+/**
+ * NackWithRollbackUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class NackWithRollbackUnitTestCase extends JBossMQMicrocontainerTest
+{
+ public NackWithRollbackUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testNackWithRollback() throws Exception
+ {
+ SpyQueue queue = createQueue("testQueue");
+
+ JMSDestinationManager server = getJMSServer();
+ MockClientIL client = new MockClientIL();
+ ConnectionToken dc = new ConnectionToken("test", client, "session");
+ server.setEnabled(dc, true);
+
+ // Add a message
+ SpyMessage send = new SpyMessage();
+ send.setJMSDestination(queue);
+ send.setJMSDeliveryMode(DeliveryMode.NON_PERSISTENT);
+ long ts = System.currentTimeMillis();
+ send.setJMSTimestamp(ts);
+ send.setJMSPriority(5);
+ send.setJMSMessageID("Message1");
+ server.addMessage(dc, send);
+
+ // Subscribe to the queue
+ Subscription sub = new Subscription();
+ sub.connectionToken = dc;
+ sub.subscriptionId = 1;
+ sub.destination = queue;
+ sub.noLocal = false;
+ server.subscribe(dc, sub);
+
+ // Get the message
+ SpyMessage received = server.receive(dc, sub.subscriptionId, -1);
+ assertNotNull(received);
+
+ // Prepare a nack
+ TransactionRequest t = new TransactionRequest();
+ t.xid = new Long(1);
+ t.requestType = TransactionRequest.TWO_PHASE_COMMIT_PREPARE_REQUEST;
+ received.createAcknowledgementRequest(sub.subscriptionId);
+ AcknowledgementRequest nack = received.getAcknowledgementRequest(false);
+ t.acks = new AcknowledgementRequest[] { nack };
+ server.transact(dc, t);
+
+ // Rollback
+ t = new TransactionRequest();
+ t.xid = new Long(1);
+ t.requestType = TransactionRequest.TWO_PHASE_COMMIT_ROLLBACK_REQUEST;
+ server.transact(dc, t);
+
+ // Should re-receive
+ received = server.receive(dc, sub.subscriptionId, -1);
+ assertNotNull(received);
+ }
+}
Added: trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.xml 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/ClientMonitorConnectionRaceUnitTestCase.xml 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="PersistenceManager" class="org.jboss.mq.pm.none.PersistenceManager"/>
+
+ <bean name="StateManager" class="org.jboss.mq.sm.none.NullStateManager"/>
+
+ <bean name="MessageCache" class="org.jboss.mq.kernel.MessageCache">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ </bean>
+
+ <bean name="DestinationManager" class="org.jboss.mq.kernel.DestinationManager">
+ <property name="persistenceManagerInstance"><inject bean="PersistenceManager"/></property>
+ <property name="stateManagerInstance"><inject bean="StateManager"/></property>
+ <property name="messageCacheInstance"><inject bean="MessageCache"/></property>
+ </bean>
+
+ <bean name="JMSServer" class="org.jboss.mq.server.JMSDestinationManager">
+ <constructor factoryMethod="getInterceptor">
+ <factory bean="DestinationManager"/>
+ </constructor>
+ </bean>
+
+ <bean name="ClientMonitor" class="org.jboss.mq.server.jmx.ClientMonitorInterceptor">
+ <property name="clientTimeout">5000000</property> <!-- DOESN'T HAPPEN! -->
+ </bean>
+
+ <bean name="ClientMonitorInterceptor" class="org.jboss.mq.server.ClientMonitorInterceptor">
+ <constructor factoryMethod="getInterceptor">
+ <factory bean="ClientMonitor"/>
+ </constructor>
+ <property name="next"><inject bean="JMSServer"/></property>
+ </bean>
+
+</deployment>
Added: trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.xml 2006-09-21 05:07:35 UTC (rev 57045)
+++ trunk/testsuite/src/resources/org/jboss/test/jbossmq/test/NackWithRollbackUnitTestCase.xml 2006-09-21 05:08:25 UTC (rev 57046)
@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<deployment xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="urn:jboss:bean-deployer bean-deployer_1_0.xsd"
+ xmlns="urn:jboss:bean-deployer">
+
+ <bean name="PersistenceManager" class="org.jboss.mq.pm.none.PersistenceManager"/>
+
+ <bean name="StateManager" class="org.jboss.mq.sm.none.NullStateManager"/>
+
+ <bean name="MessageCache" class="org.jboss.mq.kernel.MessageCache">
+ <property name="persistenceManager"><inject bean="PersistenceManager"/></property>
+ </bean>
+
+ <bean name="DestinationManager" class="org.jboss.mq.kernel.DestinationManager">
+ <property name="persistenceManagerInstance"><inject bean="PersistenceManager"/></property>
+ <property name="stateManagerInstance"><inject bean="StateManager"/></property>
+ <property name="messageCacheInstance"><inject bean="MessageCache"/></property>
+ </bean>
+
+ <bean name="JMSServer" class="org.jboss.mq.server.JMSDestinationManager">
+ <constructor factoryMethod="getInterceptor">
+ <factory bean="DestinationManager"/>
+ </constructor>
+ </bean>
+
+</deployment>
More information about the jboss-cvs-commits
mailing list