qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shus...@apache.org
Subject svn commit: r1187150 [27/43] - in /qpid/branches/QPID-2519: ./ bin/ cpp/ cpp/bindings/ cpp/bindings/qmf/python/ cpp/bindings/qmf/ruby/ cpp/bindings/qmf/tests/ cpp/bindings/qmf2/ cpp/bindings/qmf2/examples/cpp/ cpp/bindings/qmf2/python/ cpp/bindings/qmf...
Date Fri, 21 Oct 2011 01:20:13 GMT
Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueAlertTest.java Fri Oct 21 01:19:00 2011
@@ -20,6 +20,7 @@
  */
 package org.apache.qpid.server.queue;
 
+import org.apache.mina.common.ByteBuffer;
 import org.apache.qpid.AMQException;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.framing.ContentHeaderBody;
@@ -276,7 +277,7 @@ public class AMQQueueAlertTest extends I
 
         ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
         BasicContentHeaderProperties props = new BasicContentHeaderProperties();
-        contentHeaderBody.setProperties(props);
+        contentHeaderBody.properties = props;
         contentHeaderBody.bodySize = size;   // in bytes
         IncomingMessage message = new IncomingMessage(publish);
         message.setContentHeaderBody(contentHeaderBody);
@@ -288,7 +289,7 @@ public class AMQQueueAlertTest extends I
     protected void configure()
     {
         // Increase Alert Check period
-        getConfiguration().setHousekeepingCheckPeriod(200);
+        getConfiguration().setHousekeepingExpiredMessageCheckPeriod(200);
     }
 
     private void sendMessages(AMQChannel channel, long messageCount, final long size) throws AMQException
@@ -311,14 +312,18 @@ public class AMQQueueAlertTest extends I
         {
             messages[i].addContentBodyFrame(new ContentChunk(){
 
-                byte[] _data = new byte[(int)size];
+                ByteBuffer _data = ByteBuffer.allocate((int)size);
+
+                {
+                    _data.limit((int)size);
+                }
 
                 public int getSize()
                 {
                     return (int) size;
                 }
 
-                public byte[] getData()
+                public ByteBuffer getData()
                 {
                     return _data;
                 }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AMQQueueMBeanTest.java Fri Oct 21 01:19:00 2011
@@ -37,6 +37,7 @@ import org.apache.qpid.server.subscripti
 import org.apache.qpid.server.protocol.InternalTestProtocolSession;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
+import org.apache.mina.common.ByteBuffer;
 
 import javax.management.JMException;
 
@@ -274,14 +275,18 @@ public class AMQQueueMBeanTest extends I
 
         msg.addContentBodyFrame(new ContentChunk()
         {
-            byte[] _data = new byte[((int)MESSAGE_SIZE)];
+            ByteBuffer _data = ByteBuffer.allocate((int)MESSAGE_SIZE);
+
+            {
+                _data.limit((int)MESSAGE_SIZE);
+            }
 
             public int getSize()
             {
                 return (int) MESSAGE_SIZE;
             }
 
-            public byte[] getData()
+            public ByteBuffer getData()
             {
                 return _data;
             }
@@ -397,8 +402,8 @@ public class AMQQueueMBeanTest extends I
 
         ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
         contentHeaderBody.bodySize = MESSAGE_SIZE;   // in bytes
-        contentHeaderBody.setProperties(new BasicContentHeaderProperties());
-        ((BasicContentHeaderProperties) contentHeaderBody.getProperties()).setDeliveryMode((byte) (persistent ? 2 : 1));
+        contentHeaderBody.properties = new BasicContentHeaderProperties();
+        ((BasicContentHeaderProperties) contentHeaderBody.properties).setDeliveryMode((byte) (persistent ? 2 : 1));
         IncomingMessage msg = new IncomingMessage(publish);
         msg.setContentHeaderBody(contentHeaderBody);
         return msg;
@@ -436,7 +441,8 @@ public class AMQQueueMBeanTest extends I
                     getSession().getMethodRegistry()
                                                        .getProtocolVersionMethodConverter()
                                                        .convertToContentChunk(
-                                                       new ContentBody(new byte[(int) MESSAGE_SIZE])));
+                                                       new ContentBody(ByteBuffer.allocate((int) MESSAGE_SIZE),
+                                                                       MESSAGE_SIZE)));
 
             AMQMessage m = new AMQMessage(currentMessage.getStoredMessage());
             for(BaseQueue q : currentMessage.getDestinationQueues())

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/AckTest.java Fri Oct 21 01:19:00 2011
@@ -126,7 +126,7 @@ public class AckTest extends InternalBro
             //IncomingMessage msg2 = null;
             BasicContentHeaderProperties b = new BasicContentHeaderProperties();
             ContentHeaderBody cb = new ContentHeaderBody();
-            cb.setProperties(b);
+            cb.properties = b;
 
             if (persistent)
             {

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockAMQQueue.java Fri Oct 21 01:19:00 2011
@@ -29,7 +29,7 @@ import org.apache.qpid.server.subscripti
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.server.management.ManagedObject;
 import org.apache.qpid.server.message.ServerMessage;
-import org.apache.qpid.server.security.AuthorizationHolder;
+import org.apache.qpid.server.security.PrincipalHolder;
 import org.apache.qpid.server.AMQChannel;
 import org.apache.qpid.server.protocol.AMQSessionModel;
 import org.apache.qpid.server.binding.Binding;
@@ -48,7 +48,7 @@ public class MockAMQQueue implements AMQ
     private AMQShortString _name;
     private VirtualHost _virtualhost;
 
-    private AuthorizationHolder _authorizationHolder;
+    private PrincipalHolder _principalHolder;
 
     private AMQSessionModel _exclusiveOwner;
     private AMQShortString _owner;
@@ -536,14 +536,14 @@ public class MockAMQQueue implements AMQ
         return null;  //To change body of implemented methods use File | Settings | File Templates.
     }
 
-    public AuthorizationHolder getAuthorizationHolder()
+    public PrincipalHolder getPrincipalHolder()
     {
-        return _authorizationHolder;
+        return _principalHolder;
     }
 
-    public void setAuthorizationHolder(final AuthorizationHolder authorizationHolder)
+    public void setPrincipalHolder(PrincipalHolder principalHolder)
     {
-        _authorizationHolder = authorizationHolder;
+        _principalHolder = principalHolder;
     }
 
     public AMQSessionModel getExclusiveOwningSession()

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/MockQueueEntry.java Fri Oct 21 01:19:00 2011
@@ -139,7 +139,7 @@ public class MockQueueEntry implements Q
     }
 
 
-    public boolean isRejectedBy(long subscriptionId)
+    public boolean isRejectedBy(Subscription subscription)
     {
 
         return false;
@@ -153,6 +153,13 @@ public class MockQueueEntry implements Q
     }
 
 
+    public void reject(Subscription subscription)
+    {
+
+
+    }
+
+
     public void release()
     {
 
@@ -224,14 +231,4 @@ public class MockQueueEntry implements Q
         _message = msg;
     }
 
-    public boolean isDequeued()
-    {
-        return false;
-    }
-
-    public boolean isDispensed()
-    {
-        return false;
-    }
-
 }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleAMQQueueTest.java Fri Oct 21 01:19:00 2011
@@ -36,16 +36,13 @@ import org.apache.qpid.server.configurat
 import org.apache.qpid.server.exchange.DirectExchange;
 import org.apache.qpid.server.message.AMQMessage;
 import org.apache.qpid.server.message.MessageMetaData;
-import org.apache.qpid.server.message.ServerMessage;
 import org.apache.qpid.server.queue.BaseQueue.PostEnqueueAction;
-import org.apache.qpid.server.queue.SimpleAMQQueue.QueueEntryFilter;
 import org.apache.qpid.server.registry.ApplicationRegistry;
 import org.apache.qpid.server.store.StoredMessage;
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
 import org.apache.qpid.server.subscription.MockSubscription;
 import org.apache.qpid.server.subscription.Subscription;
 import org.apache.qpid.server.txn.AutoCommitTransaction;
-import org.apache.qpid.server.txn.LocalTransaction;
 import org.apache.qpid.server.txn.ServerTransaction;
 import org.apache.qpid.server.util.InternalBrokerBaseCase;
 import org.apache.qpid.server.virtualhost.VirtualHost;
@@ -54,8 +51,6 @@ import org.apache.qpid.server.virtualhos
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
 
 public class SimpleAMQQueueTest extends InternalBrokerBaseCase
 {
@@ -107,7 +102,7 @@ public class SimpleAMQQueueTest extends 
         ApplicationRegistry applicationRegistry = (ApplicationRegistry)ApplicationRegistry.getInstance();
 
         PropertiesConfiguration env = new PropertiesConfiguration();
-        _virtualHost = new VirtualHostImpl(ApplicationRegistry.getInstance(), new VirtualHostConfiguration(getClass().getName(), env), _store);
+        _virtualHost = new VirtualHostImpl(new VirtualHostConfiguration(getClass().getName(), env), _store);
         applicationRegistry.getVirtualHostRegistry().registerVirtualHost(_virtualHost);
 
         _queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(_qname, false, _owner, false, false, _virtualHost, _arguments);
@@ -232,10 +227,10 @@ public class SimpleAMQQueueTest extends 
     }
 
     /**
-     * Tests that a released queue entry is resent to the subscriber.  Verifies also that the
+     * Tests that a re-queued message is resent to the subscriber.  Verifies also that the
      * QueueContext._releasedEntry is reset to null after the entry has been reset.
      */
-    public void testReleasedMessageIsResentToSubscriber() throws Exception
+    public void testRequeuedMessageIsResentToSubscriber() throws Exception
     {
         _queue.registerSubscription(_subscription, false);
 
@@ -258,18 +253,19 @@ public class SimpleAMQQueueTest extends 
         _queue.enqueue(messageB, postEnqueueAction);
         _queue.enqueue(messageC, postEnqueueAction);
 
-        Thread.sleep(150);  // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(150);  // Work done by SubFlushRunner Thread
 
         assertEquals("Unexpected total number of messages sent to subscription", 3, _subscription.getMessages().size());
         assertFalse("Redelivery flag should not be set", queueEntries.get(0).isRedelivered());
         assertFalse("Redelivery flag should not be set", queueEntries.get(1).isRedelivered());
         assertFalse("Redelivery flag should not be set", queueEntries.get(2).isRedelivered());
 
-        /* Now release the first message only, causing it to be requeued */
+        /* Now requeue the first message only */
 
         queueEntries.get(0).release();
+        _queue.requeue(queueEntries.get(0));
 
-        Thread.sleep(150); // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(150); // Work done by SubFlushRunner Thread
 
         assertEquals("Unexpected total number of messages sent to subscription", 4, _subscription.getMessages().size());
         assertTrue("Redelivery flag should now be set", queueEntries.get(0).isRedelivered());
@@ -279,11 +275,11 @@ public class SimpleAMQQueueTest extends 
     }
 
     /**
-     * Tests that a released message that becomes expired is not resent to the subscriber.
+     * Tests that a re-queued message that becomes expired is not resent to the subscriber.
      * This tests ensures that SimpleAMQQueueEntry.getNextAvailableEntry avoids expired entries.
      * Verifies also that the QueueContext._releasedEntry is reset to null after the entry has been reset.
      */
-    public void testReleaseMessageThatBecomesExpiredIsNotRedelivered() throws Exception
+    public void testRequeuedMessageThatBecomesExpiredIsNotRedelivered() throws Exception
     {
         _queue.registerSubscription(_subscription, false);
 
@@ -305,16 +301,17 @@ public class SimpleAMQQueueTest extends 
         _queue.enqueue(messageA, postEnqueueAction);
 
         int subFlushWaitTime = 150;
-        Thread.sleep(subFlushWaitTime); // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(subFlushWaitTime); // Work done by SubFlushRunner Thread
 
         assertEquals("Unexpected total number of messages sent to subscription", 1, _subscription.getMessages().size());
         assertFalse("Redelivery flag should not be set", queueEntries.get(0).isRedelivered());
 
-        /* Wait a little more to be sure that message will have expired, then release the first message only, causing it to be requeued */
+        /* Wait a little more to be sure that message will have expired, then requeue it */
         Thread.sleep(messageExpirationOffset - subFlushWaitTime + 10);
         queueEntries.get(0).release();
+        _queue.requeue(queueEntries.get(0));
 
-        Thread.sleep(subFlushWaitTime); // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(subFlushWaitTime); // Work done by SubFlushRunner Thread
 
         assertTrue("Expecting the queue entry to be now expired", queueEntries.get(0).expired());
         assertEquals("Total number of messages sent should not have changed", 1, _subscription.getMessages().size());
@@ -324,12 +321,12 @@ public class SimpleAMQQueueTest extends 
     }
 
     /**
-     * Tests that if a client releases entries 'out of order' (the order
+     * Tests that if a client requeues messages 'out of order' (the order
      * used by QueueEntryImpl.compareTo) that messages are still resent
      * successfully.  Specifically this test ensures the {@see SimpleAMQQueue#requeue()}
      * can correctly move the _releasedEntry to an earlier position in the QueueEntry list.
      */
-    public void testReleasedOutOfComparableOrderAreRedelivered() throws Exception
+    public void testMessagesRequeuedOutOfComparableOrderAreDelivered() throws Exception
     {
         _queue.registerSubscription(_subscription, false);
 
@@ -352,19 +349,21 @@ public class SimpleAMQQueueTest extends 
         _queue.enqueue(messageB, postEnqueueAction);
         _queue.enqueue(messageC, postEnqueueAction);
 
-        Thread.sleep(150);  // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(150);  // Work done by SubFlushRunner Thread
 
         assertEquals("Unexpected total number of messages sent to subscription", 3, _subscription.getMessages().size());
         assertFalse("Redelivery flag should not be set", queueEntries.get(0).isRedelivered());
         assertFalse("Redelivery flag should not be set", queueEntries.get(1).isRedelivered());
         assertFalse("Redelivery flag should not be set", queueEntries.get(2).isRedelivered());
 
-        /* Now release the third and first message only, causing it to be requeued */
+        /* Now requeue the third and first message only */
 
         queueEntries.get(2).release();
         queueEntries.get(0).release();
+        _queue.requeue(queueEntries.get(2));
+        _queue.requeue(queueEntries.get(0));
 
-        Thread.sleep(150); // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(150); // Work done by SubFlushRunner Thread
 
         assertEquals("Unexpected total number of messages sent to subscription", 5, _subscription.getMessages().size());
         assertTrue("Redelivery flag should now be set", queueEntries.get(0).isRedelivered());
@@ -375,10 +374,10 @@ public class SimpleAMQQueueTest extends 
 
 
     /**
-     * Tests that a release requeues an entry for a queue with multiple subscriptions.  Verifies that a
+     * Tests a requeue for a queue with multiple subscriptions.  Verifies that a
      * requeue resends a message to a <i>single</i> subscriber.
      */
-    public void testReleaseForQueueWithMultipleSubscriptions() throws Exception
+    public void testRequeueForQueueWithMultipleSubscriptions() throws Exception
     {
         MockSubscription subscription1 = new MockSubscription();
         MockSubscription subscription2 = new MockSubscription();
@@ -403,16 +402,66 @@ public class SimpleAMQQueueTest extends 
         _queue.enqueue(messageA, postEnqueueAction);
         _queue.enqueue(messageB, postEnqueueAction);
 
-        Thread.sleep(150);  // Work done by SubFlushRunner/QueueRunner Threads
+        Thread.sleep(150);  // Work done by SubFlushRunner Thread
 
-        assertEquals("Unexpected total number of messages sent to both after enqueue", 2, subscription1.getMessages().size() + subscription2.getMessages().size());
+        assertEquals("Unexpected total number of messages sent to subscription1 after enqueue", 1, subscription1.getMessages().size());
+        assertEquals("Unexpected total number of messages sent to subscription2 after enqueue", 1, subscription2.getMessages().size());
 
-        /* Now release the first message only, causing it to be requeued */
-        queueEntries.get(0).release();  
+        /* Now requeue a message (for any subscription) */
 
-        Thread.sleep(150); // Work done by SubFlushRunner/QueueRunner Threads
+        queueEntries.get(0).release();
+        _queue.requeue((QueueEntryImpl)queueEntries.get(0));
+
+        Thread.sleep(150); // Work done by SubFlushRunner Thread
 
-        assertEquals("Unexpected total number of messages sent to both subscriptions after release", 3, subscription1.getMessages().size() + subscription2.getMessages().size());
+        assertEquals("Unexpected total number of messages sent to all subscriptions after requeue", 3, subscription1.getMessages().size() + subscription2.getMessages().size());
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription1.getQueueContext())._releasedEntry);
+        assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription2.getQueueContext())._releasedEntry);
+    }
+
+    /**
+     * Tests a requeue for a queue with multiple subscriptions.  Verifies that a
+     * subscriber specific requeue resends the message to <i>that</i> subscriber.
+     */
+    public void testSubscriptionSpecificRequeueForQueueWithMultipleSubscriptions() throws Exception
+    {
+        MockSubscription subscription1 = new MockSubscription();
+        MockSubscription subscription2 = new MockSubscription();
+
+        _queue.registerSubscription(subscription1, false);
+        _queue.registerSubscription(subscription2, false);
+
+        final ArrayList<QueueEntry> queueEntries = new ArrayList<QueueEntry>();
+        PostEnqueueAction postEnqueueAction = new PostEnqueueAction()
+        {
+            public void onEnqueue(QueueEntry entry)
+            {
+                queueEntries.add(entry);
+            }
+        };
+
+        AMQMessage messageA = createMessage(new Long(24));
+        AMQMessage messageB = createMessage(new Long(25));
+
+        /* Enqueue two messages */
+
+        _queue.enqueue(messageA, postEnqueueAction);
+        _queue.enqueue(messageB, postEnqueueAction);
+
+        Thread.sleep(150);  // Work done by SubFlushRunner Thread
+
+        assertEquals("Unexpected total number of messages sent to subscription1 after enqueue", 1, subscription1.getMessages().size());
+        assertEquals("Unexpected total number of messages sent to subscription2 after enqueue", 1, subscription2.getMessages().size());
+
+        /* Now requeue a message (for first subscription) */
+
+        queueEntries.get(0).release();
+        _queue.requeue((QueueEntryImpl)queueEntries.get(0), subscription1);
+
+        Thread.sleep(150); // Work done by SubFlushRunner Thread
+
+        assertEquals("Unexpected total number of messages sent to subscription1 after requeue", 2, subscription1.getMessages().size());
+        assertEquals("Unexpected total number of messages sent to subscription2 after requeue", 1, subscription2.getMessages().size());
         assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription1.getQueueContext())._releasedEntry);
         assertNull("releasedEntry should be cleared after requeue processed", ((QueueContext)subscription2.getQueueContext())._releasedEntry);
     }
@@ -611,8 +660,8 @@ public class SimpleAMQQueueTest extends 
         // Create IncomingMessage and nondurable queue
         final IncomingMessage msg = new IncomingMessage(info);
         ContentHeaderBody contentHeaderBody = new ContentHeaderBody();
-        contentHeaderBody.setProperties(new BasicContentHeaderProperties());
-        ((BasicContentHeaderProperties) contentHeaderBody.getProperties()).setDeliveryMode((byte) 2);
+        contentHeaderBody.properties = new BasicContentHeaderProperties();
+        ((BasicContentHeaderProperties) contentHeaderBody.properties).setDeliveryMode((byte) 2);
         msg.setContentHeaderBody(contentHeaderBody);
 
         final ArrayList<BaseQueue> qs = new ArrayList<BaseQueue>();
@@ -658,635 +707,6 @@ public class SimpleAMQQueueTest extends 
     }
 
 
-    /**
-     * processQueue() is used when asynchronously delivering messages to
-     * subscriptions which could not be delivered immediately during the
-     * enqueue() operation.
-     *
-     * A defect within the method would mean that delivery of these messages may
-     * not occur should the Runner stop before all messages have been processed.
-     * Such a defect was discovered when Selectors were used such that one and
-     * only one subscription can/will accept any given messages, but multiple
-     * subscriptions are present, and one of the earlier subscriptions receives
-     * more messages than the others.
-     *
-     * This test is to validate that the processQueue() method is able to
-     * correctly deliver all of the messages present for asynchronous delivery
-     * to subscriptions in such a scenario.
-     */
-    public void testProcessQueueWithUniqueSelectors() throws Exception
-    {
-        TestSimpleQueueEntryListFactory factory = new TestSimpleQueueEntryListFactory();
-        SimpleAMQQueue testQueue = new SimpleAMQQueue("testQueue", false, "testOwner",false,
-                                                      false, _virtualHost, factory, null)
-        {
-            @Override
-            public void deliverAsync(Subscription sub)
-            {
-                // do nothing, i.e prevent deliveries by the SubFlushRunner
-                // when registering the new subscriptions
-            }
-        };
-
-        // retrieve the QueueEntryList the queue creates and insert the test
-        // messages, thus avoiding straight-through delivery attempts during
-        //enqueue() process.
-        QueueEntryList list = factory.getQueueEntryList();
-        assertNotNull("QueueEntryList should have been created", list);
-
-        QueueEntry msg1 = list.add(createMessage(1L));
-        QueueEntry msg2 = list.add(createMessage(2L));
-        QueueEntry msg3 = list.add(createMessage(3L));
-        QueueEntry msg4 = list.add(createMessage(4L));
-        QueueEntry msg5 = list.add(createMessage(5L));
-
-        // Create lists of the entries each subscription should be interested
-        // in.Bias over 50% of the messages to the first subscription so that
-        // the later subscriptions reject them and report being done before
-        // the first subscription as the processQueue method proceeds.
-        List<QueueEntry> msgListSub1 = createEntriesList(msg1, msg2, msg3);
-        List<QueueEntry> msgListSub2 = createEntriesList(msg4);
-        List<QueueEntry> msgListSub3 = createEntriesList(msg5);
-
-        MockSubscription sub1 = new MockSubscription(msgListSub1);
-        MockSubscription sub2 = new MockSubscription(msgListSub2);
-        MockSubscription sub3 = new MockSubscription(msgListSub3);
-
-        // register the subscriptions
-        testQueue.registerSubscription(sub1, false);
-        testQueue.registerSubscription(sub2, false);
-        testQueue.registerSubscription(sub3, false);
-
-        //check that no messages have been delivered to the
-        //subscriptions during registration
-        assertEquals("No messages should have been delivered yet", 0, sub1.getMessages().size());
-        assertEquals("No messages should have been delivered yet", 0, sub2.getMessages().size());
-        assertEquals("No messages should have been delivered yet", 0, sub3.getMessages().size());
-
-        // call processQueue to deliver the messages
-        testQueue.processQueue(new QueueRunner(testQueue, 1)
-        {
-            @Override
-            public void run()
-            {
-                // we dont actually want/need this runner to do any work
-                // because we we are already doing it!
-            }
-        });
-
-        // check expected messages delivered to correct consumers
-        verifyRecievedMessages(msgListSub1, sub1.getMessages());
-        verifyRecievedMessages(msgListSub2, sub2.getMessages());
-        verifyRecievedMessages(msgListSub3, sub3.getMessages());
-    }
-
-    /**
-     * Tests that dequeued message is not present in the list returned form
-     * {@link SimpleAMQQueue#getMessagesOnTheQueue()}
-     */
-    public void testGetMessagesOnTheQueueWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-
-        // send test messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // get messages on the queue
-        List<QueueEntry> entries = _queue.getMessagesOnTheQueue();
-
-        // assert queue entries
-        assertEquals(messageNumber - 1, entries.size());
-        int expectedId = 0;
-        for (int i = 0; i < messageNumber - 1; i++)
-        {
-            Long id = ((AMQMessage) entries.get(i).getMessage()).getMessageId();
-            if (i == dequeueMessageIndex)
-            {
-                assertFalse("Message with id " + dequeueMessageIndex
-                        + " was dequeued and should not be returned by method getMessagesOnTheQueue!",
-                        new Long(expectedId).equals(id));
-                expectedId++;
-            }
-            assertEquals("Expected message with id " + expectedId + " but got message with id " + id,
-                    new Long(expectedId), id);
-            expectedId++;
-        }
-    }
-
-    /**
-     * Tests that dequeued message is not present in the list returned form
-     * {@link SimpleAMQQueue#getMessagesOnTheQueue(QueueEntryFilter)}
-     */
-    public void testGetMessagesOnTheQueueByQueueEntryFilterWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-
-        // send test messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // get messages on the queue with filter accepting all available messages
-        List<QueueEntry> entries = _queue.getMessagesOnTheQueue(new QueueEntryFilter()
-        {
-            public boolean accept(QueueEntry entry)
-            {
-                return true;
-            }
-
-            public boolean filterComplete()
-            {
-                return false;
-            }
-        });
-
-        // assert entries on the queue
-        assertEquals(messageNumber - 1, entries.size());
-        int expectedId = 0;
-        for (int i = 0; i < messageNumber - 1; i++)
-        {
-            Long id = ((AMQMessage) entries.get(i).getMessage()).getMessageId();
-            if (i == dequeueMessageIndex)
-            {
-                assertFalse("Message with id " + dequeueMessageIndex
-                        + " was dequeued and should not be returned by method getMessagesOnTheQueue!",
-                        new Long(expectedId).equals(id));
-                expectedId++;
-            }
-            assertEquals("Expected message with id " + expectedId + " but got message with id " + id,
-                    new Long(expectedId), id);
-            expectedId++;
-        }
-    }
-
-    /**
-     * Tests that dequeued message is not copied as part of invocation of
-     * {@link SimpleAMQQueue#copyMessagesToAnotherQueue(long, long, String, StoreContext)}
-     */
-    public void testCopyMessagesWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-        String anotherQueueName = "testQueue2";
-
-        // put test messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // create another queue
-        SimpleAMQQueue queue = createQueue(anotherQueueName);
-
-        // create transaction
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getTransactionLog());
-
-        // copy messages into another queue
-        _queue.copyMessagesToAnotherQueue(0, messageNumber, anotherQueueName, txn);
-
-        // commit transaction
-        txn.commit();
-
-        // get messages on another queue
-        List<QueueEntry> entries = queue.getMessagesOnTheQueue();
-
-        // assert another queue entries
-        assertEquals(messageNumber - 1, entries.size());
-        int expectedId = 0;
-        for (int i = 0; i < messageNumber - 1; i++)
-        {
-            Long id = ((AMQMessage)entries.get(i).getMessage()).getMessageId();
-            if (i == dequeueMessageIndex)
-            {
-                assertFalse("Message with id " + dequeueMessageIndex
-                        + " was dequeued and should not been copied into another queue!",
-                        new Long(expectedId).equals(id));
-                expectedId++;
-            }
-            assertEquals("Expected message with id " + expectedId + " but got message with id " + id,
-                    new Long(expectedId), id);
-            expectedId++;
-        }
-    }
-
-    /**
-     * Tests that dequeued message is not moved as part of invocation of
-     * {@link SimpleAMQQueue#moveMessagesToAnotherQueue(long, long, String, StoreContext)}
-     */
-    public void testMovedMessagesWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-        String anotherQueueName = "testQueue2";
-
-        // put messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // create another queue
-        SimpleAMQQueue queue = createQueue(anotherQueueName);
-
-        // create transaction
-        ServerTransaction txn = new LocalTransaction(_queue.getVirtualHost().getTransactionLog());
-
-        // move messages into another queue
-        _queue.moveMessagesToAnotherQueue(0, messageNumber, anotherQueueName, txn);
-
-        // commit transaction
-        txn.commit();
-
-        // get messages on another queue
-        List<QueueEntry> entries = queue.getMessagesOnTheQueue();
-
-        // assert another queue entries
-        assertEquals(messageNumber - 1, entries.size());
-        int expectedId = 0;
-        for (int i = 0; i < messageNumber - 1; i++)
-        {
-            Long id = ((AMQMessage)entries.get(i).getMessage()).getMessageId();
-            if (i == dequeueMessageIndex)
-            {
-                assertFalse("Message with id " + dequeueMessageIndex
-                        + " was dequeued and should not been copied into another queue!",
-                        new Long(expectedId).equals(id));
-                expectedId++;
-            }
-            assertEquals("Expected message with id " + expectedId + " but got message with id " + id,
-                    new Long(expectedId), id);
-            expectedId++;
-        }
-    }
-
-    /**
-     * Tests that messages in given range including dequeued one are deleted
-     * from the queue on invocation of
-     * {@link SimpleAMQQueue#removeMessagesFromQueue(long, long, StoreContext)}
-     */
-    public void testRemoveMessagesFromQueueWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-
-        // put messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // remove messages
-        _queue.removeMessagesFromQueue(0, messageNumber);
-
-        // get queue entries
-        List<QueueEntry> entries = _queue.getMessagesOnTheQueue();
-
-        // assert queue entries
-        assertNotNull("Null is returned from getMessagesOnTheQueue", entries);
-        assertEquals("Queue should be empty", 0, entries.size());
-    }
-
-    /**
-     * Tests that dequeued message on the top is not accounted and next message
-     * is deleted from the queue on invocation of
-     * {@link SimpleAMQQueue#deleteMessageFromTop(StoreContext)}
-     */
-    public void testDeleteMessageFromTopWithDequeuedEntryOnTop()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 0;
-
-        // put messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message on top
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        //delete message from top
-        _queue.deleteMessageFromTop();
-
-        //get queue netries
-        List<QueueEntry> entries = _queue.getMessagesOnTheQueue();
-
-        // assert queue entries
-        assertNotNull("Null is returned from getMessagesOnTheQueue", entries);
-        assertEquals("Expected " + (messageNumber - 2) + " number of messages  but recieved " + entries.size(),
-                messageNumber - 2, entries.size());
-        assertEquals("Expected first entry with id 2", new Long(2),
-                ((AMQMessage) entries.get(0).getMessage()).getMessageId());
-    }
-
-    /**
-     * Tests that all messages including dequeued one are deleted from the queue
-     * on invocation of {@link SimpleAMQQueue#clearQueue(StoreContext)}
-     */
-    public void testClearQueueWithDequeuedEntry()
-    {
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-
-        // put messages into a test queue
-        enqueueGivenNumberOfMessages(_queue, messageNumber);
-
-        // dequeue message on a test queue
-        dequeueMessage(_queue, dequeueMessageIndex);
-
-        // clean queue
-        try
-        {
-            _queue.clearQueue();
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to clear queue:" + e.getMessage());
-        }
-
-        // get queue entries
-        List<QueueEntry> entries = _queue.getMessagesOnTheQueue();
-
-        // assert queue entries
-        assertNotNull(entries);
-        assertEquals(0, entries.size());
-    }
-
-    /**
-     * Tests whether dequeued entry is sent to subscriber in result of
-     * invocation of {@link SimpleAMQQueue#processQueue(QueueRunner)}
-     */
-    public void testProcessQueueWithDequeuedEntry()
-    {
-        // total number of messages to send
-        int messageNumber = 4;
-        int dequeueMessageIndex = 1;
-
-        // create queue with overridden method deliverAsync
-        SimpleAMQQueue testQueue = new SimpleAMQQueue(new AMQShortString("test"), false,
-                new AMQShortString("testOwner"), false, false, _virtualHost, null)
-        {
-            @Override
-            public void deliverAsync(Subscription sub)
-            {
-                // do nothing
-            }
-        };
-
-        // put messages
-        List<QueueEntry> entries = enqueueGivenNumberOfMessages(testQueue, messageNumber);
-
-        // dequeue message
-        dequeueMessage(testQueue, dequeueMessageIndex);
-
-        // latch to wait for message receipt
-        final CountDownLatch latch = new CountDownLatch(messageNumber -1);
-
-        // create a subscription
-        MockSubscription subscription = new MockSubscription()
-        {
-            /**
-             * Send a message and decrement latch
-             */
-            public void send(QueueEntry msg) throws AMQException
-            {
-                super.send(msg);
-                latch.countDown();
-            }
-        };
-
-        try
-        {
-            // subscribe
-            testQueue.registerSubscription(subscription, false);
-
-            // process queue
-            testQueue.processQueue(new QueueRunner(testQueue, 1)
-            {
-                public void run()
-                {
-                    // do nothing
-                }
-            });
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to process queue:" + e.getMessage());
-        }
-        // wait up to 1 minute for message receipt
-        try
-        {
-            latch.await(1, TimeUnit.MINUTES);
-        }
-        catch (InterruptedException e1)
-        {
-            Thread.currentThread().interrupt();
-        }
-        List<QueueEntry> expected = createEntriesList(entries.get(0), entries.get(2), entries.get(3));
-        verifyRecievedMessages(expected, subscription.getMessages());
-    }
-
-    /**
-     * Tests that entry in dequeued state are not enqueued and not delivered to subscription
-     */
-    public void testEqueueDequeuedEntry()
-    {
-        // create a queue where each even entry is considered a dequeued
-        SimpleAMQQueue queue = new SimpleAMQQueue(new AMQShortString("test"), false, new AMQShortString("testOwner"),
-                false, false, _virtualHost, new QueueEntryListFactory()
-                {
-                    public QueueEntryList createQueueEntryList(AMQQueue queue)
-                    {
-                        /**
-                         * Override SimpleQueueEntryList to create a dequeued
-                         * entries for messages with even id
-                         */
-                        return new SimpleQueueEntryList(queue)
-                        {
-                            /**
-                             * Entries with even message id are considered
-                             * dequeued!
-                             */
-                            protected QueueEntryImpl createQueueEntry(final ServerMessage message)
-                            {
-                                return new QueueEntryImpl(this, message)
-                                {
-                                    public boolean isDequeued()
-                                    {
-                                        return (((AMQMessage) message).getMessageId().longValue() % 2 == 0);
-                                    }
-
-                                    public boolean isDispensed()
-                                    {
-                                        return (((AMQMessage) message).getMessageId().longValue() % 2 == 0);
-                                    }
-
-                                    public boolean isAvailable()
-                                    {
-                                        return !(((AMQMessage) message).getMessageId().longValue() % 2 == 0);
-                                    }
-                                };
-                            }
-                        };
-                    }
-                }, null);
-        // create a subscription
-        MockSubscription subscription = new MockSubscription();
-
-        // register subscription
-        try
-        {
-            queue.registerSubscription(subscription, false);
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to register subscription:" + e.getMessage());
-        }
-
-        // put test messages into a queue
-        putGivenNumberOfMessages(queue, 4);
-
-        // assert received messages
-        List<QueueEntry> messages = subscription.getMessages();
-        assertEquals("Only 2 messages should be returned", 2, messages.size());
-        assertEquals("ID of first message should be 1", new Long(1),
-                ((AMQMessage) messages.get(0).getMessage()).getMessageId());
-        assertEquals("ID of second message should be 3", new Long(3),
-                ((AMQMessage) messages.get(1).getMessage()).getMessageId());
-    }
-
-    /**
-     * A helper method to create a queue with given name
-     *
-     * @param name
-     *            queue name
-     * @return queue
-     */
-    private SimpleAMQQueue createQueue(String name)
-    {
-        SimpleAMQQueue queue = null;
-        try
-        {
-            AMQShortString queueName = new AMQShortString(name);
-            AMQShortString ownerName = new AMQShortString(name + "Owner");
-            queue = (SimpleAMQQueue) AMQQueueFactory.createAMQQueueImpl(queueName, false, ownerName, false, false,
-                    _virtualHost, _arguments);
-        }
-        catch (AMQException e)
-        {
-            fail("Failure to create a queue:" + e.getMessage());
-        }
-        assertNotNull("Queue was not created", queue);
-        return queue;
-    }
-
-    /**
-     * A helper method to put given number of messages into queue
-     * <p>
-     * All messages are asserted that they are present on queue
-     *
-     * @param queue
-     *            queue to put messages into
-     * @param messageNumber
-     *            number of messages to put into queue
-     */
-    private List<QueueEntry> enqueueGivenNumberOfMessages(AMQQueue queue, int messageNumber)
-    {
-        putGivenNumberOfMessages(queue, messageNumber);
-
-        // make sure that all enqueued messages are on the queue
-        List<QueueEntry> entries = queue.getMessagesOnTheQueue();
-        assertEquals(messageNumber, entries.size());
-        for (int i = 0; i < messageNumber; i++)
-        {
-            assertEquals(new Long(i), ((AMQMessage)entries.get(i).getMessage()).getMessageId());
-        }
-        return entries;
-    }
-
-    /**
-     * A helper method to put given number of messages into queue
-     * <p>
-     * Queue is not checked if messages are added into queue
-     *
-     * @param queue
-     *            queue to put messages into
-     * @param messageNumber
-     *            number of messages to put into queue
-     * @param queue
-     * @param messageNumber
-     */
-    private void putGivenNumberOfMessages(AMQQueue queue, int messageNumber)
-    {
-        for (int i = 0; i < messageNumber; i++)
-        {
-            // Create message
-            Long messageId = new Long(i);
-            AMQMessage message = null;
-            try
-            {
-                message = createMessage(messageId);
-            }
-            catch (AMQException e)
-            {
-                fail("Failure to create a test message:" + e.getMessage());
-            }
-            // Put message on queue
-            try
-            {
-                queue.enqueue(message);
-            }
-            catch (AMQException e)
-            {
-                fail("Failure to put message on queue:" + e.getMessage());
-            }
-        }
-    }
-
-    /**
-     * A helper method to dequeue an entry on queue with given index
-     *
-     * @param queue
-     *            queue to dequeue message on
-     * @param dequeueMessageIndex
-     *            entry index to dequeue.
-     */
-    private QueueEntry dequeueMessage(AMQQueue queue, int dequeueMessageIndex)
-    {
-        List<QueueEntry> entries = queue.getMessagesOnTheQueue();
-        QueueEntry entry = entries.get(dequeueMessageIndex);
-        entry.acquire();
-        entry.dequeue();
-        assertTrue(entry.isDequeued());
-        return entry;
-    }
-
-    private List<QueueEntry> createEntriesList(QueueEntry... entries)
-    {
-        ArrayList<QueueEntry> entriesList = new ArrayList<QueueEntry>();
-        for (QueueEntry entry : entries)
-        {
-            entriesList.add(entry);
-        }
-        return entriesList;
-    }
-
-    private void verifyRecievedMessages(List<QueueEntry> expected,
-            List<QueueEntry> delivered)
-    {
-        assertEquals("Consumer did not receive the expected number of messages",
-                    expected.size(), delivered.size());
-
-        for (QueueEntry msg : expected)
-        {
-            assertTrue("Consumer did not recieve msg: "
-                    + msg.getMessage().getMessageNumber(), delivered.contains(msg));
-        }
-    }
-
     public class TestMessage extends AMQMessage
     {
         private final long _tag;
@@ -1327,20 +747,4 @@ public class SimpleAMQQueueTest extends 
         AMQMessage messageA = new TestMessage(id, id, info);
         return messageA;
     }
-
-    class TestSimpleQueueEntryListFactory implements QueueEntryListFactory
-    {
-        QueueEntryList _list;
-
-        public QueueEntryList createQueueEntryList(AMQQueue queue)
-        {
-            _list = new SimpleQueueEntryList(queue);
-            return _list;
-        }
-
-        public QueueEntryList getQueueEntryList()
-        {
-            return _list;
-        }
-    }
 }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/queue/SimpleQueueEntryListTest.java Fri Oct 21 01:19:00 2011
@@ -23,7 +23,6 @@ package org.apache.qpid.server.queue;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import org.apache.qpid.AMQException;
 import org.apache.qpid.server.message.AMQMessage;
 
 import junit.framework.TestCase;
@@ -156,55 +155,5 @@ public class SimpleQueueEntryListTest ex
         
         assertEquals("Count should have been equal",count,remainingMessages.size());
     }
-
-    public void testDequedMessagedNotPresentInIterator()
-    {
-        int numberOfMessages = 10;
-        SimpleQueueEntryList entryList = new SimpleQueueEntryList(new MockAMQQueue("test"));
-        QueueEntry[] entries = new QueueEntry[numberOfMessages];
-
-        for(int i = 0; i < numberOfMessages ; i++)
-        {
-            AMQMessage message = null;;
-            try
-            {
-                message = new MockAMQMessage(i);
-            }
-            catch (AMQException e)
-            {
-                fail("Failure to create a mock message:" + e.getMessage());
-            }
-            QueueEntry entry = entryList.add(message);
-            assertNotNull("QE should not be null", entry);
-            entries[i]= entry;
-        }
-
-        // dequeue all even messages
-        for (QueueEntry queueEntry : entries)
-        {
-            long i = ((AMQMessage)queueEntry.getMessage()).getMessageId().longValue();
-            if (i%2 == 0)
-            {
-                queueEntry.acquire();
-                queueEntry.dequeue();
-            }
-        }
-
-        // iterate and check that dequeued messages are not returned by iterator
-        QueueEntryIterator it = entryList.iterator();
-        int counter = 0;
-        int i = 1;
-        while (it.advance())
-        {
-            QueueEntry entry = it.getNode();
-            Long id = ((AMQMessage)entry.getMessage()).getMessageId();
-            assertEquals("Expected message with id " + i + " but got message with id "
-                    + id, new Long(i), id);
-            counter++;
-            i += 2;
-        }
-        int expectedNumber = numberOfMessages / 2;
-        assertEquals("Expected  " + expectedNumber + " number of entries in iterator but got " + counter,
-                expectedNumber, counter);
-    }
+    
 }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/security/auth/rmi/RMIPasswordAuthenticatorTest.java Fri Oct 21 01:19:00 2011
@@ -20,125 +20,188 @@
  */
 package org.apache.qpid.server.security.auth.rmi;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
 import java.util.Collections;
 
 import javax.management.remote.JMXPrincipal;
 import javax.security.auth.Subject;
-import javax.security.sasl.SaslException;
-import javax.security.sasl.SaslServer;
+
+import org.apache.qpid.server.security.auth.database.Base64MD5PasswordFilePrincipalDatabase;
+import org.apache.qpid.server.security.auth.database.PlainPasswordFilePrincipalDatabase;
 
 import junit.framework.TestCase;
 
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
-import org.apache.qpid.server.security.auth.AuthenticationResult;
-import org.apache.qpid.server.security.auth.AuthenticationResult.AuthenticationStatus;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
-
-/**
- * Tests the RMIPasswordAuthenticator and its collaboration with the AuthenticationManager.
- *
- */
 public class RMIPasswordAuthenticatorTest extends TestCase
 {
     private final String USERNAME = "guest";
     private final String PASSWORD = "guest";
+    private final String B64_MD5HASHED_PASSWORD = "CE4DQ6BIb/BVMN9scFyLtA==";
     private RMIPasswordAuthenticator _rmipa;
-    private String[] _credentials;
+    
+    private Base64MD5PasswordFilePrincipalDatabase _md5Pd;
+    private File _md5PwdFile;
+    
+    private PlainPasswordFilePrincipalDatabase _plainPd;
+    private File _plainPwdFile;
+
+    private Subject testSubject;
 
     protected void setUp() throws Exception
     {
         _rmipa = new RMIPasswordAuthenticator();
         
-        _credentials = new String[] {USERNAME, PASSWORD};
-    }
-
-    /**
-     * Tests a successful authentication.  Ensures that a populated read-only subject it returned.
-     */
-    public void testAuthenticationSuccess()
-    {
-        final Subject expectedSubject = new Subject(true,
+        _md5Pd = new Base64MD5PasswordFilePrincipalDatabase();
+        _md5PwdFile = createTempPasswordFile(this.getClass().getName()+"md5pwd", USERNAME, B64_MD5HASHED_PASSWORD);
+        _md5Pd.setPasswordFile(_md5PwdFile.getAbsolutePath());
+        
+        _plainPd = new PlainPasswordFilePrincipalDatabase();
+        _plainPwdFile = createTempPasswordFile(this.getClass().getName()+"plainpwd", USERNAME, PASSWORD);
+        _plainPd.setPasswordFile(_plainPwdFile.getAbsolutePath());
+        
+        testSubject = new Subject(true,
                 Collections.singleton(new JMXPrincipal(USERNAME)),
                 Collections.EMPTY_SET,
                 Collections.EMPTY_SET);
+    }
+    
+    private File createTempPasswordFile(String filenamePrefix, String user, String password)
+    {
+        try
+        {
+            File testFile = File.createTempFile(filenamePrefix,"tmp");
+            testFile.deleteOnExit();
 
-        _rmipa.setAuthenticationManager(createTestAuthenticationManager(true, null));
+            BufferedWriter writer = new BufferedWriter(new FileWriter(testFile));
 
+            writer.write(user + ":" + password);
+            writer.newLine();
 
-        Subject newSubject = _rmipa.authenticate(_credentials);
-        assertTrue("Subject must be readonly", newSubject.isReadOnly());
-        assertTrue("Returned subject does not equal expected value",
-                newSubject.equals(expectedSubject));
+            writer.flush();
+            writer.close();
+
+            return testFile;
+        }
+        catch (IOException e)
+        {
+            fail("Unable to create temporary test password file." + e.getMessage());
+        }
 
+        return null;
     }
+
+    
+    //********** Test Methods *********//
+    
     
-    /**
-     * Tests a unsuccessful authentication.
-     */
-    public void testUsernameOrPasswordInvalid()
+    public void testAuthenticate()
     {
-        _rmipa.setAuthenticationManager(createTestAuthenticationManager(false, null));
-        
+        String[] credentials;
+        Subject newSubject;
+
+        // Test when no PD has been set
         try
         {
-            _rmipa.authenticate(_credentials);
-            fail("Exception not thrown");
+            credentials = new String[]{USERNAME, PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
+            fail("SecurityException expected due to lack of principal database");
         }
         catch (SecurityException se)
         {
             assertEquals("Unexpected exception message",
-                    RMIPasswordAuthenticator.INVALID_CREDENTIALS, se.getMessage());
-
+                    RMIPasswordAuthenticator.UNABLE_TO_LOOKUP, se.getMessage());
         }
-    }
 
-    /**
-     * Tests case where authentication system itself fails.
-     */
-    public void testAuthenticationFailure()
-    {
-        final Exception mockAuthException = new Exception("Mock Auth system failure");
-        _rmipa.setAuthenticationManager(createTestAuthenticationManager(false, mockAuthException));
+        //The PrincipalDatabase's are tested primarily by their own tests, but
+        //minimal tests are done here to exercise their usage in this area.
+        
+        // Test correct passwords are verified with an MD5 PD
+        try
+        {
+            _rmipa.setPrincipalDatabase(_md5Pd);
+            credentials = new String[]{USERNAME, PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
+            assertTrue("Returned subject does not equal expected value", 
+                    newSubject.equals(testSubject));
+        }
+        catch (Exception e)
+        {
+            fail("Unexpected Exception:" + e.getMessage());
+        }
 
+        // Test incorrect passwords are not verified with an MD5 PD
         try
         {
-            _rmipa.authenticate(_credentials);
-            fail("Exception not thrown");
+            credentials = new String[]{USERNAME, PASSWORD+"incorrect"};
+            newSubject = _rmipa.authenticate(credentials);
+            fail("SecurityException expected due to incorrect password");
         }
         catch (SecurityException se)
         {
-            assertEquals("Initial cause not found", mockAuthException, se.getCause());
+            assertEquals("Unexpected exception message",
+                    RMIPasswordAuthenticator.INVALID_CREDENTIALS, se.getMessage());
+        }
+        
+        // Test non-existent accounts are not verified with an MD5 PD
+        try
+        {
+            credentials = new String[]{USERNAME+"invalid", PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
+            fail("SecurityException expected due to non-existant account");
+        }
+        catch (SecurityException se)
+        {
+            assertEquals("Unexpected exception message",
+                    RMIPasswordAuthenticator.INVALID_CREDENTIALS, se.getMessage());
         }
-    }
 
+        // Test correct passwords are verified with a Plain PD
+        try
+        {
+            _rmipa.setPrincipalDatabase(_plainPd);
+            credentials = new String[]{USERNAME, PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
+            assertTrue("Returned subject does not equal expected value", 
+                    newSubject.equals(testSubject));
+        }
+        catch (Exception e)
+        {
+            fail("Unexpected Exception");
+        }
 
-    /**
-     * Tests case where authentication manager is not set.
-     */
-    public void testNullAuthenticationManager()
-    {
+        // Test incorrect passwords are not verified with a Plain PD
         try
         {
-            _rmipa.authenticate(_credentials);
-            fail("SecurityException expected due to lack of authentication manager");
+            credentials = new String[]{USERNAME, PASSWORD+"incorrect"};
+            newSubject = _rmipa.authenticate(credentials);
+            fail("SecurityException expected due to incorrect password");
         }
         catch (SecurityException se)
         {
             assertEquals("Unexpected exception message",
-                    RMIPasswordAuthenticator.UNABLE_TO_LOOKUP, se.getMessage());
+                    RMIPasswordAuthenticator.INVALID_CREDENTIALS, se.getMessage());
+        }
+        
+        // Test non-existent accounts are not verified with an Plain PD
+        try
+        {
+            credentials = new String[]{USERNAME+"invalid", PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
+            fail("SecurityException expected due to non existant account");
+        }
+        catch (SecurityException se)
+        {
+            assertEquals("Unexpected exception message",
+                    RMIPasswordAuthenticator.INVALID_CREDENTIALS, se.getMessage());
         }
-    }
 
-    /**
-     * Tests case where arguments are non-Strings..
-     */
-    public void testWithNonStringArrayArgument()
-    {
         // Test handling of non-string credential's
-        final Object[] objCredentials = new Object[]{USERNAME, PASSWORD};
         try
         {
-             _rmipa.authenticate(objCredentials);
+            Object[] objCredentials = new Object[]{USERNAME, PASSWORD};
+            newSubject = _rmipa.authenticate(objCredentials);
             fail("SecurityException expected due to non string[] credentials");
         }
         catch (SecurityException se)
@@ -146,18 +209,12 @@ public class RMIPasswordAuthenticatorTes
             assertEquals("Unexpected exception message",
                     RMIPasswordAuthenticator.SHOULD_BE_STRING_ARRAY, se.getMessage());
         }
-    }
-
-    /**
-     * Tests case where there are too many, too few or null arguments.
-     */
-    public void testWithIllegalNumberOfArguments()
-    {
-        // Test handling of incorrect number of credentials
+        
+        // Test handling of incorrect number of credential's
         try
         {
-            _credentials = new String[]{USERNAME, PASSWORD, PASSWORD};
-            _rmipa.authenticate(_credentials);
+            credentials = new String[]{USERNAME, PASSWORD, PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
             fail("SecurityException expected due to supplying wrong number of credentials");
         }
         catch (SecurityException se)
@@ -166,12 +223,12 @@ public class RMIPasswordAuthenticatorTes
                     RMIPasswordAuthenticator.SHOULD_HAVE_2_ELEMENTS, se.getMessage());
         }
         
-        // Test handling of null credentials
+        // Test handling of null credential's
         try
         {
             //send a null array
-            _credentials = null;
-            _rmipa.authenticate(_credentials);
+            credentials = null;
+            newSubject = _rmipa.authenticate(credentials);
             fail("SecurityException expected due to not supplying an array of credentials");
         }
         catch (SecurityException se)
@@ -183,8 +240,8 @@ public class RMIPasswordAuthenticatorTes
         try
         {
             //send a null password
-            _credentials = new String[]{USERNAME, null};
-            _rmipa.authenticate(_credentials);
+            credentials = new String[]{USERNAME, null};
+            newSubject = _rmipa.authenticate(credentials);
             fail("SecurityException expected due to sending a null password");
         }
         catch (SecurityException se)
@@ -196,8 +253,8 @@ public class RMIPasswordAuthenticatorTes
         try
         {
             //send a null username
-            _credentials = new String[]{null, PASSWORD};
-            _rmipa.authenticate(_credentials);
+            credentials = new String[]{null, PASSWORD};
+            newSubject = _rmipa.authenticate(credentials);
             fail("SecurityException expected due to sending a null username");
         }
         catch (SecurityException se)
@@ -207,54 +264,4 @@ public class RMIPasswordAuthenticatorTes
         }
     }
 
-    private AuthenticationManager createTestAuthenticationManager(final boolean successfulAuth, final Exception exception)
-    {
-        return new AuthenticationManager()
-        {
-            public void configure(ConfigurationPlugin config)
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public void initialise()
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public void close()
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public String getMechanisms()
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public SaslServer createSaslServer(String mechanism, String localFQDN) throws SaslException
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public AuthenticationResult authenticate(SaslServer server, byte[] response)
-            {
-                throw new UnsupportedOperationException();
-            }
-
-            public AuthenticationResult authenticate(String username, String password)
-            {
-                if (exception != null) {
-                    return new AuthenticationResult(AuthenticationStatus.ERROR, exception);
-                }
-                else if (successfulAuth)
-                {
-                    return new AuthenticationResult(new Subject());
-                }
-                else
-                {
-                    return new AuthenticationResult(AuthenticationStatus.CONTINUE);
-                }
-            }
-        };
-    }
 }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/MessageStoreTest.java Fri Oct 21 01:19:00 2011
@@ -122,7 +122,6 @@ public class MessageStoreTest extends In
             }
             catch (Exception e)
             {
-                e.printStackTrace();
                 fail(e.getMessage());
             }
         }
@@ -590,7 +589,7 @@ public class MessageStoreTest extends In
         headerBody.classId = BasicConsumeBodyImpl.CLASS_ID;
         headerBody.bodySize = 0;
 
-        headerBody.setProperties(properties);
+        headerBody.properties = properties;
 
         try
         {

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/ReferenceCountingTest.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/ReferenceCountingTest.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/ReferenceCountingTest.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/store/ReferenceCountingTest.java Fri Oct 21 01:19:00 2011
@@ -102,7 +102,7 @@ public class ReferenceCountingTest exten
         ContentHeaderBody chb = new ContentHeaderBody();
         BasicContentHeaderProperties bchp = new BasicContentHeaderProperties();
         bchp.setDeliveryMode((byte)2);
-        chb.setProperties(bchp);
+        chb.properties = bchp;
         return chb;
     }
 

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/subscription/MockSubscription.java Fri Oct 21 01:19:00 2011
@@ -22,7 +22,6 @@ package org.apache.qpid.server.subscript
 */
 
 import java.util.ArrayList;
-import java.util.List;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
@@ -46,7 +45,6 @@ public class MockSubscription implements
     private State _state = State.ACTIVE;
     private ArrayList<QueueEntry> messages = new ArrayList<QueueEntry>();
     private final Lock _stateChangeLock = new ReentrantLock();
-    private List<QueueEntry> _acceptEntries = null;
 
     private final QueueEntry.SubscriptionAcquiredState _owningState = new QueueEntry.SubscriptionAcquiredState(this);
     private final QueueEntry.SubscriptionAssignedState _assignedState = new QueueEntry.SubscriptionAssignedState(this);
@@ -56,15 +54,6 @@ public class MockSubscription implements
     // Create a simple ID that increments for ever new Subscription
     private final long _subscriptionID = idGenerator.getAndIncrement();
 
-    public MockSubscription()
-    {
-    }
-
-    public MockSubscription(List<QueueEntry> acceptEntries)
-    {
-        _acceptEntries = acceptEntries;
-    }
-
     public void close()
     {
         _closed = true;
@@ -130,15 +119,8 @@ public class MockSubscription implements
         _stateChangeLock.lock();
     }
 
-    public boolean hasInterest(QueueEntry entry)
+    public boolean hasInterest(QueueEntry msg)
     {
-        if(_acceptEntries != null)
-        {
-            //simulate selector behaviour, only signal
-            //interest in the dictated queue entries
-            return _acceptEntries.contains(entry);
-        }
-
         return true;
     }
 

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockAction.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockAction.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockAction.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockAction.java Fri Oct 21 01:19:00 2011
@@ -32,11 +32,13 @@ class MockAction implements Action
     private boolean _rollbackFired = false;
     private boolean _postCommitFired = false;
 
+    @Override
     public void postCommit()
     {
         _postCommitFired = true;
     }
 
+    @Override
     public void onRollback()
     {
         _rollbackFired = true;

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockServerMessage.java Fri Oct 21 01:19:00 2011
@@ -46,56 +46,67 @@ class MockServerMessage implements Serve
         this.persistent = persistent;
     }
 
+    @Override
     public boolean isPersistent()
     {
         return persistent;
     }
 
+    @Override
     public MessageReference newReference()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public boolean isImmediate()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public long getSize()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public SessionConfig getSessionConfig()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public String getRoutingKey()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public AMQMessageHeader getMessageHeader()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public long getExpiration()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public int getContent(ByteBuffer buf, int offset)
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public long getArrivalTime()
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public Long getMessageNumber()
     {
         return 0L;

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/txn/MockStoreTransaction.java Fri Oct 21 01:19:00 2011
@@ -61,6 +61,7 @@ class MockStoreTransaction implements Tr
         return _state;
     }
 
+    @Override
     public void enqueueMessage(TransactionLogResource queue, Long messageId) throws AMQStoreException
     {
         if (_throwExceptionOnQueueOp)
@@ -82,6 +83,8 @@ class MockStoreTransaction implements Tr
         return _numberOfEnqueuedMessages;
     }
 
+
+    @Override
     public void dequeueMessage(TransactionLogResource queue, Long messageId) throws AMQStoreException
     {
         if (_throwExceptionOnQueueOp)
@@ -92,16 +95,19 @@ class MockStoreTransaction implements Tr
         _numberOfDequeuedMessages++;
     }
 
+    @Override
     public void commitTran() throws AMQStoreException
     {
         _state = TransactionState.COMMITTED;
     }
 
+    @Override
     public StoreFuture commitTranAsync() throws AMQStoreException
     {
         throw new NotImplementedException();
     }
 
+    @Override
     public void abortTran() throws AMQStoreException
     {
         _state = TransactionState.ABORTED;
@@ -111,11 +117,14 @@ class MockStoreTransaction implements Tr
     {
         return new TransactionLog()
         {
+    
+            @Override
             public void configureTransactionLog(String name, TransactionLogRecoveryHandler recoveryHandler,
                     Configuration storeConfiguration, LogSubject logSubject) throws Exception
             {
             }
-
+    
+            @Override
             public Transaction newTransaction()
             {
                 storeTransaction.setState(TransactionState.STARTED);

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/InternalBrokerBaseCase.java Fri Oct 21 01:19:00 2011
@@ -44,13 +44,14 @@ import org.apache.qpid.server.store.Mess
 import org.apache.qpid.server.store.TestableMemoryMessageStore;
 import org.apache.qpid.server.virtualhost.VirtualHost;
 import org.apache.qpid.test.utils.QpidTestCase;
+import org.apache.qpid.util.MockChannel;
 
 
 public class InternalBrokerBaseCase extends QpidTestCase
 {
     private IApplicationRegistry _registry;
     private MessageStore _messageStore;
-    private AMQChannel _channel;
+    private MockChannel _channel;
     private InternalTestProtocolSession _session;
     private VirtualHost _virtualHost;
     private AMQQueue _queue;
@@ -110,7 +111,7 @@ public class InternalBrokerBaseCase exte
         _session = new InternalTestProtocolSession(_virtualHost);
         CurrentActor.set(_session.getLogActor());
 
-        _channel = new AMQChannel(_session, 1, _messageStore);
+        _channel = new MockChannel(_session, 1, _messageStore);
 
         _session.addChannel(_channel);
     }
@@ -242,7 +243,7 @@ public class InternalBrokerBaseCase exte
             //Make Message Persistent
             properties.setDeliveryMode((byte) 2);
 
-            _headerBody.setProperties(properties);
+            _headerBody.properties = properties;
 
             channel.publishContentHeader(_headerBody);
         }
@@ -282,12 +283,12 @@ public class InternalBrokerBaseCase exte
         _messageStore = messageStore;
     }
 
-    public AMQChannel getChannel()
+    public MockChannel getChannel()
     {
         return _channel;
     }
 
-    public void setChannel(AMQChannel channel)
+    public void setChannel(MockChannel channel)
     {
         _channel = channel;
     }

Modified: qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/test/java/org/apache/qpid/server/util/TestApplicationRegistry.java Fri Oct 21 01:19:00 2011
@@ -20,72 +20,27 @@
  */
 package org.apache.qpid.server.util;
 
-import java.util.Properties;
-
 import org.apache.commons.configuration.ConfigurationException;
 import org.apache.qpid.server.configuration.ServerConfiguration;
-import org.apache.qpid.server.logging.NullRootMessageLogger;
-import org.apache.qpid.server.logging.actors.BrokerActor;
-import org.apache.qpid.server.logging.actors.CurrentActor;
-import org.apache.qpid.server.logging.actors.GenericActor;
-import org.apache.qpid.server.configuration.plugins.ConfigurationPlugin;
 import org.apache.qpid.server.registry.ApplicationRegistry;
-import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabase;
-import org.apache.qpid.server.security.auth.manager.AuthenticationManager;
-import org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager;
+import org.apache.qpid.server.security.auth.database.PropertiesPrincipalDatabaseManager;
+
+import java.util.Properties;
+
 
 public class TestApplicationRegistry extends ApplicationRegistry
 {
-
     public TestApplicationRegistry(ServerConfiguration config) throws ConfigurationException
     {
         super(config);
     }
 
-    @Override
-    public void initialise() throws Exception
-    {
-        CurrentActor.setDefault(new BrokerActor(new NullRootMessageLogger()));
-        GenericActor.setDefaultMessageLogger(new NullRootMessageLogger());
-        super.initialise();
-    }
-
-    /**
-     * @see org.apache.qpid.server.registry.ApplicationRegistry#createAuthenticationManager()
-     */
-    @Override
-    protected AuthenticationManager createAuthenticationManager() throws ConfigurationException
+    protected void createDatabaseManager(ServerConfiguration configuration) throws Exception
     {
-        final Properties users = new Properties();
+        Properties users = new Properties();
         users.put("guest","guest");
         users.put("admin","admin");
-
-        final PropertiesPrincipalDatabase ppd = new PropertiesPrincipalDatabase(users);
-
-        AuthenticationManager pdam =  new PrincipalDatabaseAuthenticationManager()
-        {
-
-            /**
-             * @see org.apache.qpid.server.security.auth.manager.PrincipalDatabaseAuthenticationManager#configure(org.apache.qpid.server.configuration.plugins.ConfigurationPlugin)
-             */
-            @Override
-            public void configure(ConfigurationPlugin config) throws ConfigurationException
-            {
-                // We don't pass configuration to this test instance.
-            }
-
-            @Override
-            public void initialise()
-            {
-                setPrincipalDatabase(ppd);
-
-                super.initialise();
-            }
-        };
-
-        pdam.initialise();
-
-        return pdam;
+        _databaseManager = new PropertiesPrincipalDatabaseManager("testPasswordFile", users);
     }
 
 }

Modified: qpid/branches/QPID-2519/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java
URL: http://svn.apache.org/viewvc/qpid/branches/QPID-2519/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java?rev=1187150&r1=1187149&r2=1187150&view=diff
==============================================================================
--- qpid/branches/QPID-2519/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java (original)
+++ qpid/branches/QPID-2519/java/broker/src/velocity/java/org/apache/qpid/server/logging/GenerateLogMessages.java Fri Oct 21 01:19:00 2011
@@ -481,7 +481,7 @@ public class GenerateLogMessages
                     // Only check the text inside the braces '{}'
                     int typeIndexEnd = parametersString[index].indexOf("}", typeIndex);
                     String typeString = parametersString[index].substring(typeIndex, typeIndexEnd);
-                    if (typeString.contains("number") || typeString.contains("choice"))
+                    if (typeString.contains("number"))
                     {
                         type = "Number";
                     }



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message