KickJava   Java API By Example, From Geeks To Geeks.

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


1 package com.mockobjects.jms;
2
3 import com.mockobjects.*;
4
5 import javax.jms.*;
6
7 public class MockQueueConnectionFactory extends MockObject implements
8     QueueConnectionFactory {
9
10     private final ExpectationValue myUserName = new ExpectationValue("MockQueueConnectionFactory.createQueueConnection");
11     private final ExpectationValue myPassword = new ExpectationValue("MockQueueConnectionFactory.createQueueConnection");
12
13     private JMSException myException;
14     private final ReturnValue myQueueConnection = new ReturnValue("queue connection");
15
16     public QueueConnection createQueueConnection() throws JMSException {
17         throwExceptionIfAny();
18         return (QueueConnection) myQueueConnection.getValue();
19     }
20
21     public QueueConnection createQueueConnection(String JavaDoc userName, String JavaDoc password)
22         throws JMSException {
23         throwExceptionIfAny();
24         myUserName.setActual(userName);
25         myPassword.setActual(password);
26         return (QueueConnection) myQueueConnection.getValue();
27     }
28
29     public void setExpectedUserName(String JavaDoc userName) {
30         myUserName.setExpected(userName);
31     }
32
33     public void setExpectedPassword(String JavaDoc password) {
34         myPassword.setExpected(password);
35     }
36
37     public void setupQueueConnection(QueueConnection queueConnection) {
38         myQueueConnection.setValue(queueConnection);
39     }
40
41     public void setupThrowException(JMSException e) {
42         myException = e;
43     }
44
45     private void throwExceptionIfAny() throws JMSException {
46         if (null != myException) {
47             throw myException;
48         }
49     }
50 }
Popular Tags