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


001:        package org.drools.jsr94.rules.admin;
002:
003:        /*
004:         * Copyright 2005 JBoss Inc
005:         * 
006:         * Licensed under the Apache License, Version 2.0 (the "License");
007:         * you may not use this file except in compliance with the License.
008:         * You may obtain a copy of the License at
009:         * 
010:         *      http://www.apache.org/licenses/LICENSE-2.0
011:         * 
012:         * Unless required by applicable law or agreed to in writing, software
013:         * distributed under the License is distributed on an "AS IS" BASIS,
014:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015:         * See the License for the specific language governing permissions and
016:         * limitations under the License.
017:         */
018:
019:        import java.io.IOException;
020:        import java.io.InputStream;
021:        import java.io.InputStreamReader;
022:        import java.util.ArrayList;
023:
024:        import javax.rules.admin.RuleAdministrator;
025:        import javax.rules.admin.RuleExecutionSet;
026:        import javax.rules.admin.RuleExecutionSetProvider;
027:
028:        import org.drools.compiler.PackageBuilder;
029:        import org.drools.jsr94.rules.RuleEngineTestBase;
030:        import org.drools.rule.Package;
031:
032:        /**
033:         * Test the RuleExecutionSetProvider implementation.
034:         *
035:         * @author N. Alex Rupp (n_alex <at>codehaus.org)
036:         * @author <a href="mailto:michael.frandsen@syngenio.de">michael frandsen </a>
037:         */
038:        public class RuleExecutionSetProviderTest extends RuleEngineTestBase {
039:            private RuleAdministrator ruleAdministrator;
040:
041:            private RuleExecutionSetProvider ruleSetProvider;
042:
043:            private Package pkg;
044:
045:            /**
046:             * Setup the test case.
047:             */
048:            protected void setUp() throws Exception {
049:                super .setUp();
050:                this .ruleAdministrator = this .ruleServiceProvider
051:                        .getRuleAdministrator();
052:                this .ruleSetProvider = this .ruleAdministrator
053:                        .getRuleExecutionSetProvider(null);
054:
055:                initPackage();
056:            }
057:
058:            private void initPackage() {
059:                final InputStream resourceAsStream = null;
060:                try {
061:                    final PackageBuilder builder = new PackageBuilder();
062:                    builder.addPackageFromDrl(new InputStreamReader(
063:                            RuleEngineTestBase.class
064:                                    .getResourceAsStream(this .bindUri)));
065:                    final Package pkg = builder.getPackage();
066:
067:                    this .pkg = pkg;
068:                } catch (final IOException e) {
069:                    throw new ExceptionInInitializerError(
070:                            "setUp() could not init the "
071:                                    + "RuleSet due to an IOException in the InputStream: "
072:                                    + e);
073:                } catch (final Exception e) {
074:                    throw new ExceptionInInitializerError(
075:                            "setUp() could not init the RuleSet, " + e);
076:                } finally {
077:                    if (resourceAsStream != null) {
078:                        try {
079:                            resourceAsStream.close();
080:                        } catch (final IOException e) {
081:                            e.printStackTrace();
082:                        }
083:                    }
084:                }
085:            }
086:
087:            protected void tearDown() {
088:                this .pkg = null;
089:            }
090:
091:            //     Rule files are no XML
092:            //    /**
093:            //     * Test createRuleExecutionSet from DOM.
094:            //     */
095:            //    public void testCreateFromElement( ) throws Exception
096:            //    {
097:            //        DOMParser parser = new DOMParser( );
098:            //        Document doc = null;
099:            //        try
100:            //        {
101:            //            parser.parse( new InputSource(
102:            //                RuleEngineTestBase.class.getResourceAsStream( bindUri ) ) );
103:            //            doc = parser.getDocument( );
104:            //        }
105:            //        catch ( SAXException e )
106:            //        {
107:            //            fail( "could not parse incoming data stream: " + e );
108:            //        }
109:            //        catch ( IOException e )
110:            //        {
111:            //            fail( "could not open incoming data stream: " + e );
112:            //        }
113:            //        Element element = null;
114:            //        NodeList children = doc.getChildNodes( );
115:            //        if ( children != null )
116:            //        {
117:            //            for ( int i = 0; i < children.getLength( ); i++ )
118:            //            {
119:            //                Node child = children.item( i );
120:            //                if ( Node.ELEMENT_NODE == child.getNodeType( ) )
121:            //                {
122:            //                    element = ( Element ) child;
123:            //                }
124:            //            }
125:            //        }
126:            //
127:            //        if ( element != null )
128:            //        {
129:            //            RuleExecutionSet testRuleSet =
130:            //                ruleSetProvider.createRuleExecutionSet( element, null );
131:            //            assertEquals(
132:            //                "rule set name", "Sisters Rules", testRuleSet.getName( ) );
133:            //            assertEquals(
134:            //                "number of rules", 1, testRuleSet.getRules( ).size( ) );
135:            //        }
136:            //        else
137:            //        {
138:            //            fail( "could not build an org.w3c.dom.Element" );
139:            //        }
140:            //    }
141:
142:            /**
143:             * Test createRuleExecutionSet from Serializable.
144:             */
145:            public void testCreateFromSerializable() throws Exception {
146:                final RuleExecutionSet ruleExecutionSet = this .ruleSetProvider
147:                        .createRuleExecutionSet(this .pkg, null);
148:                assertEquals("rule set name", "SistersRules", ruleExecutionSet
149:                        .getName());
150:                assertEquals("number of rules", 1, ruleExecutionSet.getRules()
151:                        .size());
152:            }
153:
154:            /**
155:             * Test createRuleExecutionSet from URI.
156:             */
157:            public void testCreateFromURI() throws Exception {
158:                final String rulesUri = RuleEngineTestBase.class.getResource(
159:                        this .bindUri).toExternalForm();
160:                final RuleExecutionSet testRuleSet = this .ruleSetProvider
161:                        .createRuleExecutionSet(rulesUri, null);
162:                assertEquals("rule set name", "SistersRules", testRuleSet
163:                        .getName());
164:                assertEquals("number of rules", 1, testRuleSet.getRules()
165:                        .size());
166:            }
167:
168:            public void testIncompatibleSerializableCreation() throws Exception {
169:                try {
170:                    final RuleExecutionSet testRuleSet = this .ruleSetProvider
171:                            .createRuleExecutionSet(new ArrayList(), null);
172:                    fail("Should have thrown an IllegalArgumentException. ArrayList "
173:                            + "objects are not valid AST representations. "
174:                            + testRuleSet);
175:                } catch (final IllegalArgumentException e) {
176:                    /*
177:                     * this is supposed to happen if you pass in a serializable object
178:                     * that isn't a supported AST representation.
179:                     */
180:                }
181:            }
182:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.