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


001:        /* TestSamples.java */
002:        package org.quilt.cl;
003:
004:        import java.io.*;
005:        import java.lang.Class;
006:        import java.lang.reflect.*;
007:        import java.net.*;
008:        import junit.framework.*;
009:
010:        /** 
011:         * Checks to make sure that the samples in test-data will load
012:         * and execute correctly.  Some of them wouldn't ;-)
013:         *
014:         * @author <a href="jddixon@users.sourceforge.net">Jim Dixon</a>
015:         */
016:        public class TestSamples extends TestCase {
017:
018:            public TestSamples(String name) {
019:                super (name);
020:            }
021:
022:            public void setUp() {
023:            }
024:
025:            private RunTest loadAsRunTest(String name) {
026:                Class clazz = null;
027:                try {
028:                    clazz = Class.forName(name);
029:                } catch (ClassNotFoundException e) {
030:                    e.printStackTrace();
031:                    fail("exception loading " + name + " using loadClass");
032:                }
033:                RunTest rt = null;
034:                try {
035:                    rt = (RunTest) clazz.newInstance();
036:                } catch (InstantiationException e) {
037:                    fail("InstantiationException instantiating loaded class "
038:                            + name);
039:                } catch (IllegalAccessException e) {
040:                    fail("IllegalAccessException instantiating loaded class "
041:                            + name);
042:                } catch (ClassCastException e) {
043:                    fail("ClassCastException instantiating loaded class "
044:                            + name);
045:                }
046:                return rt;
047:            }
048:
049:            public void testInvokeTestData() {
050:                RunTest rt = loadAsRunTest("AnonymousClass");
051:                // AnonymousClass.runTest(x) returns x
052:                assertEquals("AnonymousClass isn't working", 47, rt.runTest(47));
053:
054:                rt = loadAsRunTest("BasicLoad");
055:                // BasicLoad.runTest(x) returns x*x
056:                assertEquals("BasicLoad isn't working", 49, rt.runTest(7));
057:
058:                rt = loadAsRunTest("ComplicatedConstructor");
059:                assertEquals("ComplicatedConstructor isn't working", 61, rt
060:                        .runTest(3));
061:                // XXX causes ClassCastException when instantiating
062:                rt = loadAsRunTest("ExceptionLoad");
063:                // ExceptionLoad.runTest(x) also returns x*x
064:                assertEquals("ExceptionLoad isn't working", 121, rt.runTest(11));
065:            }
066:
067:            public void testInvokeTestData2() {
068:                RunTest rt = loadAsRunTest("Finally");
069:                // Finally.runTest(x) returns -1
070:                assertEquals("Finally isn't working", -1, rt.runTest(11));
071:                assertEquals("Finally isn't working", -1, rt.runTest(1));
072:
073:                rt = loadAsRunTest("Finally2Catches");
074:                // what Finally.runTest(x) returns is a bit complicated ...
075:                assertEquals("Finally2Catches isn't working", 3600, rt
076:                        .runTest(11));
077:
078:                rt = loadAsRunTest("InnerClass");
079:                // InnerClass.runTest(x) also returns x*x
080:                assertEquals("InnerClass isn't working", 9, rt.runTest(3));
081:
082:                rt = loadAsRunTest("Looper");
083:                assertEquals("Looper isn't working", 127008000, rt.runTest(5));
084:
085:                rt = loadAsRunTest("NestedTryBlocks");
086:                assertEquals("NestedTryBlocks isn't working", 22, rt.runTest(7));
087:
088:                rt = loadAsRunTest("OddSwitches");
089:                // we like to play
090:                assertEquals(91, rt.runTest(1001));
091:                assertEquals(31, rt.runTest(3));
092:                assertEquals(9, rt.runTest(9));
093:                assertEquals(101, rt.runTest(1005));
094:                assertEquals(-41, rt.runTest(-1));
095:                assertEquals(-3, rt.runTest(-51));
096:                assertEquals(7, rt.runTest(-2));
097:            }
098:
099:            public void testInvokeTestData3() {
100:                RunTest rt;
101:                try {
102:                    Class clazz = Class.forName("PrivateClass");
103:                    rt = (RunTest) clazz.newInstance();
104:                    fail("Expected IllegalAccessException");
105:                } catch (Exception e) {
106:                    ; // ignore it
107:                }
108:
109:                rt = loadAsRunTest("StaticInit");
110:                assertEquals("StaticInit isn't working", 10, rt.runTest(7));
111:
112:                rt = loadAsRunTest("SuperClass");
113:                // returns 3*x
114:                assertEquals("SuperClass isn't working", 21, rt.runTest(7));
115:
116:                rt = loadAsRunTest("SwitchLoad");
117:                assertEquals("SwitchLoad isn't working", 42, rt.runTest(7));
118:
119:            }
120:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.