KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > jms > MockTopicSession


1 package com.mockobjects.jms;
2
3 import com.mockobjects.*;
4 import javax.jms.*;
5
6 public class MockTopicSession extends MockSession implements TopicSession{
7     private final ReturnValue topicToReturn = new ReturnValue("topic");
8     private ExpectationValue topicName = new ExpectationValue("topicName");
9     private ExpectationCounter createTopicCalls =
10         new ExpectationCounter("createTopicCalls");
11     private final ReturnValue topicPublisherToReturn = new ReturnValue("topic publisher");
12     private final ReturnValue topicSubscriberToReturn = new ReturnValue("topic subscriber");
13
14     public void setupCreateTopic(Topic topicToReturn){
15         this.topicToReturn.setValue(topicToReturn);
16     }
17
18     public void setExpectedTopicName(String JavaDoc topicName){
19         this.topicName.setExpected(topicName);
20     }
21
22     public void setupCreateTopicCalls(int createTopicCalls){
23         this.createTopicCalls.setExpected(createTopicCalls);
24     }
25
26     public TopicSubscriber createDurableSubscriber(Topic topic, String JavaDoc name)
27     throws JMSException{
28         return (TopicSubscriber)topicSubscriberToReturn.getValue();
29     }
30
31     public TopicSubscriber createDurableSubscriber(Topic topic, String JavaDoc name,
32     String JavaDoc messsageSelecter, boolean noLocal) throws JMSException{
33         return (TopicSubscriber)topicSubscriberToReturn.getValue();
34     }
35
36     public void setupCreatePublisher(TopicPublisher topicPublisherToReturn){
37         this.topicPublisherToReturn.setValue(topicPublisherToReturn);
38     }
39
40     public TopicPublisher createPublisher(Topic topic) throws JMSException{
41         return (TopicPublisher)topicPublisherToReturn.getValue();
42     }
43
44     public void setupTopicSubscriber(TopicSubscriber topicSubscriberToReturn){
45         this.topicSubscriberToReturn.setValue(topicSubscriberToReturn);
46     }
47
48     public TopicSubscriber createSubscriber(Topic topic) throws JMSException{
49         return (TopicSubscriber)topicSubscriberToReturn.getValue();
50     }
51
52     public TopicSubscriber createSubscriber(Topic topic,
53     String JavaDoc messsageSelecter, boolean noLocal) throws JMSException{
54         return (TopicSubscriber)topicSubscriberToReturn.getValue();
55     }
56
57     public TemporaryTopic createTemporaryTopic() throws JMSException{
58         notImplemented();
59         return null;
60     }
61
62     public Topic createTopic(String JavaDoc topicName) throws JMSException{
63         this.topicName.setActual(topicName);
64         this.createTopicCalls.inc();
65         return (Topic)topicToReturn.getValue();
66     }
67
68     public void unsubscribe(String JavaDoc topicName) throws JMSException{
69         notImplemented();
70     }
71
72 }
73
Popular Tags