Source Code Cross Referenced for Java15Test.java in  » Testing » MockCreator » net » sf » mockcreator » 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 » MockCreator » net.sf.mockcreator 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.sf.mockcreator;
002:
003:        import java.util.*;
004:
005:        import net.sf.mockcreator.Java15.Java15Enum;
006:        import net.sf.mockcreator.exceptions.MockException;
007:        import net.sf.mockcreator.expectable.Ignore;
008:
009:        public class Java15Test extends TestCase {
010:            MockJava15 mock;
011:
012:            public void testExpect() throws Exception {
013:                MockCore.reset();
014:                mock = new MockJava15();
015:                mock.expectGetNames().returns(new HashSet<String>());
016:                mock.getNames();
017:                MockCore.verify();
018:            }
019:
020:            public void DISABLED_TEMPORARELY_testExpectWrongGenericsParameter()
021:                    throws Exception {
022:                Set ints = new HashSet<Integer>();
023:                MockCore.reset();
024:                mock = new MockJava15();
025:                mock.acceptSetNames(new HashSet<String>());
026:
027:                try {
028:                    mock.setNames(ints);
029:                    fail();
030:                } catch (MockException ex) {
031:                }
032:
033:                MockCore.verify();
034:            }
035:
036:            public void testExpectWrongGenericsParameter2() throws Exception {
037:                Set ints = new HashSet<Integer>();
038:                ints.add(new Integer(1));
039:
040:                Set strings = new HashSet<String>();
041:                strings.add("foo");
042:
043:                MockCore.reset();
044:                mock = new MockJava15();
045:                mock.acceptSetNames(strings);
046:
047:                try {
048:                    mock.setNames(ints);
049:                    fail();
050:                } catch (net.sf.mockcreator.exceptions.MockException ex) {
051:                }
052:
053:                MockCore.reset();
054:            }
055:
056:            public void testExpectZeroOrMore() throws Exception {
057:                MockCore.reset();
058:                mock = new MockJava15();
059:                mock.expectZeroOrMoreGetNames().returns(new HashSet<String>());
060:                mock.getNames();
061:                mock.getNames();
062:                mock.getNames();
063:                MockCore.verify();
064:            }
065:
066:            public void testAccept() throws Exception {
067:                MockCore.reset();
068:                mock = new MockJava15();
069:                mock.acceptSetNames(new HashSet<String>());
070:                mock.setNames(new HashSet<String>());
071:                MockCore.verify();
072:            }
073:
074:            public void testThrowable() throws Exception {
075:                MockCore.reset();
076:                mock = new MockJava15();
077:                mock.expectGetNames().throwable(new IllegalArgumentException());
078:                try {
079:                    mock.getNames();
080:                } catch (IllegalArgumentException ex) {
081:                }
082:                MockCore.verify();
083:            }
084:
085:            // public Set<? extends List> mess1(Object ... args);
086:
087:            public void testExpectVariableParams() throws Exception {
088:                Set<ArrayList> ret = new HashSet<ArrayList>();
089:
090:                MockCore.reset();
091:                mock = new MockJava15();
092:                mock.expectMess1("vasya", "petya").returns(ret);
093:
094:                Set real = mock.mess1("vasya", "petya");
095:                assertEquals(ret, real);
096:
097:                MockCore.verify();
098:            }
099:
100:            public void testExpectZeroOrMoreVariableParams() throws Exception {
101:                Set<ArrayList> ret = new HashSet<ArrayList>();
102:
103:                MockCore.reset();
104:                mock = new MockJava15();
105:                mock.expectZeroOrMoreMess1("vasya", "petya").returns(ret);
106:                mock.expectZeroOrMoreMess1().returns(null);
107:
108:                Set real = mock.mess1("vasya", "petya");
109:                assertEquals(ret, real);
110:
111:                assertNull(mock.mess1("foo"));
112:
113:                real = mock.mess1("vasya", "petya");
114:                assertEquals(ret, real);
115:
116:                MockCore.verify();
117:            }
118:
119:            public void testExpectVariableParamsFails() throws Exception {
120:                Set<ArrayList> ret = new HashSet<ArrayList>();
121:
122:                MockCore.reset();
123:                mock = new MockJava15();
124:                mock.expectMess1("vasya", "petya").returns(ret);
125:
126:                try {
127:                    mock.mess1(123);
128:                    fail();
129:                } catch (MockException ex) {
130:                }
131:            }
132:
133:            public void testAcceptVariableParams() throws Exception {
134:                Set<ArrayList> ret = new HashSet<ArrayList>();
135:
136:                MockCore.reset();
137:                mock = new MockJava15();
138:                mock.acceptMess1("vasya", new Ignore()).returns(ret);
139:
140:                Set real = mock.mess1("vasya", "masha");
141:                assertEquals(ret, real);
142:
143:                MockCore.verify();
144:            }
145:
146:            public void testAcceptVariableParamsFails() throws Exception {
147:                Set<ArrayList> ret = new HashSet<ArrayList>();
148:
149:                MockCore.reset();
150:                mock = new MockJava15();
151:                mock.acceptMess1("vasya", "petya").returns(ret);
152:
153:                try {
154:                    mock.mess1(123);
155:                    fail();
156:                } catch (MockException ex) {
157:                }
158:            }
159:
160:            // public void enums(Java15Enum e);
161:
162:            public void testExpectEnum() throws Exception {
163:                MockCore.reset();
164:                mock = new MockJava15();
165:                mock.expectEnums(Java15Enum.FOO).returns(5);
166:
167:                int ret = mock.enums(Java15Enum.FOO);
168:                assertEquals(5, ret);
169:
170:                MockCore.verify();
171:            }
172:
173:            public void testExpectFailed() throws Exception {
174:                MockCore.reset();
175:                mock = new MockJava15();
176:                mock.expectEnums(Java15Enum.FOO).returns(5);
177:
178:                try {
179:                    mock.enums(Java15Enum.BAR);
180:                    fail();
181:                } catch (MockException ex) {
182:                }
183:
184:                MockCore.reset();
185:            }
186:
187:            public void testExpectZeroOrMoreEnum() throws Exception {
188:                MockCore.reset();
189:                mock = new MockJava15();
190:                mock.expectZeroOrMoreEnums(Java15Enum.FOO).returns(5);
191:                mock.expectZeroOrMoreEnums().returns(333);
192:
193:                assertEquals(5, mock.enums(Java15Enum.FOO));
194:                assertEquals(5, mock.enums(Java15Enum.FOO));
195:                assertEquals(333, mock.enums(Java15Enum.BAR));
196:                assertEquals(333, mock.enums(null));
197:                assertEquals(5, mock.enums(Java15Enum.FOO));
198:
199:                MockCore.verify();
200:            }
201:
202:            public void testAcceotEnum() throws Exception {
203:                MockCore.reset();
204:                mock = new MockJava15();
205:                mock.acceptEnums(new Ignore()).returns(5);
206:
207:                int ret = mock.enums(Java15Enum.BAZ);
208:                assertEquals(5, ret);
209:
210:                MockCore.verify();
211:            }
212:
213:            public void testAcceptFailed() throws Exception {
214:                MockCore.reset();
215:                mock = new MockJava15();
216:                mock.acceptEnums(Java15Enum.FOO).returns(5);
217:
218:                try {
219:                    mock.enums(Java15Enum.BAR);
220:                    fail();
221:                } catch (MockException ex) {
222:                }
223:
224:                MockCore.reset();
225:            }
226:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.