01: package org.drools.jsr94.rules.admin;
02:
03: /*
04: * Copyright 2005 JBoss Inc
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing, software
13: * distributed under the License is distributed on an "AS IS" BASIS,
14: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15: * See the License for the specific language governing permissions and
16: * limitations under the License.
17: */
18:
19: import java.io.InputStream;
20: import java.util.List;
21:
22: import javax.rules.admin.LocalRuleExecutionSetProvider;
23: import javax.rules.admin.Rule;
24: import javax.rules.admin.RuleAdministrator;
25: import javax.rules.admin.RuleExecutionSet;
26:
27: import org.drools.jsr94.rules.RuleEngineTestBase;
28:
29: /**
30: * Test the LocalRuleExecutionSetProvider implementation.
31: *
32: * @author N. Alex Rupp (n_alex <at>codehaus.org)
33: * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
34: * @author <a href="mailto:michael.frandsen@syngenio.de">michael frandsen </a>
35: */
36: public class RuleTest extends RuleEngineTestBase {
37: private RuleAdministrator ruleAdministrator;
38:
39: private LocalRuleExecutionSetProvider ruleSetProvider;
40:
41: /**
42: * Setup the test case.
43: */
44: protected void setUp() throws Exception {
45: super .setUp();
46: this .ruleAdministrator = this .ruleServiceProvider
47: .getRuleAdministrator();
48: this .ruleSetProvider = this .ruleAdministrator
49: .getLocalRuleExecutionSetProvider(null);
50: }
51:
52: /**
53: * Test rule name and description.
54: */
55: public void testRule() throws Exception {
56: final InputStream in = RuleEngineTestBase.class
57: .getResourceAsStream(this .bindUri);
58: final RuleExecutionSet ruleExecutionSet = this .ruleSetProvider
59: .createRuleExecutionSet(in, null);
60: final List rules = ruleExecutionSet.getRules();
61: assertEquals("number of rules", 1, rules.size());
62:
63: final Rule rule01 = (Rule) ruleExecutionSet.getRules().get(0);
64: assertEquals("rule name", "FindSisters", rule01.getName());
65: assertEquals("rule description", "FindSisters", rule01
66: .getDescription());
67: }
68: }
|