Source Code Cross Referenced for PackageSuiteBuilder.java in  » Portal » Open-Portal » com » sun » portal » rewriter » test » util » 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 » Portal » Open Portal » com.sun.portal.rewriter.test.util 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2001 Sun Microsystems, Inc.  All rights reserved.
003:         * PROPRIETARY/CONFIDENTIAL.  Use of this product is subject to license terms.
004:         */
005:        package com.sun.portal.rewriter.test.util;
006:
007:        import com.sun.portal.rewriter.util.Resource;
008:        import com.sun.portal.rewriter.util.StringHelper;
009:        import junit.framework.Test;
010:        import junitx.util.ArchiveSuiteBuilder;
011:        import junitx.util.DirectorySuiteBuilder;
012:        import junitx.util.TestFilter;
013:
014:        public class PackageSuiteBuilder {
015:            public static final String DEFAULT_TEST_FILTER_CLASS = "DEFAULT_TEST_FILETER_CLASS";
016:
017:            private final Class dirRootClass;
018:            private TestFilter filterClass = null;
019:
020:            public PackageSuiteBuilder(final String aClassName) {
021:                this (aClassName, System.getProperty(DEFAULT_TEST_FILTER_CLASS));
022:            }//constructor
023:
024:            public PackageSuiteBuilder(final String aClassName,
025:                    final String aTestFilterClass) {
026:                dirRootClass = getClass(aClassName);
027:
028:                try {
029:                    filterClass = (TestFilter) (getClass(aTestFilterClass)
030:                            .newInstance());
031:                } catch (Exception e) {
032:                    System.out
033:                            .println("Unable to Instantiate the TestFilter Instance");
034:                    e.printStackTrace();
035:                    System.exit(0);
036:                }
037:            }//constructor
038:
039:            public Test suite() {
040:                String file = "";
041:                try {
042:                    file = dirRootClass.getProtectionDomain().getCodeSource()
043:                            .getLocation().toString().substring(
044:                                    "file:".length());
045:                    if (file.endsWith(".jar")) {
046:                        ArchiveSuiteBuilder builder = new ArchiveSuiteBuilder(
047:                                filterClass);
048:                        return builder.suite(file);
049:                    } else {
050:                        String classLocation = file
051:                                + dirRootClass.getPackage().getName().replace(
052:                                        '.', '/');
053:                        DirectorySuiteBuilder builder = new DirectorySuiteBuilder(
054:                                filterClass);
055:                        return builder.suite(classLocation);
056:                    }
057:                } catch (Exception e) {
058:                    System.out.println("Unable to fetch the suite from File: "
059:                            + file);
060:                    e.printStackTrace();
061:                    return null;
062:                }
063:            }//suite()
064:
065:            private static Class getClass(String aClassName) {
066:                if (aClassName.indexOf('/') != -1) {
067:                    aClassName = StringHelper.searchAndReplace(aClassName, "/",
068:                            ".");
069:                }
070:
071:                if (aClassName.endsWith(".class")) {
072:                    aClassName = aClassName.substring(0, aClassName.length()
073:                            - ".class".length());
074:                }
075:
076:                try {
077:                    return Class.forName(aClassName);
078:                } catch (ClassNotFoundException e) {
079:                    System.out.println("Class:" + aClassName
080:                            + " does not exists!! aborting..");
081:                    e.printStackTrace();
082:                    System.exit(0);
083:                    return null;
084:                }
085:            }//getClass()
086:
087:            public static void main(String[] args) {
088:                if (args.length == 0 || args.length > 2) {
089:                    System.out
090:                            .println("Ussage: PackageSuiteBuilder <Fully Qualified Class Name> [<TestFilterClass>]");
091:                    System.exit(0);
092:                }
093:
094:                PackageSuiteBuilder lSuiteBuilder = new PackageSuiteBuilder(
095:                        args[0]);
096:                if (args.length == 2) {
097:                    System.setProperty(DEFAULT_TEST_FILTER_CLASS, args[1]);
098:                }
099:
100:                BasicTestCase.run(lSuiteBuilder.suite());
101:            }//main()
102:
103:            private static class DirectoryClassLoader extends ClassLoader {
104:                public Class findClass(String name)
105:                        throws ClassNotFoundException {
106:                    byte classBytes[] = Resource.readBytes(name);
107:                    Class cl = defineClass(null, classBytes, 0,
108:                            classBytes.length);
109:                    cl = Class.forName(cl.getName());
110:                    return cl;
111:                }
112:            }//class DirectoryClassLoader
113:
114:        }//class PackageSuiteBuilder
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.