KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.mockobjects.jms;
2
3 import com.mockobjects.*;
4
5 import javax.jms.*;
6
7 public class MockQueueSession extends MockSession implements QueueSession {
8
9     private final ExpectationValue mySendingQueue = new ExpectationValue("MockQueueSession.createSender");
10     private final ExpectationValue myReceivingQueue = new ExpectationValue("MockQueueSession.createReceiver");
11     private final ExpectationValue messageSelector = new ExpectationValue("message selector");
12     private final ExpectationValue queue = new ExpectationValue("queue");
13
14     private final ReturnValue queueToReturn = new ReturnValue("queue");
15     private final ReturnValue myReceiver = new ReturnValue("reciever");
16     private final ReturnValue mySender = new ReturnValue("reciever");
17     private final ReturnValue myTemporaryQueue = new ReturnValue("reciever");
18     private final ReturnValue queueBrowser = new ReturnValue("queue browser");
19
20     public QueueBrowser createBrowser(Queue queue) throws JMSException {
21         this.queue.setActual(queue);
22         return (QueueBrowser) queueBrowser.getValue();
23     }
24
25     public void setExpectedQueue(Queue queue) {
26         this.queue.setExpected(queue);
27     }
28
29     public void setupCreateQueueBrowser(QueueBrowser browser) {
30         this.queueBrowser.setValue(browser);
31     }
32
33     public QueueBrowser createBrowser(Queue queue, String JavaDoc messageSelector) throws JMSException {
34         notImplemented();
35         return null;
36     }
37
38     public void setupCreateQueue(Queue queue) {
39         this.queueToReturn.setValue(queue);
40     }
41
42     public Queue createQueue(String JavaDoc queueName) throws JMSException {
43         throwExceptionIfAny();
44         return (Queue) queueToReturn.getValue();
45     }
46
47     public QueueReceiver createReceiver(Queue queue) throws JMSException {
48         throwExceptionIfAny();
49         myReceivingQueue.setActual(queue);
50         return (QueueReceiver) myReceiver.getValue();
51     }
52
53     public QueueReceiver createReceiver(Queue queue, String JavaDoc messageSelector) throws JMSException {
54         this.messageSelector.setActual(messageSelector);
55         myReceivingQueue.setActual(queue);
56         throwExceptionIfAny();
57         return (QueueReceiver) myReceiver.getValue();
58     }
59
60     public QueueSender createSender(Queue queue) throws JMSException {
61         mySendingQueue.setActual(queue);
62         throwExceptionIfAny();
63         return (QueueSender) mySender.getValue();
64     }
65
66     public TemporaryQueue createTemporaryQueue() throws JMSException {
67         throwExceptionIfAny();
68         return (TemporaryQueue) myTemporaryQueue.getValue();
69     }
70
71     public void setExpectedSendingQueue(Queue queue) {
72         mySendingQueue.setExpected(queue);
73     }
74
75     public void setExpectedReceivingQueue(Queue queue) {
76         myReceivingQueue.setExpected(queue);
77     }
78
79     public void setupReceiver(QueueReceiver receiver) {
80         myReceiver.setValue(receiver);
81     }
82
83     public void setupSender(QueueSender sender) {
84         mySender.setValue(sender);
85     }
86
87     public void setupTemporaryQueue(MockTemporaryQueue temporaryQueue) {
88         myTemporaryQueue.setValue(temporaryQueue);
89     }
90
91     public void setExpectedMessageSelector(String JavaDoc messageSelector) {
92         this.messageSelector.setExpected(messageSelector);
93     }
94 }
95
Popular Tags