Author: aidan
Date: Mon Jan 19 07:56:57 2009
New Revision: 735735

URL: http://svn.apache.org/viewvc?rev=735735&view=rev
Log:
QPID-1573: Move unit tests that were living in systests into appropriate 
module. Fix up a few bugs in other tests that this exposed. 

Added:
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
      - copied, changed from r734435, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
      - copied, changed from r734435, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
      - copied unchanged from r735666, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
      - copied unchanged from r735666, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
    qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/plugins/PluginTest.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/plugins/PluginTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
      - copied, changed from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MockIoSession.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MockIoSession.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/MockProtocolSession.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MockProtocolSession.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/SkeletonMessageStore.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SkeletonMessageStore.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
      - copied unchanged from r734435, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/store/TestReferenceCounting.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/txn/TxnBufferTest.java
      - copied unchanged from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/txn/TxnBufferTest.java
Removed:
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/AbstractHeadersExchangeTestBase.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/exchange/HeadersExchangeTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/plugins/PluginTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/AMQProtocolSessionMBeanTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MockIoSession.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/AckTest.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/queue/MockProtocolSession.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/SkeletonMessageStore.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestMemoryMessageStore.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/store/TestReferenceCounting.java
    
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/txn/TxnBufferTest.java
Modified:
    
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java

Copied: 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
 (from r734435, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java)
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java?p2=qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java&p1=qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java&r1=734435&r2=735735&rev=735735&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/AMQBrokerManagerMBeanTest.java
 Mon Jan 19 07:56:57 2009
@@ -28,7 +28,6 @@
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.registry.IApplicationRegistry;
 import org.apache.qpid.server.virtualhost.VirtualHost;
-import org.apache.qpid.client.transport.TransportConnection;
 
 public class AMQBrokerManagerMBeanTest extends TestCase
 {

Copied: 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
 (from r734435, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java)
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java?p2=qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java&p1=qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java&r1=734435&r2=735735&rev=735735&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/ack/TxAckTest.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/ack/TxAckTest.java
 Mon Jan 19 07:56:57 2009
@@ -68,6 +68,14 @@
         combined.update(1, false);//should be ignored
         combined.update(10, false);
     }
+    
+    @Override
+    protected void tearDown() throws Exception
+    {
+       individual.stop();
+       multiple.stop();
+       combined.stop();
+    }
 
     public void testPrepare() throws AMQException
     {
@@ -102,6 +110,7 @@
         private final List<Long> _acked;
         private final List<Long> _unacked;
         private StoreContext _storeContext = new StoreContext();
+               private AMQQueue _queue;
 
         Scenario(int messageCount, List<Long> acked, List<Long> unacked) 
throws Exception
         {
@@ -109,9 +118,8 @@
                                                                           
_storeContext, null,
                                                                           new 
LinkedList<RequiredDeliveryException>()
             );
-            AMQQueue queue =
-                    AMQQueueFactory.createAMQQueueImpl(new 
AMQShortString("test"), false, null, false, new VirtualHost("test", new 
MemoryMessageStore()),
-                                                       null);
+            _queue = AMQQueueFactory.createAMQQueueImpl(new 
AMQShortString("test"), false, null, false, new VirtualHost("test", new 
MemoryMessageStore()),
+                                                          null);
 
             for (int i = 0; i < messageCount; i++)
             {
@@ -147,7 +155,7 @@
                 };
 
                 TestMessage message = new TestMessage(deliveryTag, i, info, 
txnContext.getStoreContext());
-                _map.add(deliveryTag, queue.enqueue(new StoreContext(), 
message));
+                _map.add(deliveryTag, _queue.enqueue(new StoreContext(), 
message));
             }
             _acked = acked;
             _unacked = unacked;
@@ -201,6 +209,11 @@
             keys.removeAll(_map.getDeliveryTags());
             assertTrue("Expected messages with following tags to still be in 
map: " + keys, keys.isEmpty());
         }
+        
+        public void stop()
+        {
+               _queue.stop();
+        }
     }
 
     private static AMQMessageHandle createMessageHandle(final long messageId, 
final MessagePublishInfo publishBody)

Copied: 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
 (from r734440, 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java)
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java?p2=qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java&p1=qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java&r1=734440&r2=735735&rev=735735&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/protocol/MaxChannelsTest.java
 Mon Jan 19 07:56:57 2009
@@ -33,38 +33,54 @@
 /** Test class to test MBean operations for AMQMinaProtocolSession. */
 public class MaxChannelsTest extends TestCase
 {
-//    private MessageStore _messageStore = new SkeletonMessageStore();
+       private IApplicationRegistry _appRegistry;
+       private AMQMinaProtocolSession _session;
 
     public void testChannels() throws Exception
     {
-        IApplicationRegistry appRegistry = ApplicationRegistry.getInstance();
-        AMQMinaProtocolSession _protocolSession = new 
AMQMinaProtocolSession(new MockIoSession(),
-                                                                             
appRegistry.getVirtualHostRegistry(),
-                                                                             
new AMQCodecFactory(true),
-                                                                             
null);
-        
_protocolSession.setVirtualHost(appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
+        _session = new AMQMinaProtocolSession(new MockIoSession(), _appRegistry
+                               .getVirtualHostRegistry(), new 
AMQCodecFactory(true), null);
+        
_session.setVirtualHost(_appRegistry.getVirtualHostRegistry().getVirtualHost("test"));
 
         // check the channel count is correct
-        int channelCount = _protocolSession.getChannels().size();
+        int channelCount = _session.getChannels().size();
         assertEquals("Initial channel count wrong", 0, channelCount);
 
         long maxChannels = 10L;
-        _protocolSession.setMaximumNumberOfChannels(maxChannels);
-        assertEquals("Number of channels not correctly set.", new 
Long(maxChannels), _protocolSession.getMaximumNumberOfChannels());
+        _session.setMaximumNumberOfChannels(maxChannels);
+        assertEquals("Number of channels not correctly set.", new 
Long(maxChannels), _session.getMaximumNumberOfChannels());
 
 
         try
         {
             for (long currentChannel = 0L; currentChannel < maxChannels; 
currentChannel++)
             {
-                _protocolSession.addChannel(new AMQChannel(_protocolSession, 
(int) currentChannel, null));
+                _session.addChannel(new AMQChannel(_session, (int) 
currentChannel, null));
             }
         }
         catch (AMQException e)
         {
             assertEquals("Wrong exception recevied.", e.getErrorCode(), 
AMQConstant.NOT_ALLOWED);
         }
-        assertEquals("Maximum number of channels not set.", new 
Long(maxChannels), new Long(_protocolSession.getChannels().size()));
+        assertEquals("Maximum number of channels not set.", new 
Long(maxChannels), new Long(_session.getChannels().size()));
+    }
+    
+    @Override
+    public void setUp()
+    {
+        _appRegistry = ApplicationRegistry.getInstance(1);
+    }
+    
+    @Override
+    public void tearDown()
+    {
+       try {
+                       _session.closeSession();
+               } catch (AMQException e) {
+                       // Yikes
+                       fail(e.getMessage());
+               }
+       ApplicationRegistry.remove(1);
     }
 
 }

Modified: 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
URL: 
http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java?rev=735735&r1=735734&r2=735735&view=diff
==============================================================================
--- 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
 (original)
+++ 
qpid/trunk/qpid/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueThreadPoolTest.java
 Mon Jan 19 07:56:57 2009
@@ -35,6 +35,7 @@
 
     public void test() throws AMQException
     {
+        assertEquals("References exist before start!", 0, 
ReferenceCountingExecutorService.getInstance().getReferenceCount());
         VirtualHost test = 
ApplicationRegistry.getInstance(1).getVirtualHostRegistry().getVirtualHost("test");
 
         try
@@ -43,8 +44,8 @@
                                                                                
        new AMQShortString("owner"),
                                                                                
        false, test, null);
 
-            assertTrue("Creation did not start Pool.", 
!ReferenceCountingExecutorService.getInstance().getPool().isShutdown());
-
+            assertFalse("Creation did not start Pool.", 
ReferenceCountingExecutorService.getInstance().getPool().isShutdown());
+            
             queue.stop();
 
             assertEquals("References still exist", 0, 
ReferenceCountingExecutorService.getInstance().getReferenceCount());


Reply via email to