Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/AtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/AtomTest.java?rev=1221321&r1=1221320&r2=1221321&view=diff ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/AtomTest.java (original) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/AtomTest.java Tue Dec 20 15:48:58 2011 @@ -1,70 +1,67 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.stanbol.rules.manager.atoms; import static org.junit.Assert.fail; +import org.apache.stanbol.rules.base.api.JenaClauseEntry; +import org.apache.stanbol.rules.base.api.JenaVariableMap; import org.apache.stanbol.rules.base.api.RuleAtom; +import org.apache.stanbol.rules.manager.JenaVariableMapImpl; import org.junit.Before; -import org.junit.Test; import org.semanticweb.owlapi.apibinding.OWLManager; import org.semanticweb.owlapi.model.OWLDataFactory; import org.semanticweb.owlapi.model.OWLOntologyManager; import org.semanticweb.owlapi.model.SWRLAtom; public abstract class AtomTest { - - - protected OWLDataFactory factory; - - @Before - public void init(){ - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - this.factory = manager.getOWLDataFactory(); - } - - @Test - public abstract void testValidAtomWithVariableArguments(); - - - @Test - public abstract void testValidAtomWithLiteralArguments(); - - - @Test - public abstract void testValidAtomWithTypedLiteralArguments(); - - protected void execTest(RuleAtom ruleAtom){ - String stanbolSyntax = ruleAtom.toKReSSyntax(); - if(stanbolSyntax == null){ - fail(GreaterThanAtom.class.getCanonicalName() + " does not produce any rule in Stanbo syntax."); - } - - String sparql = ruleAtom.toSPARQL().getObject(); - if(sparql == null){ - fail(GreaterThanAtom.class.getCanonicalName() + " does not produce any rule as SPARQL CONSTRUCT."); - } - - SWRLAtom swrlAtom = ruleAtom.toSWRL(factory); - - if(swrlAtom == null){ - fail(GreaterThanAtom.class.getCanonicalName() + " does not produce any rule in SWRL."); - } - } - + + protected OWLDataFactory factory; + + protected JenaVariableMap jenaVariableMap; + + @Before + public void init() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + this.jenaVariableMap = new JenaVariableMapImpl(); + } + + protected void execTest(RuleAtom ruleAtom) { + String stanbolSyntax = ruleAtom.toKReSSyntax(); + if (stanbolSyntax == null) { + fail(this.getClass().getCanonicalName() + " does not produce any rule in Stanbo syntax."); + } + + String sparql = ruleAtom.toSPARQL().getObject(); + if (sparql == null) { + fail(this.getClass().getCanonicalName() + " does not produce any rule as SPARQL CONSTRUCT."); + } + + SWRLAtom swrlAtom = ruleAtom.toSWRL(factory); + if (swrlAtom == null) { + fail(this.getClass().getCanonicalName() + " does not produce any rule in SWRL."); + } + + JenaClauseEntry jenaEntry = ruleAtom.toJenaClauseEntry(jenaVariableMap); + if (jenaEntry == null) { + fail(this.getClass().getCanonicalName() + " does not produce any rule in JENA."); + } + } + }
Added: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/ClassAtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/ClassAtomTest.java?rev=1221321&view=auto ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/ClassAtomTest.java (added) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/ClassAtomTest.java Tue Dec 20 15:48:58 2011 @@ -0,0 +1,52 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stanbol.rules.manager.atoms; + +import java.net.URI; + +import org.apache.stanbol.rules.base.api.RuleAtom; +import org.apache.stanbol.rules.base.api.URIResource; +import org.junit.Before; +import org.junit.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +public class ClassAtomTest extends AtomTest { + + private URIResource classResource; + private URIResource argument1; + + @Before + public void setup() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + + classResource = new ResourceAtom(URI.create("http://kres.iks-project.eu/ontology/meta/resource#Test")); + argument1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), true); + + } + + @Test + public void testValidClassAtomWith() { + + RuleAtom ruleAtom = new ClassAtom(classResource, argument1); + + execTest(ruleAtom); + } + +} Added: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/DatavaluedPropertyAtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/DatavaluedPropertyAtomTest.java?rev=1221321&view=auto ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/DatavaluedPropertyAtomTest.java (added) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/DatavaluedPropertyAtomTest.java Tue Dec 20 15:48:58 2011 @@ -0,0 +1,88 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stanbol.rules.manager.atoms; + +import java.net.URI; +import java.net.URISyntaxException; + +import org.apache.stanbol.rules.base.api.RuleAtom; +import org.apache.stanbol.rules.base.api.URIResource; +import org.junit.Before; +import org.junit.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +import com.hp.hpl.jena.vocabulary.XSD; + +public class DatavaluedPropertyAtomTest extends AtomTest { + + private URIResource datatypeProperty; + private URIResource argument1; + + // argument2 + private Object variable; + private Object literal; + private Object typedLiteral; + + @Before + public void setup() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + + datatypeProperty = new ResourceAtom( + URI.create("http://kres.iks-project.eu/ontology/meta/resource#hasTest")); + argument1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), true); + + variable = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), false); + + literal = "some text"; + + try { + typedLiteral = new TypedLiteralAtom(3.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + + } + + @Test + public void testValidAtomWithVariableArguments() { + + RuleAtom ruleAtom = new DatavaluedPropertyAtom(datatypeProperty, argument1, variable); + + execTest(ruleAtom); + + } + + @Test + public void testValidAtomWithLiteralArguments() { + + RuleAtom ruleAtom = new DatavaluedPropertyAtom(datatypeProperty, argument1, literal); + + execTest(ruleAtom); + } + + @Test + public void testValidAtomWithTypedLiteralArguments() { + + RuleAtom ruleAtom = new DatavaluedPropertyAtom(datatypeProperty, argument1, typedLiteral); + + execTest(ruleAtom); + } + +} Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtomTest.java?rev=1221321&r1=1221320&r2=1221321&view=diff ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtomTest.java (original) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/GreaterThanAtomTest.java Tue Dec 20 15:48:58 2011 @@ -1,19 +1,19 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.stanbol.rules.manager.atoms; @@ -28,65 +28,62 @@ import org.semanticweb.owlapi.model.OWLO import com.hp.hpl.jena.vocabulary.XSD; - public class GreaterThanAtomTest extends AtomTest { - private Object variable1; - private Object variable2; - - private Object literal1; - private Object literal2; - - - private Object typedLiteral1; - private Object typedLiteral2; - - @Before - public void setup() { - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - this.factory = manager.getOWLDataFactory(); - - variable1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), false); - variable2 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#y"), false); - - - literal1 = "some text"; - literal2 = "some other text"; - - try { - typedLiteral1 = new TypedLiteralAtom(3.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); - typedLiteral2 = new TypedLiteralAtom(5.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - - @Test - public void testValidAtomWithVariableArguments() { - - RuleAtom ruleAtom = new GreaterThanAtom(variable1, variable2); - - execTest(ruleAtom); - - } - - - @Test - public void testValidAtomWithLiteralArguments() { - - RuleAtom ruleAtom = new GreaterThanAtom(literal1, literal2); - - execTest(ruleAtom); - } - - - @Test - public void testValidAtomWithTypedLiteralArguments() { - - RuleAtom ruleAtom = new GreaterThanAtom(typedLiteral1, typedLiteral2); - - execTest(ruleAtom); - } - - + private Object variable1; + private Object variable2; + + private Object literal1; + private Object literal2; + + private Object typedLiteral1; + private Object typedLiteral2; + + @Before + public void setup() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + + variable1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), + false); + variable2 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#y"), + false); + + literal1 = "some text"; + literal2 = "some other text"; + + try { + typedLiteral1 = new TypedLiteralAtom(3.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); + typedLiteral2 = new TypedLiteralAtom(5.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + + } + + @Test + public void testValidAtomWithVariableArguments() { + + RuleAtom ruleAtom = new GreaterThanAtom(variable1, variable2); + + execTest(ruleAtom); + + } + + @Test + public void testValidAtomWithLiteralArguments() { + + RuleAtom ruleAtom = new GreaterThanAtom(literal1, literal2); + + execTest(ruleAtom); + } + + @Test + public void testValidAtomWithTypedLiteralArguments() { + + RuleAtom ruleAtom = new GreaterThanAtom(typedLiteral1, typedLiteral2); + + execTest(ruleAtom); + } + } Added: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtomTest.java?rev=1221321&view=auto ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtomTest.java (added) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/IndividualPropertyAtomTest.java Tue Dec 20 15:48:58 2011 @@ -0,0 +1,55 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.stanbol.rules.manager.atoms; + +import java.net.URI; + +import org.apache.stanbol.rules.base.api.RuleAtom; +import org.apache.stanbol.rules.base.api.URIResource; +import org.junit.Before; +import org.junit.Test; +import org.semanticweb.owlapi.apibinding.OWLManager; +import org.semanticweb.owlapi.model.OWLOntologyManager; + +public class IndividualPropertyAtomTest extends AtomTest { + + private URIResource objectProperty; + private URIResource argument1; + private URIResource argument2; + + @Before + public void setup() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + + objectProperty = new ResourceAtom( + URI.create("http://kres.iks-project.eu/ontology/meta/resource#hasTest")); + argument1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), true); + argument2 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#y"), true); + + } + + @Test + public void testValidIndividualPropertyAtomWith() { + + RuleAtom ruleAtom = new IndividualPropertyAtom(objectProperty, argument1, argument2); + + execTest(ruleAtom); + } + +} Modified: incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/LessThanAtomTest.java URL: http://svn.apache.org/viewvc/incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/LessThanAtomTest.java?rev=1221321&r1=1221320&r2=1221321&view=diff ============================================================================== --- incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/LessThanAtomTest.java (original) +++ incubator/stanbol/trunk/rules/manager/src/test/java/org/apache/stanbol/rules/manager/atoms/LessThanAtomTest.java Tue Dec 20 15:48:58 2011 @@ -1,19 +1,19 @@ /* -* Licensed to the Apache Software Foundation (ASF) under one or more -* contributor license agreements. See the NOTICE file distributed with -* this work for additional information regarding copyright ownership. -* The ASF licenses this file to You under the Apache License, Version 2.0 -* (the "License"); you may not use this file except in compliance with -* the License. You may obtain a copy of the License at -* -* http://www.apache.org/licenses/LICENSE-2.0 -* -* Unless required by applicable law or agreed to in writing, software -* distributed under the License is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* See the License for the specific language governing permissions and -* limitations under the License. -*/ + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ package org.apache.stanbol.rules.manager.atoms; @@ -29,63 +29,60 @@ import org.semanticweb.owlapi.model.OWLO import com.hp.hpl.jena.vocabulary.XSD; public class LessThanAtomTest extends AtomTest { - - private Object variable1; - private Object variable2; - - private Object literal1; - private Object literal2; - - - private Object typedLiteral1; - private Object typedLiteral2; - - @Before - public void setup() { - OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); - this.factory = manager.getOWLDataFactory(); - - variable1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), false); - variable2 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#y"), false); - - - literal1 = "some text"; - literal2 = "some other text"; - - try { - typedLiteral1 = new TypedLiteralAtom(3.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); - typedLiteral2 = new TypedLiteralAtom(5.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); - } catch (URISyntaxException e) { - e.printStackTrace(); - } - } - - @Test - public void testValidAtomWithVariableArguments() { - - RuleAtom ruleAtom = new LessThanAtom(variable1, variable2); - - execTest(ruleAtom); - - } - - - @Test - public void testValidAtomWithLiteralArguments() { - - RuleAtom ruleAtom = new GreaterThanAtom(literal1, literal2); - - execTest(ruleAtom); - } - - - @Test - public void testValidAtomWithTypedLiteralArguments() { - - RuleAtom ruleAtom = new GreaterThanAtom(typedLiteral1, typedLiteral2); - - execTest(ruleAtom); - } - - + + private Object variable1; + private Object variable2; + + private Object literal1; + private Object literal2; + + private Object typedLiteral1; + private Object typedLiteral2; + + @Before + public void setup() { + OWLOntologyManager manager = OWLManager.createOWLOntologyManager(); + this.factory = manager.getOWLDataFactory(); + + variable1 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#x"), + false); + variable2 = new VariableAtom(URI.create("http://kres.iks-project.eu/ontology/meta/variables#y"), + false); + + literal1 = "some text"; + literal2 = "some other text"; + + try { + typedLiteral1 = new TypedLiteralAtom(3.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); + typedLiteral2 = new TypedLiteralAtom(5.0, new ResourceAtom(new URI(XSD.xdouble.getURI()))); + } catch (URISyntaxException e) { + e.printStackTrace(); + } + } + + @Test + public void testValidAtomWithVariableArguments() { + + RuleAtom ruleAtom = new LessThanAtom(variable1, variable2); + + execTest(ruleAtom); + + } + + @Test + public void testValidAtomWithLiteralArguments() { + + RuleAtom ruleAtom = new LessThanAtom(literal1, literal2); + + execTest(ruleAtom); + } + + @Test + public void testValidAtomWithTypedLiteralArguments() { + + RuleAtom ruleAtom = new LessThanAtom(typedLiteral1, typedLiteral2); + + execTest(ruleAtom); + } + }
