01: package com.mockrunner.test.connector;
02:
03: import junit.framework.TestCase;
04:
05: import com.mockrunner.mock.connector.cci.ConnectorMockObjectFactory;
06: import com.mockrunner.mock.connector.cci.MockConnection;
07: import com.mockrunner.mock.connector.cci.MockConnectionFactory;
08:
09: public class ConnectorMockObjectFactoryTest extends TestCase {
10: public void testSetup() throws Exception {
11: ConnectorMockObjectFactory factory = new ConnectorMockObjectFactory();
12: MockConnectionFactory connectionFactory = factory
13: .getMockConnectionFactory();
14: assertSame(connectionFactory.getConnection(), factory
15: .getMockConnection());
16: assertSame(connectionFactory.getMockConnection(), factory
17: .getMockConnection());
18: assertSame(factory.getInteractionHandler(), connectionFactory
19: .getMockConnection().getInteractionHandler());
20: }
21:
22: public void testOverrideCreate() {
23: ConnectorMockObjectFactory factory = new TestConnectorMockObjectFactory();
24: assertNotSame(factory.getMockConnection().getClass(),
25: MockConnection.class);
26: assertNotSame(factory.getMockConnectionFactory().getClass(),
27: MockConnectionFactory.class);
28: }
29:
30: public static class TestConnectorMockObjectFactory extends
31: ConnectorMockObjectFactory {
32: public MockConnection createMockConnection() {
33: return new MockConnection() {
34: };
35: }
36:
37: public MockConnectionFactory createMockConnectionFactory() {
38: return new MockConnectionFactory() {
39: };
40: }
41: }
42: }
|