Source Code Cross Referenced for TestQCLJars.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:        /* TestQCLJars.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:         * At the moment this is identical to TestQuiltClassLoader except that
012:         * test-data.jar is on the classpath and test-data-classes/ is not.
013:         * 
014:         * @author <a href="jddixon@users.sourceforge.net">Jim Dixon</a>
015:         */
016:        public class TestQCLJars extends TestCase {
017:
018:            private URL[] cp = null;
019:
020:            private String[] delegating = {
021:            // EMPTY -- nothing additional to defaults
022:            };
023:            private String[] include = {
024:            // EMPTY -- nothing being instrumented
025:            };
026:            private String[] exclude = { "AnonymousClass",
027:                    "AnonymousClass2Catches", "InnerClass", "NestedTryBlocks",
028:                    "PrivateClass", "SuperClass", "Wimple" };
029:            private QuiltClassLoader qLoader = null;
030:
031:            public TestQCLJars(String name) {
032:                super (name);
033:            }
034:
035:            public void setUp() {
036:                // TAKE CARE NO TERMINATING SLASH (/) ON THE JAR
037:                File sam1 = new File("target/test-data.jar");
038:                String fullPath1 = sam1.getAbsolutePath();
039:
040:                File sam2 = new File("target/classes");
041:                String fullPath2 = sam2.getAbsolutePath() + "/";
042:                File sam3 = new File("target/test-classes");
043:                String fullPath3 = sam3.getAbsolutePath() + "/";
044:                try {
045:                    // Terminating slash is required.  Relative paths don't
046:                    // work.
047:                    URL[] samples = { new URL("file://" + fullPath1),
048:                            new URL("file://" + fullPath2),
049:                            new URL("file://" + fullPath3) };
050:                    cp = samples;
051:                } catch (MalformedURLException e) {
052:                    e.printStackTrace();
053:                    fail("problem creating class path");
054:                }
055:                qLoader = new QuiltClassLoader(cp, null, // parent
056:                        delegating, // delegated classes
057:                        include, // being instrumented
058:                        exclude); // do NOT instrument
059:            }
060:
061:            /////////////////////////////////////////////////////////////////
062:            // AnonymousClass comes from test-data.jar, as does BasicLoad,
063:            // used in testInvokeTestData 
064:            // //////////////////////////////////////////////////////////////
065:            public void testLoader() {
066:                Class a1 = null;
067:                Class a2 = null;
068:                try {
069:                    a1 = qLoader.loadClass("AnonymousClass");
070:                } catch (ClassNotFoundException e) {
071:                    e.printStackTrace();
072:                    fail("Error loading AnonymousClass using loadClass");
073:                }
074:                try {
075:                    a2 = qLoader.loadClass("AnonymousClass");
076:                } catch (ClassNotFoundException e) {
077:                    fail("Error loading AnonymousClass using loadClass");
078:                }
079:                assertNotNull("qLoader returned null", a1);
080:                assertNotNull("qLoader returned null", a2);
081:                assertEquals("second load returned a different class",
082:                        (Object) a1, (Object) a2);
083:            }
084:
085:            public void testInvokeTestData() {
086:                Class a1 = null;
087:                Class a2 = null;
088:                try {
089:                    a1 = qLoader.loadClass("AnonymousClass");
090:                } catch (ClassNotFoundException e) {
091:                    e.printStackTrace();
092:                    fail("Error loading AnonymousClass using loadClass");
093:                }
094:                try {
095:                    a2 = qLoader.loadClass("BasicLoad");
096:                } catch (ClassNotFoundException e) {
097:                    fail("Error loading BasicLoad using loadClass");
098:                }
099:                RunTest rt = null;
100:                // exercise AnonymousClass ////////////////////////
101:                try {
102:                    rt = (RunTest) a1.newInstance();
103:                } catch (InstantiationException e) {
104:                    fail("error instantiating loaded AnonymousClass");
105:                } catch (IllegalAccessException e) {
106:                    fail("error instantiating loaded AnonymousClass");
107:                }
108:                // AnonymousClass.runTest(x) returns x
109:                assertEquals("AnonymousClass isn't working", 47, rt.runTest(47));
110:
111:                // exercise BasicLoad ////////////////////////
112:                try {
113:                    rt = (RunTest) a2.newInstance();
114:                } catch (InstantiationException e) {
115:                    fail("error instantiating loaded BasicLoad");
116:                } catch (IllegalAccessException e) {
117:                    fail("error instantiating loaded BasicLoad");
118:                }
119:                // BasicLoad.runTest(x) returns x*x
120:                assertEquals("BasicLoad isn't working", 49, rt.runTest(7));
121:            }
122:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.