KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > messaging > ExclusiveChannelTestCase


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7 package org.jboss.test.messaging;
8
9 import org.jboss.messaging.channel.plugins.handler.ChannelHandler;
10 import org.jboss.messaging.channel.plugins.handler.ExclusiveChannelHandler;
11 import org.jboss.messaging.interfaces.Consumer;
12 import org.jboss.messaging.memory.MemoryMessageSet;
13 import org.jboss.test.jms.BaseJMSTest;
14
15 /**
16  * A basic test
17  *
18  * @author <a HREF="adrian@jboss.org>Adrian Brock</a>
19  * @version $Revision: 1.1 $
20  */

21 public class ExclusiveChannelTestCase extends BaseJMSTest
22 {
23    // Constants -----------------------------------------------------
24

25    // Attributes ----------------------------------------------------
26

27    // Static --------------------------------------------------------
28

29    // Constructors --------------------------------------------------
30

31    public ExclusiveChannelTestCase(String JavaDoc name)
32    {
33       super(name);
34    }
35
36    // Public --------------------------------------------------------
37

38    public void testSomething()
39       throws Exception JavaDoc
40    {
41       ChannelHandler handler = getExclusiveChannelHandler();
42       Consumer consumer = new AcceptAllConsumer();
43       TestMessageReference t1 = new TestMessageReference();
44       handler.addMessage(t1);
45       TestMessageReference t2 = new TestMessageReference();
46       handler.addMessage(t2);
47       TestMessageReference r = (TestMessageReference) handler.removeMessage(consumer);
48       assertEquals(t1.getMessageID(), r.getMessageID());
49       r = (TestMessageReference) handler.removeMessage(consumer);
50       assertEquals(t2.getMessageID(), r.getMessageID());
51    }
52
53    // Protected ------------------------------------------------------
54

55    protected ChannelHandler getExclusiveChannelHandler()
56    {
57       MemoryMessageSet mms = new MemoryMessageSet(new TestMessageReference.TestMessageReferenceComparator());
58       return new ExclusiveChannelHandler(mms);
59    }
60    
61    // Package Private ------------------------------------------------
62

63    // Private --------------------------------------------------------
64

65    // Inner Classes --------------------------------------------------
66
}
67
Popular Tags