Source Code Cross Referenced for TestArrComparator.java in  » Test-Coverage » Quilt » org » quilt » reg » 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 » Test Coverage » Quilt » org.quilt.reg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


01:        /* TestArrComparator.java */
02:
03:        package org.quilt.reg;
04:
05:        import java.util.*;
06:        import junit.framework.*;
07:
08:        public class TestArrComparator extends TestCase {
09:
10:            private Registry reg = new Registry();
11:            private Comparator cmp = reg.comparator();
12:
13:            int compare(String[] s1, String[] s2) {
14:                return cmp.compare(s1, s2);
15:            }
16:
17:            int objCompare(Object o1, Object o2) {
18:                return cmp.compare(o1, o2);
19:            }
20:
21:            final String key0[] = { "Quilt" };
22:            final String key1[] = { "Quilt", "ARG0" };
23:            final String key2[] = { "Elvis", "lives" };
24:            final String key20[] = { "Elvis", "lives", "forever" };
25:            final String key22[] = { "Elvis", "lives", "forever", "in",
26:                    "Graceland" };
27:            final String key3[] = { "One plus ", "one" };
28:            final String key4[] = { "Elvis", "wombat" };
29:            final String key5[] = { "Elvis", "heart-throb" };
30:            final String key6[] = { "rg2", "msg" };
31:            final String key7[] = { "rg2", "test" };
32:            final String key8[] = { "rg2", "test", "a" };
33:            final String key9[] = { "rg2", "test", "b" };
34:
35:            public void testSelfCompare() {
36:                // self-comparisons should always return 0
37:                assertEquals("compare to self does not return 0", 0, compare(
38:                        key0, key0));
39:                assertEquals("compare to self does not return 0", 0, compare(
40:                        key1, key1));
41:                assertEquals("compare to self does not return 0", 0, compare(
42:                        key20, key20));
43:                assertEquals("compare to self does not return 0", 0, compare(
44:                        key22, key22));
45:            }
46:
47:            public void testDiffLen() {
48:                // shorter to otherwise identical but longer string returns -1
49:                assertEquals("compare to longer but otherwise identical", -1,
50:                        compare(key0, key1));
51:                assertEquals("compare to longer but otherwise identical", -1,
52:                        compare(key2, key20));
53:                assertEquals("compare to longer but otherwise identical", -1,
54:                        compare(key20, key22));
55:
56:                // longer to otherwise identical but shorter string returns +1
57:                assertEquals("compare to longer but otherwise identical", 1,
58:                        compare(key1, key0));
59:                assertEquals("compare to longer but otherwise identical", 1,
60:                        compare(key20, key2));
61:                assertEquals("compare to longer but otherwise identical", 1,
62:                        compare(key22, key20));
63:            }
64:
65:            public void testMiscCompare() {
66:                // seem to fail in the field
67:                assertEquals("rg2/msg vs rg2/test", -1, compare(key6, key7));
68:                assertEquals("rg2/msg vs rg2/test", 1, compare(key7, key6));
69:
70:                // two-string arrays
71:                assertEquals("Elvis/heart-throb vs lives", -1, compare(key5,
72:                        key2));
73:                assertEquals("Elvis/lives vs wombat", -1, compare(key2, key4));
74:                assertEquals("Elvis/lives vs heart-throb", 1, compare(key2,
75:                        key5));
76:                assertEquals("Elvis/wombat vs lives", 1, compare(key4, key2));
77:
78:                // three-string arrays
79:                assertEquals("rg2/test/a vs b", -1, compare(key8, key9));
80:                assertEquals("rg2/test/b vs a", 1, compare(key9, key8));
81:            }
82:
83:            public void testExceptions() {
84:                try {
85:                    objCompare("this is a string", new Boolean(true));
86:                    fail("args not String[], Comparator did not throw ClassCastException");
87:                } catch (ClassCastException e) {
88:                    // success
89:                }
90:            }
91:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.