01: /*
02: (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
03: All rights reserved - see end of file.
04: $Id: TestRuleSet.java,v 1.4 2008/01/02 12:05:55 andy_seaborne Exp $
05: */
06:
07: package com.hp.hpl.jena.assembler.test;
08:
09: import java.util.*;
10:
11: import com.hp.hpl.jena.assembler.RuleSet;
12: import com.hp.hpl.jena.reasoner.rulesys.Rule;
13: import com.hp.hpl.jena.shared.BrokenException;
14:
15: public class TestRuleSet extends AssemblerTestBase {
16: public TestRuleSet(String name) {
17: super (name);
18: }
19:
20: protected Class getAssemblerClass() {
21: throw new BrokenException(
22: "TestAssemblers does not need this method");
23: }
24:
25: public void testEmpty() {
26: assertEquals(Collections.EMPTY_LIST, RuleSet.empty.getRules());
27: assertEquals(RuleSet.empty, RuleSet
28: .create(Collections.EMPTY_LIST));
29: }
30:
31: public void testEmptyRuleSet() {
32: RuleSet s = RuleSet.create(Collections.EMPTY_LIST);
33: assertEquals(Collections.EMPTY_LIST, s.getRules());
34: assertNotSame(Collections.EMPTY_LIST, s.getRules());
35: }
36:
37: public void testSingleRuleSet() {
38: Rule rule = Rule.parseRule("[(?a P b) -> (?a rdf:type T)]");
39: List list = listOfOne(rule);
40: RuleSet s = RuleSet.create(list);
41: assertEquals(list, s.getRules());
42: assertNotSame(list, s.getRules());
43: }
44:
45: public void testMultipleRuleSet() {
46: Rule A = Rule.parseRule("[(?a P b) -> (?a rdf:type T)]");
47: Rule B = Rule.parseRule("[(?a Q b) -> (?a rdf:type U)]");
48: List rules = Arrays.asList(new Rule[] { A, B });
49: RuleSet s = RuleSet.create(rules);
50: assertEquals(rules, s.getRules());
51: assertNotSame(rules, s.getRules());
52: }
53:
54: public void testFactoryForString() {
55: String ruleString = "[(?a P b) -> (?a rdf:type T)]";
56: RuleSet s = RuleSet.create(ruleString);
57: assertEquals(Rule.parseRules(ruleString), s.getRules());
58: }
59: }
60:
61: /*
62: * (c) Copyright 2005, 2006, 2007, 2008 Hewlett-Packard Development Company, LP
63: * All rights reserved.
64: *
65: * Redistribution and use in source and binary forms, with or without
66: * modification, are permitted provided that the following conditions
67: * are met:
68: * 1. Redistributions of source code must retain the above copyright
69: * notice, this list of conditions and the following disclaimer.
70: * 2. Redistributions in binary form must reproduce the above copyright
71: * notice, this list of conditions and the following disclaimer in the
72: * documentation and/or other materials provided with the distribution.
73: * 3. The name of the author may not be used to endorse or promote products
74: * derived from this software without specific prior written permission.
75: *
76: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
77: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
78: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
79: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
80: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
81: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
82: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
83: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
84: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
85: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
86: */
|