Source Code Cross Referenced for HashCodeTest.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.lang.reflect.Constructor;
004:        import java.lang.reflect.Method;
005:
006:        import net.sf.mockcreator.codegeneration.MockDescriptor;
007:
008:        public class HashCodeTest extends TestCase {
009:            public HashCodeTest(String name) {
010:                super (name);
011:            }
012:
013:            public void testMethodParametersOrder() throws Exception {
014:                long hash1 = getMethodHash("I1", "foo", new Class[] {
015:                        String.class, int.class });
016:                long hash2 = getMethodHash("I2", "foo", new Class[] {
017:                        int.class, String.class });
018:
019:                assertFalse(hash1 == hash2);
020:            }
021:
022:            public void testConstructorParametersOrder() throws Exception {
023:                String className1 = (HashCodeTest.class.getName() + "$C1")
024:                        .replace('/', '.');
025:                Class a1 = Class.forName(className1);
026:                Constructor foo1 = a1.getConstructor(new Class[] {
027:                        String.class, int.class });
028:
029:                long hashI1 = MockDescriptor.hashCode("SameC", foo1
030:                        .getModifiers(), null, foo1.getParameterTypes(), foo1
031:                        .getExceptionTypes());
032:
033:                String className2 = (HashCodeTest.class.getName() + "$C2")
034:                        .replace('/', '.');
035:                Class a2 = Class.forName(className2);
036:                Constructor foo2 = a2.getConstructor(new Class[] { int.class,
037:                        String.class });
038:
039:                long hashI2 = MockDescriptor.hashCode("SameC", foo2
040:                        .getModifiers(), null, foo2.getParameterTypes(), foo2
041:                        .getExceptionTypes());
042:
043:                assertFalse(hashI1 == hashI2);
044:            }
045:
046:            public void testMethodModifiers() throws Exception {
047:                long hash1 = getMethodHash("M1", "foo", null);
048:                long hash2 = getMethodHash("M2", "foo", null);
049:                long hash3 = getMethodHash("M3", "foo", null);
050:
051:                assertFalse(hash1 == hash2);
052:                assertFalse(hash2 == hash3);
053:                assertFalse(hash3 == hash1);
054:            }
055:
056:            public void testMethodExceptions() throws Exception {
057:                long hash1 = getMethodHash("E1", "foo", null);
058:                long hash2 = getMethodHash("E2", "foo", null);
059:                long hash3 = getMethodHash("E3", "foo", null);
060:
061:                assertFalse(hash1 == hash2);
062:                assertFalse(hash2 == hash3);
063:                assertFalse(hash3 == hash1);
064:            }
065:
066:            public void testMethodReturn() throws Exception {
067:                long hash1 = getMethodHash("R1", "foo", null);
068:                long hash2 = getMethodHash("R2", "foo", null);
069:
070:                assertFalse(hash1 == hash2);
071:            }
072:
073:            private long getMethodHash(String innerClass, String methodName,
074:                    Class[] params) throws Exception {
075:                String className = (HashCodeTest.class.getName() + "$" + innerClass)
076:                        .replace('/', '.');
077:                Class cls = Class.forName(className);
078:                Method mth = cls.getDeclaredMethod(methodName,
079:                        (params == null) ? new Class[] {} : params);
080:
081:                return MockDescriptor.hashCode(mth.getName(), mth
082:                        .getModifiers(), mth.getReturnType(), mth
083:                        .getParameterTypes(), mth.getExceptionTypes());
084:            }
085:
086:            public static interface I1 {
087:                void foo(String a, int b);
088:            }
089:
090:            public static interface I2 {
091:                void foo(int b, String a);
092:            }
093:
094:            public static class C1 {
095:                public C1(String a, int b) {
096:                }
097:            }
098:
099:            public static class C2 {
100:                public C2(int b, String a) {
101:                }
102:            }
103:
104:            public static class M1 {
105:                public void foo() {
106:                }
107:            }
108:
109:            public static class M2 {
110:                protected void foo() {
111:                }
112:            }
113:
114:            public static class M3 {
115:                protected static void foo() {
116:                }
117:            }
118:
119:            public static class E1 {
120:                public void foo() throws IllegalStateException {
121:                }
122:            }
123:
124:            public static class E2 {
125:                public void foo() throws IllegalArgumentException {
126:                }
127:            }
128:
129:            public static class E3 {
130:                public void foo() {
131:                }
132:            }
133:
134:            public static class R1 {
135:                public void foo() {
136:                }
137:            }
138:
139:            public static class R2 {
140:                public String foo() {
141:                    return null;
142:                }
143:            }
144:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.