Source Code Cross Referenced for ConnectorTestModuleTest.java in  » Testing » mockrunner-0.4 » com » mockrunner » test » connector » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » mockrunner 0.4 » com.mockrunner.test.connector 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.test.connector;
002:
003:        import java.util.List;
004:
005:        import javax.resource.cci.Interaction;
006:        import javax.resource.cci.Record;
007:
008:        import junit.framework.TestCase;
009:
010:        import com.mockrunner.base.VerifyFailedException;
011:        import com.mockrunner.connector.ConnectorTestModule;
012:        import com.mockrunner.mock.connector.cci.ConnectorMockObjectFactory;
013:
014:        public class ConnectorTestModuleTest extends TestCase {
015:            private ConnectorMockObjectFactory mockFactory;
016:            private ConnectorTestModule module;
017:
018:            protected void setUp() throws Exception {
019:                mockFactory = new ConnectorMockObjectFactory();
020:                module = new ConnectorTestModule(mockFactory);
021:            }
022:
023:            protected void tearDown() throws Exception {
024:                mockFactory = null;
025:                module = null;
026:            }
027:
028:            private void createIndexedRecord(String name) throws Exception {
029:                mockFactory.getMockConnectionFactory().getRecordFactory()
030:                        .createIndexedRecord(name);
031:            }
032:
033:            private void createMappedRecord(String name) throws Exception {
034:                mockFactory.getMockConnectionFactory().getRecordFactory()
035:                        .createMappedRecord(name);
036:            }
037:
038:            public void testGetInteractionList() throws Exception {
039:                Interaction interaction1 = mockFactory.getMockConnection()
040:                        .createInteraction();
041:                Interaction interaction2 = mockFactory.getMockConnection()
042:                        .createInteraction();
043:                List interactionList = module.getInteractionList();
044:                assertEquals(2, interactionList.size());
045:                assertEquals(interaction1, interactionList.get(0));
046:                assertEquals(interaction2, interactionList.get(1));
047:            }
048:
049:            public void testVerifyConnectionClosed() throws Exception {
050:                try {
051:                    module.verifyConnectionClosed();
052:                    fail();
053:                } catch (VerifyFailedException exc) {
054:                    //expected exception
055:                }
056:                mockFactory.getMockConnection().close();
057:                module.verifyConnectionClosed();
058:            }
059:
060:            public void testVerifyInteractionClosed() throws Exception {
061:                Interaction interaction1 = mockFactory.getMockConnection()
062:                        .createInteraction();
063:                Interaction interaction2 = mockFactory.getMockConnection()
064:                        .createInteraction();
065:                Interaction interaction3 = mockFactory.getMockConnection()
066:                        .createInteraction();
067:                try {
068:                    module.verifyAllInteractionsClosed();
069:                    fail();
070:                } catch (VerifyFailedException exc) {
071:                    //expected exception
072:                }
073:                try {
074:                    module.verifyInteractionClosed(3);
075:                    fail();
076:                } catch (VerifyFailedException exc) {
077:                    //expected exception
078:                }
079:                try {
080:                    module.verifyInteractionClosed(2);
081:                    fail();
082:                } catch (VerifyFailedException exc) {
083:                    //expected exception
084:                }
085:                interaction3.close();
086:                module.verifyInteractionClosed(2);
087:                try {
088:                    module.verifyAllInteractionsClosed();
089:                    fail();
090:                } catch (VerifyFailedException exc) {
091:                    //expected exception
092:                }
093:                interaction1.close();
094:                interaction2.close();
095:                module.verifyInteractionClosed(0);
096:                module.verifyInteractionClosed(1);
097:                module.verifyAllInteractionsClosed();
098:            }
099:
100:            public void testGetCreatedIndexedRecords() throws Exception {
101:                createIndexedRecord("indexedRecord");
102:                createIndexedRecord("indexedRecord");
103:                createIndexedRecord("anotherIndexedRecord");
104:                List list = module.getCreatedIndexedRecords();
105:                assertEquals(3, list.size());
106:                assertEquals("indexedRecord", ((Record) list.get(0))
107:                        .getRecordName());
108:                assertEquals("indexedRecord", ((Record) list.get(1))
109:                        .getRecordName());
110:                assertEquals("anotherIndexedRecord", ((Record) list.get(2))
111:                        .getRecordName());
112:                list = module.getCreatedIndexedRecords("indexedRecord");
113:                assertEquals(2, list.size());
114:                assertEquals("indexedRecord", ((Record) list.get(0))
115:                        .getRecordName());
116:                assertEquals("indexedRecord", ((Record) list.get(1))
117:                        .getRecordName());
118:                list = module.getCreatedIndexedRecords("anotherIndexedRecord");
119:                assertEquals(1, list.size());
120:                assertEquals("anotherIndexedRecord", ((Record) list.get(0))
121:                        .getRecordName());
122:                list = module.getCreatedIndexedRecords("xyz");
123:                assertEquals(0, list.size());
124:            }
125:
126:            public void testGetCreatedMappedRecords() throws Exception {
127:                createMappedRecord("mappedRecord");
128:                createMappedRecord("mappedRecord");
129:                createMappedRecord("anotherMappedRecord");
130:                List list = module.getCreatedMappedRecords();
131:                assertEquals(3, list.size());
132:                assertEquals("mappedRecord", ((Record) list.get(0))
133:                        .getRecordName());
134:                assertEquals("mappedRecord", ((Record) list.get(1))
135:                        .getRecordName());
136:                assertEquals("anotherMappedRecord", ((Record) list.get(2))
137:                        .getRecordName());
138:                list = module.getCreatedMappedRecords("mappedRecord");
139:                assertEquals(2, list.size());
140:                assertEquals("mappedRecord", ((Record) list.get(0))
141:                        .getRecordName());
142:                assertEquals("mappedRecord", ((Record) list.get(1))
143:                        .getRecordName());
144:                list = module.getCreatedMappedRecords("anotherMappedRecord");
145:                assertEquals(1, list.size());
146:                assertEquals("anotherMappedRecord", ((Record) list.get(0))
147:                        .getRecordName());
148:                list = module.getCreatedMappedRecords("xyz");
149:                assertEquals(0, list.size());
150:            }
151:
152:            public void testVerifyCreatedIndexedRecords() throws Exception {
153:                createIndexedRecord("indexedRecord");
154:                createIndexedRecord("indexedRecord");
155:                createIndexedRecord("anotherIndexedRecord");
156:                module.verifyNumberCreatedIndexedRecords(3);
157:                module.verifyNumberCreatedIndexedRecords("indexedRecord", 2);
158:                module.verifyNumberCreatedIndexedRecords(
159:                        "anotherIndexedRecord", 1);
160:                module.verifyNumberCreatedMappedRecords("xyz", 0);
161:                try {
162:                    module
163:                            .verifyNumberCreatedIndexedRecords("indexedRecord",
164:                                    3);
165:                    fail();
166:                } catch (VerifyFailedException exc) {
167:                    //should throw exception
168:                }
169:                try {
170:                    module.verifyNumberCreatedIndexedRecords(1);
171:                    fail();
172:                } catch (VerifyFailedException exc) {
173:                    //should throw exception
174:                }
175:            }
176:
177:            public void testVerifyNumberCreatedMappedRecords() throws Exception {
178:                createMappedRecord("mappedRecord");
179:                createMappedRecord("anotherMappedRecord");
180:                createMappedRecord("anotherMappedRecord");
181:                createMappedRecord("anotherMappedRecord");
182:                module.verifyNumberCreatedMappedRecords(4);
183:                module.verifyNumberCreatedMappedRecords("mappedRecord", 1);
184:                module.verifyNumberCreatedMappedRecords("anotherMappedRecord",
185:                        3);
186:                module.verifyNumberCreatedMappedRecords("xyz", 0);
187:                try {
188:                    module.verifyNumberCreatedMappedRecords("xyz", 1);
189:                    fail();
190:                } catch (VerifyFailedException exc) {
191:                    //should throw exception
192:                }
193:                try {
194:                    module.verifyNumberCreatedMappedRecords(3);
195:                    fail();
196:                } catch (VerifyFailedException exc) {
197:                    //should throw exception
198:                }
199:            }
200:
201:            public void testVerifyLocalTransaction() throws Exception {
202:                module.verifyLocalTransactionNotCommitted();
203:                module.verifyLocalTransactionNotRolledBack();
204:                try {
205:                    module.verifyLocalTransactionCommitted();
206:                    fail();
207:                } catch (VerifyFailedException exc) {
208:                    //should throw exception
209:                }
210:                try {
211:                    module.verifyLocalTransactionRolledBack();
212:                    fail();
213:                } catch (VerifyFailedException exc) {
214:                    //should throw exception
215:                }
216:                mockFactory.getMockConnection().getLocalTransaction().begin();
217:                mockFactory.getMockConnection().getLocalTransaction().commit();
218:                module.verifyLocalTransactionCommitted();
219:                module.verifyLocalTransactionNotRolledBack();
220:                try {
221:                    module.verifyLocalTransactionNotCommitted();
222:                    fail();
223:                } catch (VerifyFailedException exc) {
224:                    //should throw exception
225:                }
226:                mockFactory.getMockConnection().getLocalTransaction().begin();
227:                mockFactory.getMockConnection().getLocalTransaction()
228:                        .rollback();
229:                module.verifyLocalTransactionNotCommitted();
230:                module.verifyLocalTransactionRolledBack();
231:                try {
232:                    module.verifyLocalTransactionCommitted();
233:                    fail();
234:                } catch (VerifyFailedException exc) {
235:                    //should throw exception
236:                }
237:            }
238:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.