Source Code Cross Referenced for AllTests.java in  » Rule-Engine » drolls-Rule-Engine » org » jcp » jsr94 » tck » 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 » Rule Engine » drolls Rule Engine » org.jcp.jsr94.tck 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * J A V A  C O M M U N I T Y  P R O C E S S
003:         *
004:         * J S R  9 4
005:         *
006:         * Test Compatability Kit
007:         *
008:         */
009:        package org.jcp.jsr94.tck;
010:
011:        // java imports
012:        import java.io.BufferedWriter;
013:        import java.io.File;
014:        import java.io.FileInputStream;
015:        import java.io.FileOutputStream;
016:        import java.io.FileWriter;
017:        import java.io.IOException;
018:        import java.net.URL;
019:        import java.util.zip.ZipEntry;
020:        import java.util.zip.ZipOutputStream;
021:
022:        import junit.framework.Test;
023:        import junit.framework.TestSuite;
024:
025:        import org.drools.jsr94.rules.Jsr94FactHandle;
026:        import org.jcp.jsr94.tck.admin.LocalRuleExecutionSetProviderTest;
027:        import org.jcp.jsr94.tck.admin.RuleAdministrationExceptionTest;
028:        import org.jcp.jsr94.tck.admin.RuleAdministratorTest;
029:        import org.jcp.jsr94.tck.admin.RuleExecutionSetCreateExceptionTest;
030:        import org.jcp.jsr94.tck.admin.RuleExecutionSetDeregistrationExceptionTest;
031:        import org.jcp.jsr94.tck.admin.RuleExecutionSetRegisterExceptionTest;
032:        import org.jcp.jsr94.tck.admin.RuleExecutionSetTest;
033:        import org.jcp.jsr94.tck.admin.RuleTest;
034:
035:        /**
036:         * Run all the test suites in the Test Compatability Kit.
037:         * Output is directed to System.out (textui).
038:         */
039:        public class AllTests extends TestSuite {
040:
041:            public static Test suite() {
042:                setTckConf();
043:
044:                final TestSuite suite = new TestSuite(
045:                        "JSR 94 Test Compatability Kit");
046:                suite.addTestSuite(ApiSignatureTest.class);
047:                suite.addTestSuite(ClassLoaderTest.class);
048:                suite.addTestSuite(ConfigurationExceptionTest.class);
049:                suite.addTestSuite(HandleTest.class);
050:                suite.addTestSuite(InvalidHandleExceptionTest.class);
051:                suite.addTestSuite(InvalidRuleSessionExceptionTest.class);
052:                suite.addTestSuite(ObjectFilterTest.class);
053:                suite.addTestSuite(RuleExceptionTest.class);
054:                suite.addTestSuite(RuleExecutionExceptionTest.class);
055:                suite.addTestSuite(RuleExecutionSetMetadataTest.class);
056:                suite.addTestSuite(RuleExecutionSetNotFoundExceptionTest.class);
057:                suite.addTestSuite(RuleRuntimeTest.class);
058:                suite.addTestSuite(RuleServiceProviderManagerTest.class);
059:                suite.addTestSuite(RuleServiceProviderTest.class);
060:                suite.addTestSuite(RuleSessionCreateExceptionTest.class);
061:                suite.addTestSuite(RuleSessionTest.class);
062:                suite
063:                        .addTestSuite(RuleSessionTypeUnsupportedExceptionTest.class);
064:                suite.addTestSuite(StatefulRuleSessionTest.class);
065:                suite.addTestSuite(StatelessRuleSessionTest.class);
066:                suite.addTestSuite(LocalRuleExecutionSetProviderTest.class);
067:                suite.addTestSuite(RuleAdministrationExceptionTest.class);
068:                suite.addTestSuite(RuleAdministratorTest.class);
069:                suite.addTestSuite(RuleExecutionSetCreateExceptionTest.class);
070:                //     suite.addTestSuite(RuleExecutionSetProviderTest.class);
071:                suite.addTestSuite(RuleExecutionSetRegisterExceptionTest.class);
072:                suite.addTestSuite(RuleExecutionSetTest.class);
073:                suite
074:                        .addTestSuite(RuleExecutionSetDeregistrationExceptionTest.class);
075:                suite.addTestSuite(RuleTest.class);
076:                return suite;
077:            }
078:
079:            /**
080:             * Because the tck.conf relies on directory paths that are not universally the same from eclipse, maven
081:             * and ant this method create a tck.conf on the fly with the correct locations, it also create a jar
082:             * on the fly which it uses as the jar url location.
083:             *
084:             */
085:            private static void setTckConf() {
086:                File jarFile = null;
087:                ZipOutputStream zos = null;
088:                File rootDirectory = null;
089:                try {
090:                    jarFile = File.createTempFile("drools-jsr94", ".jar");
091:
092:                    URL url = Jsr94FactHandle.class
093:                            .getResource("Jsr94FactHandle.class");
094:                    rootDirectory = new File(url.getFile()).getParentFile()
095:                            .getParentFile().getParentFile().getParentFile();
096:
097:                    zos = new ZipOutputStream(new FileOutputStream(jarFile));
098:                    zipDir(rootDirectory, zos);
099:                } catch (Exception e) {
100:                    e.printStackTrace();
101:                } finally {
102:                    if (zos != null) {
103:                        try {
104:                            zos.close();
105:                        } catch (IOException e) {
106:                        }
107:                    }
108:                }
109:
110:                String conf = "";
111:                conf += "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
112:                conf += "<tck-configuration>\n";
113:                conf += "<test-factory>org.jcp.jsr94.tck.util.TestFactory</test-factory>\n";
114:                conf += "<rule-service-provider>org.drools.jsr94.rules.RuleServiceProviderImpl</rule-service-provider>\n";
115:                conf += "<rule-service-provider-jar-url>file://"
116:                        + jarFile.getAbsolutePath()
117:                        + "</rule-service-provider-jar-url>\n";
118:
119:                URL url = AllTests.class.getResource("AllTests.class");
120:                String setLocation = new File(url.getFile()).getParentFile()
121:                        .getAbsolutePath().replaceAll("\\\\", "/");
122:                // the tck needs an asbolute path, with no drive letters
123:                if (setLocation.charAt(1) == ':') {
124:                    setLocation = setLocation.substring(2);
125:                }
126:                conf += "<rule-execution-set-location>" + setLocation
127:                        + "</rule-execution-set-location>\n";
128:                conf += "</tck-configuration>";
129:
130:                url = AllTests.class.getResource("tck.conf");
131:                File tckConf = new File(url.getFile());
132:                BufferedWriter buffWriter = null;
133:                try {
134:                    FileWriter fileWriter = new FileWriter(tckConf);
135:                    buffWriter = new BufferedWriter(fileWriter);
136:                    buffWriter.write(conf);
137:                } catch (IOException e) {
138:                    e.printStackTrace();
139:                } finally {
140:                    try {
141:                        buffWriter.close();
142:                    } catch (IOException e) {
143:                        e.printStackTrace();
144:                    }
145:                }
146:
147:                System.setProperty("jsr94.tck.configuration", tckConf
148:                        .getParent());
149:
150:            }
151:
152:            public static void zipDir(File zipDir, ZipOutputStream zos) {
153:                try {
154:                    String[] dirList = zipDir.list();
155:                    byte[] readBuffer = new byte[2156];
156:                    int bytesIn = 0;
157:                    for (int i = 0; i < dirList.length; i++) {
158:                        File f = new File(zipDir, dirList[i]);
159:                        if (f.isDirectory()) {
160:                            zipDir(f, zos);
161:                            continue;
162:                        }
163:                        FileInputStream fis = new FileInputStream(f);
164:                        ZipEntry anEntry = new ZipEntry(f.getPath());
165:                        zos.putNextEntry(anEntry);
166:                        while ((bytesIn = fis.read(readBuffer)) != -1) {
167:                            zos.write(readBuffer, 0, bytesIn);
168:                        }
169:                        fis.close();
170:                    }
171:                } catch (Exception e) {
172:                    e.printStackTrace();
173:                }
174:            }
175:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.