Source Code Cross Referenced for ParameterUtilTest.java in  » Testing » mockrunner-0.4 » com » mockrunner » test » jdbc » 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.jdbc 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.mockrunner.test.jdbc;
002:
003:        import java.io.ByteArrayInputStream;
004:        import java.io.InputStream;
005:        import java.io.Reader;
006:        import java.io.StringReader;
007:        import java.util.Arrays;
008:        import java.util.Date;
009:
010:        import junit.framework.TestCase;
011:
012:        import com.mockrunner.jdbc.ParameterUtil;
013:        import com.mockrunner.mock.jdbc.MockArray;
014:        import com.mockrunner.mock.jdbc.MockBlob;
015:        import com.mockrunner.mock.jdbc.MockClob;
016:        import com.mockrunner.mock.jdbc.MockRef;
017:        import com.mockrunner.mock.jdbc.MockResultSet;
018:        import com.mockrunner.mock.jdbc.MockStruct;
019:        import com.mockrunner.util.common.StreamUtil;
020:
021:        public class ParameterUtilTest extends TestCase {
022:            public void testCompareParameter() {
023:                assertTrue(ParameterUtil.compareParameter(null, null));
024:                assertFalse(ParameterUtil.compareParameter("test", null));
025:                assertTrue(ParameterUtil.compareParameter("test", "test"));
026:                assertFalse(ParameterUtil.compareParameter(new Double(1),
027:                        new Double(2)));
028:                assertTrue(ParameterUtil.compareParameter(
029:                        new byte[] { 1, 2, 3 }, new byte[] { 1, 2, 3 }));
030:                assertFalse(ParameterUtil.compareParameter(
031:                        new byte[] { 1, 2, 4 }, new byte[] { 1, 2, 3 }));
032:                assertTrue(ParameterUtil.compareParameter(
033:                        new ByteArrayInputStream(new byte[] { 1, 2, 3 }),
034:                        new ByteArrayInputStream(new byte[] { 1, 2, 3 })));
035:                assertTrue(ParameterUtil.compareParameter(new StringReader(
036:                        "xyz"), new StringReader("xyz")));
037:                assertFalse(ParameterUtil.compareParameter(new StringReader(
038:                        "xyz"), new StringReader("")));
039:                assertFalse(ParameterUtil.compareParameter(new Object(),
040:                        new Object()));
041:                assertTrue(ParameterUtil.compareParameter(new MockRef("test"),
042:                        new MockRef("test")));
043:                assertFalse(ParameterUtil.compareParameter(new MockRef(""),
044:                        new MockRef("xyz")));
045:                assertTrue(ParameterUtil.compareParameter(new MockArray(
046:                        new String[] { "", "" }), new MockArray(new String[] {
047:                        "", "" })));
048:                assertFalse(ParameterUtil.compareParameter(new MockArray(
049:                        new String[] { "", "" }), new MockArray(new int[] { 1,
050:                        1 })));
051:                assertTrue(ParameterUtil.compareParameter(new MockArray(
052:                        new Object[] { "1", new Integer(2) }), new MockArray(
053:                        new Object[] { "1", new Integer(2) })));
054:                assertFalse(ParameterUtil.compareParameter(new MockArray(
055:                        new Object[] { new Integer(2), "1" }), new MockArray(
056:                        new Object[] { "1", new Integer(2) })));
057:                assertTrue(ParameterUtil.compareParameter(new MockBlob(
058:                        new byte[] { 1, 1, 1 }), new MockBlob(new byte[] { 1,
059:                        1, 1 })));
060:                assertFalse(ParameterUtil.compareParameter(new MockBlob(
061:                        new byte[] { 1, 1, 1 }), new MockBlob(
062:                        new byte[] { 1, 1 })));
063:                assertTrue(ParameterUtil.compareParameter(new MockBlob(
064:                        new byte[] {}), new MockBlob(new byte[] {})));
065:                assertFalse(ParameterUtil.compareParameter(new MockBlob(
066:                        new byte[] {}), new MockBlob(new byte[] { 2 })));
067:                assertFalse(ParameterUtil.compareParameter(new MockBlob(
068:                        new byte[] { 1, 2, 3 }), new MockBlob(new byte[] { 1,
069:                        2, 4 })));
070:                assertTrue(ParameterUtil.compareParameter(new MockClob("123"),
071:                        new MockClob("123")));
072:                assertTrue(ParameterUtil.compareParameter(new MockClob(""),
073:                        new MockClob("")));
074:                assertFalse(ParameterUtil.compareParameter(new MockClob("1"),
075:                        new MockClob("")));
076:                assertTrue(ParameterUtil.compareParameter(new MockStruct(""),
077:                        new MockStruct("")));
078:                assertTrue(ParameterUtil.compareParameter(
079:                        new MockStruct("123"), new MockStruct("123")));
080:                assertFalse(ParameterUtil.compareParameter(
081:                        new MockStruct("123"), new MockStruct("")));
082:                MockStruct struct = new MockStruct("123");
083:                struct.addAttribute("test");
084:                assertTrue(ParameterUtil.compareParameter(struct, struct));
085:                assertFalse(ParameterUtil.compareParameter(struct,
086:                        new MockStruct("123")));
087:                MockStruct anotherStruct = new MockStruct("123");
088:                anotherStruct.addAttribute("test");
089:                assertTrue(ParameterUtil
090:                        .compareParameter(struct, anotherStruct));
091:                anotherStruct.addAttribute(new Integer(2));
092:                assertFalse(ParameterUtil.compareParameter(struct,
093:                        anotherStruct));
094:                struct.addAttribute(new Integer(2));
095:                assertTrue(ParameterUtil
096:                        .compareParameter(struct, anotherStruct));
097:                MockResultSet resultSet1 = new MockResultSet("id");
098:                resultSet1.addRow(new Object[] { "1", new Integer(1) });
099:                resultSet1.addRow(new Object[] { "2", new Integer(2) });
100:                resultSet1.addRow(new Object[] { "3", new Integer(3) });
101:                MockResultSet resultSet2 = new MockResultSet("id");
102:                resultSet2.addRow(new Object[] { "1", new Integer(1) });
103:                resultSet2.addRow(new Object[] { "2", new Integer(2) });
104:                resultSet2.addRow(new Object[] { "3", new Integer(3) });
105:                assertTrue(ParameterUtil.compareParameter(resultSet1,
106:                        resultSet1));
107:                assertTrue(ParameterUtil.compareParameter(resultSet1,
108:                        resultSet2));
109:                resultSet2.addRow(new Object[] { "4", new Integer(4) });
110:                assertFalse(ParameterUtil.compareParameter(resultSet1,
111:                        resultSet2));
112:            }
113:
114:            public void testCopyParameter() {
115:                String testString = new String("Test");
116:                String copyString = (String) ParameterUtil
117:                        .copyParameter(testString);
118:                assertTrue(testString == copyString);
119:                byte[] testArray = new byte[] { 1, 2, 3 };
120:                byte[] copyArray = (byte[]) ParameterUtil
121:                        .copyParameter(testArray);
122:                assertFalse(testArray == copyArray);
123:                assertTrue(Arrays.equals(testArray, copyArray));
124:                Reader testReader = new StringReader("Test");
125:                Reader copyReader = (Reader) ParameterUtil
126:                        .copyParameter(testReader);
127:                assertFalse(testReader == copyReader);
128:                assertTrue(StreamUtil.compareReaders(testReader, copyReader));
129:                InputStream testStream = new ByteArrayInputStream(new byte[] {
130:                        1, 2, 3 });
131:                InputStream copyStream = (InputStream) ParameterUtil
132:                        .copyParameter(testStream);
133:                assertFalse(testStream == copyStream);
134:                assertTrue(StreamUtil.compareStreams(testStream, copyStream));
135:                MockClob testClob = new MockClob("Test");
136:                MockClob copyClob = (MockClob) ParameterUtil
137:                        .copyParameter(testClob);
138:                assertFalse(testClob == copyClob);
139:                assertTrue(ParameterUtil.compareParameter(testClob, copyClob));
140:                MockArray testMockArray = new MockArray(new String[] { "", "" });
141:                MockArray copyMockArray = (MockArray) ParameterUtil
142:                        .copyParameter(testMockArray);
143:                assertFalse(testMockArray == copyMockArray);
144:                assertTrue(ParameterUtil.compareParameter(testMockArray,
145:                        copyMockArray));
146:                Date testDate = new Date();
147:                Date copyDate = (Date) ParameterUtil.copyParameter(testDate);
148:                assertNotSame(testDate, copyDate);
149:                assertEquals(testDate, copyDate);
150:                TestParameter parameter = new TestParameter();
151:                TestParameter copyParameter = (TestParameter) ParameterUtil
152:                        .copyParameter(parameter);
153:                assertSame(parameter, copyParameter);
154:            }
155:
156:            public static class TestParameter implements  Cloneable {
157:                public Object clone() throws CloneNotSupportedException {
158:                    throw new RuntimeException("OOPPSS");
159:                }
160:            }
161:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.