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


001:        package net.sf.mockcreator.utils;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.HashMap;
006:        import java.util.HashSet;
007:        import java.util.LinkedList;
008:        import java.util.Map;
009:        import java.util.Set;
010:        import java.util.TreeMap;
011:        import java.util.TreeSet;
012:        import java.util.Vector;
013:
014:        import net.sf.mockcreator.TestCase;
015:        import net.sf.mockcreator.utils.CompareByValue;
016:
017:        public class RecursiveComparatorCollectionsTest extends TestCase {
018:
019:            public RecursiveComparatorCollectionsTest(String name) {
020:                super (name);
021:            }
022:
023:            public void testMap_Empty() {
024:                Map map1 = new HashMap();
025:                Map map2 = new TreeMap();
026:
027:                assertTrue(CompareByValue.equals(map1, map2));
028:
029:                Map map3 = new HashMap();
030:                map3.put("foo", "bar");
031:                assertFalse(CompareByValue.equals(map1, map3));
032:            }
033:
034:            public void testMap_OneElement_Equal() {
035:                Map map1 = new HashMap();
036:                Map map2 = new TreeMap();
037:
038:                map1.put(new Long(1), "foo");
039:                map2.put(new Long(1), "foo");
040:
041:                assertTrue(CompareByValue.equals(map1, map2));
042:            }
043:
044:            public void testMap_OneElement_KeysEqual() {
045:                Map map1 = new HashMap();
046:                Map map2 = new TreeMap();
047:
048:                map1.put(new Long(1), "foo");
049:                map2.put(new Long(1), "bar");
050:
051:                assertFalse(CompareByValue.equals(map1, map2));
052:            }
053:
054:            public void testMap_OneElement_ValueEqual() {
055:                Map map1 = new HashMap();
056:                Map map2 = new TreeMap();
057:
058:                map1.put(new Long(1), "foo");
059:                map2.put(new Long(2), "foo");
060:
061:                assertFalse(CompareByValue.equals(map1, map2));
062:            }
063:
064:            public void testMap_ThreeElements_OneValueMismatchs() {
065:                Map map1 = new HashMap();
066:                Map map2 = new TreeMap();
067:
068:                map1.put(new Long(1), "foo");
069:                map1.put(new Long(2), "bar");
070:                map1.put(new Long(3), "baz");
071:
072:                map2.put(new Long(1), "foo");
073:                map2.put(new Long(2), "bar");
074:                map2.put(new Long(3), "zzz");
075:
076:                assertFalse(CompareByValue.equals(map1, map2));
077:            }
078:
079:            public void testMap_ThreeElements_OneKeyMismatchs() {
080:                Map map1 = new HashMap();
081:                Map map2 = new TreeMap();
082:
083:                map1.put(new Long(1), "foo");
084:                map1.put(new Long(2), "bar");
085:                map1.put(new Long(3), "baz");
086:
087:                map2.put(new Long(1), "foo");
088:                map2.put(new Long(7), "bar");
089:                map2.put(new Long(3), "baz");
090:
091:                assertFalse(CompareByValue.equals(map1, map2));
092:            }
093:
094:            public void testMap_Nulls() {
095:                Map map1 = new HashMap();
096:                Map map2 = new HashMap();
097:
098:                map1.put(null, null);
099:                map2.put(null, null);
100:
101:                assertTrue(CompareByValue.equals(map1, map2));
102:            }
103:
104:            public void testSet_Empty() {
105:                Set set1 = new HashSet();
106:                Set set2 = new TreeSet();
107:
108:                assertTrue(CompareByValue.equals(set1, set2));
109:
110:                Set set3 = new HashSet();
111:                set3.add("foo");
112:                assertFalse(CompareByValue.equals(set1, set3));
113:            }
114:
115:            public void testSet_OneElement_Equal() {
116:                Set set1 = new HashSet();
117:                Set set2 = new TreeSet();
118:
119:                set1.add(new Long(1));
120:                set2.add(new Long(1));
121:
122:                assertTrue(CompareByValue.equals(set1, set2));
123:            }
124:
125:            public void testSet_OneElement_Set() {
126:                Set set1 = new HashSet();
127:                Set set2 = new TreeSet();
128:
129:                Set set11 = new HashSet();
130:                Set set21 = new TreeSet();
131:                set11.add("foo");
132:                set21.add("foo");
133:
134:                set1.add(set11);
135:                set2.add(set21);
136:
137:                assertTrue(CompareByValue.compareCollections(set1, set2));
138:
139:                set21.add("bar");
140:                assertFalse(CompareByValue.compareCollections(set1, set2));
141:            }
142:
143:            public void testSet_ThreeElements_OneValueMismatchs() {
144:                Set set1 = new HashSet();
145:                Set set2 = new TreeSet();
146:
147:                set1.add("foo");
148:                set1.add("bar");
149:                set1.add("baz");
150:
151:                set2.add("foo");
152:                set2.add("bar");
153:                set2.add("zzz");
154:
155:                assertFalse(CompareByValue.equals(set1, set2));
156:            }
157:
158:            public void testSet_Nulls() {
159:                Set set1 = new HashSet();
160:                Set set2 = new HashSet();
161:
162:                set1.add(null);
163:                set2.add(null);
164:
165:                assertTrue(CompareByValue.equals(set1, set2));
166:            }
167:
168:            public void testCollection_Empty() {
169:                Collection col1 = new ArrayList();
170:                Collection col2 = new Vector();
171:
172:                assertTrue(CompareByValue.equals(col1, col2));
173:
174:                Collection col3 = new ArrayList();
175:                col3.add("foo");
176:                assertFalse(CompareByValue.equals(col1, col3));
177:            }
178:
179:            public void testCollection_OneElement_Equal() {
180:                Collection col1 = new ArrayList();
181:                Collection col2 = new Vector();
182:
183:                col1.add(new Long(1));
184:                col2.add(new Long(1));
185:
186:                assertTrue(CompareByValue.equals(col1, col2));
187:            }
188:
189:            public void testCollection_OneElement_Set() {
190:                Collection col1 = new ArrayList();
191:                Collection col2 = new Vector();
192:
193:                Set set1 = new HashSet();
194:                Set set2 = new TreeSet();
195:                set1.add("foo");
196:                set2.add("foo");
197:
198:                col1.add(set1);
199:                col2.add(set2);
200:
201:                assertTrue(CompareByValue.equals(col1, col2));
202:
203:                col2.add(set2);
204:                assertFalse(CompareByValue.equals(col1, col2));
205:            }
206:
207:            public void testCollection_ThreeElements_OneValueMismatchs() {
208:                Collection col1 = new LinkedList();
209:                Collection col2 = new Vector();
210:
211:                col1.add("foo");
212:                col1.add("bar");
213:                col1.add("baz");
214:
215:                col2.add("foo");
216:                col2.add("bar");
217:                col2.add("zzz");
218:
219:                assertFalse(CompareByValue.equals(col1, col2));
220:            }
221:
222:            public void testCollection_DifferentLength() {
223:                Collection col1 = new LinkedList();
224:                Collection col2 = new Vector();
225:
226:                col1.add("foo");
227:                col1.add("bar");
228:                col1.add("baz");
229:
230:                col2.add("foo");
231:                col2.add("bar");
232:
233:                assertFalse(CompareByValue.equals(col1, col2));
234:            }
235:
236:            public void testCollection_Nulls() {
237:                Collection col1 = new Vector();
238:                Collection col2 = new Vector();
239:
240:                col1.add(null);
241:                col2.add(null);
242:
243:                assertTrue(CompareByValue.equals(col1, col2));
244:            }
245:
246:            // FIXME: don't know what to do in case of recursion yet
247:            //    public void test_Recursive() {
248:            //        Collection map1 = new HashCollection();
249:            //        Collection map2 = new HashCollection();
250:            //        
251:            //        map1.put(map2,map2);
252:            //        map2.put(map1,map1);
253:            //        
254:            //        assertFalse(RecursiveComparator.equals(map1,map2));
255:            //    }
256:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.