01: package com.mockrunner.test.jms;
02:
03: import junit.framework.TestCase;
04:
05: import com.mockrunner.mock.jms.JMSMockObjectFactory;
06: import com.mockrunner.mock.jms.MockConnectionFactory;
07: import com.mockrunner.mock.jms.MockQueueConnectionFactory;
08: import com.mockrunner.mock.jms.MockTopicConnectionFactory;
09:
10: public class JMSMockObjectFactoryTest extends TestCase {
11: public void testSetup() throws Exception {
12: JMSMockObjectFactory factory = new JMSMockObjectFactory();
13: MockConnectionFactory mockFactory = factory
14: .getMockConnectionFactory();
15: MockQueueConnectionFactory mockQueueFactory = factory
16: .getMockQueueConnectionFactory();
17: MockTopicConnectionFactory mockTopicFactory = factory
18: .getMockTopicConnectionFactory();
19: assertNotSame(mockFactory, mockQueueFactory);
20: assertNotSame(mockFactory, mockTopicFactory);
21: assertNotSame(mockQueueFactory, mockTopicFactory);
22: }
23:
24: public void testOverrideCreate() {
25: JMSMockObjectFactory factory = new TestJMSMockObjectFactory();
26: assertNotSame(factory.getMockConnectionFactory().getClass(),
27: MockConnectionFactory.class);
28: assertNotSame(factory.getMockQueueConnectionFactory()
29: .getClass(), MockQueueConnectionFactory.class);
30: assertNotSame(factory.getMockTopicConnectionFactory()
31: .getClass(), MockTopicConnectionFactory.class);
32: }
33:
34: public static class TestJMSMockObjectFactory extends
35: JMSMockObjectFactory {
36: public MockConnectionFactory createMockConnectionFactory() {
37: return new MockConnectionFactory(getDestinationManager(),
38: getConfigurationManager()) {
39: };
40: }
41:
42: public MockQueueConnectionFactory createMockQueueConnectionFactory() {
43: return new MockQueueConnectionFactory(
44: getDestinationManager(), getConfigurationManager()) {
45: };
46: }
47:
48: public MockTopicConnectionFactory createMockTopicConnectionFactory() {
49: return new MockTopicConnectionFactory(
50: getDestinationManager(), getConfigurationManager()) {
51: };
52: }
53: }
54: }
|