Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/mockobjects/jms/MockSession.java


1   package com.mockobjects.jms;
2   
3   import com.mockobjects.*;
4   import java.io.Serializable;
5   import javax.jms.*;
6   
7   public class MockSession extends MockObject implements Session {
8   
9       protected ExpectationCounter myCloseCalls =
10          new ExpectationCounter("MockSession.close");
11      protected ExpectationCounter myCreateTextMessageCalls =
12          new ExpectationCounter("MockSession.createTextMessage");
13  
14      private TextMessage myTextMessage = new MockTextMessage();
15      private JMSException myException;
16      private ObjectMessage objectMessageToReturn;
17  
18      public void setupCreateObjectMessage(ObjectMessage objectMessageToReturn){
19          this.objectMessageToReturn = objectMessageToReturn;
20      }
21  
22      public ObjectMessage createObjectMessage() throws JMSException {
23          return objectMessageToReturn;
24      }
25  
26      public ObjectMessage createObjectMessage(Serializable object)
27      throws JMSException {
28          return objectMessageToReturn;
29      }
30  
31      public void rollback() throws JMSException {
32          notImplemented();
33      }
34  
35      public void setupTextMessage(TextMessage textMessage) {
36          myTextMessage = textMessage;
37      }
38  
39      public BytesMessage createBytesMessage() throws JMSException {
40          notImplemented();
41          return null;
42      }
43  
44      public MapMessage createMapMessage() throws JMSException {
45          notImplemented();
46          return null;
47      }
48  
49      public Message createMessage() throws JMSException {
50          notImplemented();
51          return null;
52      }
53  
54      public boolean getTransacted() throws JMSException {
55          notImplemented();
56          return false;
57      }
58  
59      public void recover() throws JMSException {
60          notImplemented();
61      }
62  
63      public void close() throws JMSException {
64          throwExceptionIfAny();
65          myCloseCalls.inc();
66      }
67  
68      public void commit() throws JMSException {
69          notImplemented();
70      }
71  
72      public void setMessageListener(MessageListener listener)
73      throws JMSException {
74          notImplemented();
75      }
76  
77      public void setExpectedCloseCalls(int callCount) {
78          myCloseCalls.setExpected(callCount);
79      }
80  
81      public void setExpectedCreateTextMessageCalls(int callCount) {
82          myCreateTextMessageCalls.setExpected(callCount);
83      }
84  
85      public StreamMessage createStreamMessage() throws JMSException {
86          notImplemented();
87          return null;
88      }
89  
90      public TextMessage createTextMessage() throws JMSException {
91          myCreateTextMessageCalls.inc();
92          return myTextMessage;
93      }
94  
95      public TextMessage createTextMessage(String text) throws JMSException {
96          myTextMessage.setText(text);
97          return myTextMessage;
98      }
99  
100     public MessageListener getMessageListener() throws JMSException {
101         notImplemented();
102         return null;
103     }
104 
105     public void run() {
106         notImplemented();
107     }
108 
109     public void setupThrowException(JMSException e) {
110         myException = e;
111     }
112 
113     protected void throwExceptionIfAny() throws JMSException {
114         if (null != myException) {
115             throw myException;
116         }
117     }
118 }