KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.mockobjects.jms;
2
3 import com.mockobjects.MockObject;
4 import com.mockobjects.ReturnValue;
5
6 import javax.jms.JMSException JavaDoc;
7 import javax.jms.Queue JavaDoc;
8
9 public class MockQueue extends MockObject implements Queue JavaDoc {
10
11     private JMSException JavaDoc myException;
12     private final ReturnValue myName = new ReturnValue("name");
13
14     public String JavaDoc getQueueName() throws JMSException JavaDoc {
15         throwExceptionIfAny();
16         return (String JavaDoc)myName.getValue();
17     }
18
19     public void setupGetQueueName(final String JavaDoc name){
20         myName.setValue(name);
21     }
22
23     public String JavaDoc toString() {
24         return this.getClass().getName() + ", " + myName.getValue();
25     }
26
27     public void setupThrowException(JMSException JavaDoc e) {
28         myException = e;
29     }
30
31     protected void throwExceptionIfAny() throws JMSException JavaDoc {
32         if (null != myException) {
33             throw myException;
34         }
35     }
36 }
Popular Tags