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 javax.rules.admin.LocalRuleExecutionSetProvider;
20: import javax.rules.admin.RuleAdministrator;
21: import javax.rules.admin.RuleExecutionSetDeregistrationException;
22: import javax.rules.admin.RuleExecutionSetProvider;
23: import javax.rules.admin.RuleExecutionSetRegisterException;
24:
25: import org.drools.jsr94.rules.RuleEngineTestBase;
26:
27: /**
28: * Test the RuleRuntime implementation.
29: *
30: * @author N. Alex Rupp (n_alex <at>codehaus.org)
31: * @author <a href="mailto:thomas.diesler@softcon-itec.de">thomas diesler </a>
32: */
33: public class RuleAdministratorTest extends RuleEngineTestBase {
34: private RuleAdministrator ruleAdministrator;
35:
36: /**
37: * Obtain an instance of <code>RuleAdministrator</code>.
38: */
39: protected void setUp() throws Exception {
40: super .setUp();
41: this .ruleAdministrator = this .ruleServiceProvider
42: .getRuleAdministrator();
43: }
44:
45: /**
46: * Test getRuleExecutionSetProvider.
47: */
48: public void testRuleExecutionSetProvider() throws Exception {
49: final RuleExecutionSetProvider ruleExecutionSetProvider = this .ruleAdministrator
50: .getRuleExecutionSetProvider(null);
51: assertNotNull("cannot obtain RuleExecutionSetProvider",
52: ruleExecutionSetProvider);
53: }
54:
55: /**
56: * Test getLocalRuleExecutionSetProvider.
57: */
58: public void testLocalRuleExecutionSetProvider() throws Exception {
59: final LocalRuleExecutionSetProvider localRuleExecutionSetProvider = this .ruleAdministrator
60: .getLocalRuleExecutionSetProvider(null);
61: assertNotNull("cannot obtain LocalRuleExecutionSetProvider",
62: localRuleExecutionSetProvider);
63: }
64:
65: /**
66: * Test registerRuleExecutionSet.
67: */
68: public void testRegisterRuleExecutionSet() throws Exception {
69: try {
70: // that it works is tested elsewhere
71: this .ruleAdministrator.registerRuleExecutionSet("test URI",
72: null, null);
73: fail("RuleExecutionSetRegisterException expected");
74: } catch (final RuleExecutionSetRegisterException ex) {
75: // ignore exception
76: }
77: }
78:
79: /**
80: * Test deregisterRuleExecutionSet.
81: */
82: public void testDeregisterRuleExecutionSet() throws Exception {
83: try {
84: // that it works is tested else where
85: this .ruleAdministrator.deregisterRuleExecutionSet(
86: "test URI", null);
87: fail("RuleExecutionSetUnregisterException expected");
88: } catch (final RuleExecutionSetDeregistrationException ex) {
89: // ignore exception
90: }
91: }
92: }
|