Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSAddRuleTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSAddRuleTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSAddRuleTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSAddRuleTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,185 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSAddRule;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSAddRuleTest {
+
+    public KReSAddRuleTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       onm = new ONManager(null, new Hashtable<String, Object>());
+       store = new KReSRuleStore(onm, 
configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+    }
+
+    @After
+    public void tearDown() {
+       store = null;
+       onm = null;
+    }
+
+    public RuleStore store = null;
+    public KReSONManager onm = null;
+
+    /**
+     * Test of addRule method, of class KReSAddRule.
+     */
+    @Test
+    public void testAddRule_3args_1() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+
+        String ruleName = "MyRuleA";
+        String ruleBodyHead = "MyRuleABody -> MyRuleAHead";
+        String ruleDescription = "My comment to the rule A";
+        KReSAddRule instance = new KReSAddRule(store);
+        
+        boolean result = instance.addRule(ruleName, ruleBodyHead, 
ruleDescription);
+        OWLOntology newonto = instance.getStore().getOntology();
+        String ID = 
newonto.getOntologyID().toString().replace("<","").replace(">","")+"#";
+
+       if(result){
+            OWLNamedIndividual ruleind = 
newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID
 + "MyRuleA"));
+            int axiom = newonto.getAxioms(ruleind).size();
+            assertEquals(3,axiom);
+            // TODO review the generated test code and remove the default call 
to fail.
+        }else{
+            fail("Some problem occurs with addRule of KReSAddRule");
+        }
+    }
+
+    /**
+     * Test of addRule method, of class KReSAddRule.
+     */
+    @Test
+    public void testAddRule_3args_2() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = 
owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
+        IRI ruleName = IRI.create(ID+"MyRuleA");
+        String ruleBodyHead = "MyRuleABody -> MyRuleAHead";
+        String ruleDescription = "My comment to the rule A";
+        KReSAddRule instance = new KReSAddRule(store);
+
+        boolean result = instance.addRule(ruleName, ruleBodyHead, 
ruleDescription);
+        OWLOntology newonto = instance.getStore().getOntology();
+
+       if(result){
+            OWLNamedIndividual ruleind = 
newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(ruleName);
+            int axiom = newonto.getAxioms(ruleind).size();
+            assertEquals(3,axiom);
+            // TODO review the generated test code and remove the default call 
to fail.
+        }else{
+            fail("Some problem occurs with addRule of KReSAddRule");
+        }
+    }
+
+    /**
+     * Test of addRuleMap method, of class KReSAddRule.
+     */
+    @Test
+    public void testAddRuleMap() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = 
owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
+        HashMap<String, String> ruleBodyHeadMap = new HashMap();
+        HashMap<String, String> ruleDescriptionMap = new HashMap();
+
+        ruleBodyHeadMap.put("MyRuleA","MyRuleABody -> MyRuleAHead");
+        ruleBodyHeadMap.put("MyRuleB","MyRuleBBody -> MyRuleBHead");
+        ruleDescriptionMap.put("MyRuleA","My comment to the rule A");
+        ruleDescriptionMap.put("MyRuleB","My comment to the rule B");
+
+        KReSAddRule instance = new KReSAddRule(store);
+       
+        boolean result = instance.addRuleMap(ruleBodyHeadMap, 
ruleDescriptionMap);
+        OWLOntology newonto = instance.getStore().getOntology();
+
+       if(result){
+            Iterator<String> keys = ruleBodyHeadMap.keySet().iterator();
+            int axiom = 0;
+            while(keys.hasNext()){
+                OWLNamedIndividual ruleind = 
newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(IRI.create(ID+keys.next()));
+                axiom = axiom + newonto.getAxioms(ruleind).size();
+            }
+            assertEquals(6,axiom);
+            // TODO review the generated test code and remove the default call 
to fail.
+        }else{
+            fail("Some problem occurs with addRuleMap of KReSAddRule");
+        }
+    }
+
+    /**
+     * Test of addRuleMapIRI method, of class KReSAddRule.
+     */
+    @Test
+    public void testAddRuleMapIRI() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = 
owl.getOntologyID().toString().replace("<","").replace(">","")+"#";
+        HashMap<IRI, String> ruleBodyHeadMap = new HashMap();
+        HashMap<IRI, String> ruleDescriptionMap = new HashMap();
+
+        ruleBodyHeadMap.put(IRI.create(ID+"MyRuleA"),"MyRuleABody -> 
MyRuleAHead");
+        ruleBodyHeadMap.put(IRI.create(ID+"MyRuleB"),"MyRuleBBody -> 
MyRuleBHead");
+        ruleDescriptionMap.put(IRI.create(ID+"MyRuleA"),"My comment to the 
rule A");
+        ruleDescriptionMap.put(IRI.create(ID+"MyRuleB"),"My comment to the 
rule B");
+
+        KReSAddRule instance = new KReSAddRule(store);
+
+        boolean result = instance.addRuleMapIRI(ruleBodyHeadMap, 
ruleDescriptionMap);
+        OWLOntology newonto = instance.getStore().getOntology();
+
+       if(result){
+            Iterator<IRI> keys = ruleBodyHeadMap.keySet().iterator();
+            int axiom = 0;
+            while(keys.hasNext()){
+                OWLNamedIndividual ruleind = 
newonto.getOWLOntologyManager().getOWLDataFactory().getOWLNamedIndividual(keys.next());
+                axiom = axiom + newonto.getAxioms(ruleind).size();
+            }
+            assertEquals(6,axiom);
+            // TODO review the generated test code and remove the default call 
to fail.
+        }else{
+            fail("Some problem occurs with addRuleMap of KReSAddRule");
+        }
+    }
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRecipeTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRecipeTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRecipeTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRecipeTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,115 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSGetRecipe;
+import org.apache.stanbol.rules.manager.changes.KReSLoadRuleFile;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSGetRecipeTest {
+
+    public KReSGetRecipeTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       onm = new ONManager(null, new Hashtable<String, Object>());
+       store = new KReSRuleStore(onm, 
configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+    }
+
+    @After
+    public void tearDown() {
+       store = null;
+       onm = null;
+    }
+
+    public RuleStore store = null;
+    public KReSONManager onm = null;
+
+    /**
+     * Test of getRule method, of class KReSGetRecipe.
+     */
+    @Test
+    public void testGetRecipe() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+        KReSGetRecipe rule = new KReSGetRecipe(store);
+        HashMap<IRI, String> map = 
rule.getRecipe(IRI.create("http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRecipe";));
+        HashMap<IRI, String> expmap = new HashMap();
+        expmap.put(IRI.create(ID+"MyRecipe"), 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA";);
+        if(map!=null){
+         assertEquals(expmap, map);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method GetRecipe of KReSGetRecipe");
+        }
+    }
+
+    /**
+     * Test of getAllRecipes method, of class KReSGetRecipe.
+     */
+    @Test
+    public void testGetAllRecipes() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+
+        KReSGetRecipe rule = new KReSGetRecipe(store);
+
+        HashMap<IRI, String> map = rule.getAllRecipes();
+        HashMap<IRI, String> expmap = new HashMap();
+        expmap.put(IRI.create(ID+"MyRecipe"), 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA";);
+        expmap.put(IRI.create(ID+"MyRecipe2"), 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleE, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD";);
+        expmap.put(IRI.create(ID+"MyRecipe3"), 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF";);
+        expmap.put(IRI.create(ID+"MyRecipe4"), 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD";);
+
+        if(map!=null){
+         assertEquals(expmap, map);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method GetAllRecipe of KReSGetRecipe");
+        }
+    }
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRuleTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRuleTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRuleTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSGetRuleTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,179 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Vector;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSGetRule;
+import org.apache.stanbol.rules.manager.changes.KReSLoadRuleFile;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSGetRuleTest {
+
+    public KReSGetRuleTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       onm = new ONManager(null, new Hashtable<String, Object>());
+       store = new KReSRuleStore(onm, 
configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+    }
+
+    @After
+    public void tearDown() {
+       store = null;
+       onm = null;
+    }
+
+    public RuleStore store = null;
+    public KReSONManager onm = null;
+
+    /**
+     * Test of getRule method, of class KReSGetRule.
+     */
+    @Test
+    public void testGetRule() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+        
+        KReSGetRule rule = new KReSGetRule(store);
+        HashMap<IRI, String> map = rule.getRule("MyRuleC");
+        HashMap<IRI, String> expmap = new HashMap();
+        expmap.put(IRI.create(ID+"MyRuleC"), "MyRuleCBody -> MyRuleCHead");
+        if(map!=null){
+         assertEquals(expmap, map);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method GetRule of KReSGetRule");
+        }
+    }
+
+    /**
+     * Test of getAllRule method, of class KReSGetRule.
+     */
+    @Test
+    public void testGetAllRule() {
+//        KReSRuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+
+        KReSGetRule rule = new KReSGetRule(store);
+    
+        HashMap<IRI, String> map = rule.getAllRules();
+        HashMap<IRI, String> expmap = new HashMap();
+        //MyRuleX
+        String rulex = "PREFIX var http://kres.iksproject.eu/rules# ." +
+                 "PREFIX dbs 
http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl# ." +
+                 "PREFIX lmm 
http://www.ontologydesignpatterns.org/ont/lmm/LMM_L1.owl# ." +
+                 "rule1[dbs:Table(?x) -> lmm:Meaning(?x)]";
+        
+        expmap.put(IRI.create(ID+"MyRuleA"), "MyRuleABody -> MyRuleAHead");
+        expmap.put(IRI.create(ID+"MyRuleB"), "MyRuleBBody -> MyRuleBHead");
+        expmap.put(IRI.create(ID+"MyRuleC"), "MyRuleCBody -> MyRuleCHead");
+        expmap.put(IRI.create(ID+"MyRuleD"), "MyRuleDBody -> MyRuleDHead");
+        expmap.put(IRI.create(ID+"MyRuleE"), "MyRuleEBody -> MyRuleEHead");
+        expmap.put(IRI.create(ID+"MyRuleF"), "MyRuleFBody -> MyRuleFHead");
+        expmap.put(IRI.create(ID+"MyRuleX"),rulex);
+
+        if(map!=null){
+            Iterator<IRI> key = map.keySet().iterator();
+            int m = 0;
+            while(key.hasNext()){
+                IRI k = key.next();
+                if(expmap.keySet().contains(k))
+                    if(expmap.get(k).equals(map.get(k)))
+                        m++;
+            }
+
+         assertEquals(expmap.size(),m);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method GetAllRule of KReSGetRule");
+        }
+    }
+
+    /**
+     * Test of getRule method, of class KReSGetRule.
+     */
+    @Test
+    public void testGetRuleUsage() {
+//        KReSRuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+
+        KReSGetRule rule = new KReSGetRule(store);
+        Vector<IRI> vector = rule.getRuleUsage(IRI.create(ID + "MyRuleC"));
+ 
+        if(vector!=null){
+         assertEquals(2, vector.size());
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method getRuleUsage of KReSGetRule");
+        }
+    }
+    
+    @Test
+    public void testGetRulesOfRecipe() {
+//        KReSRuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        OWLOntology owl = store.getOntology();
+        String ID = owl.getOntologyID().toString().replace("<", 
"").replace(">", "")+"#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        owl = load.getStore().getOntology();
+
+        KReSGetRule rule = new KReSGetRule(store);
+        Vector<IRI> vector = rule.getRuleUsage(IRI.create(ID + "MyRuleC"));
+ 
+        if(vector!=null){
+         assertEquals(2, vector.size());
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+          fail("Some error occurs for method getRuleUsage of KReSGetRule");
+        }
+    }
+
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSLoadRuleFileTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSLoadRuleFileTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSLoadRuleFileTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSLoadRuleFileTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,306 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSLoadRuleFile;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLAxiom;
+import org.semanticweb.owlapi.model.OWLClass;
+import org.semanticweb.owlapi.model.OWLClassAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLDataFactory;
+import org.semanticweb.owlapi.model.OWLDataProperty;
+import org.semanticweb.owlapi.model.OWLDataPropertyAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLNamedIndividual;
+import org.semanticweb.owlapi.model.OWLObjectProperty;
+import org.semanticweb.owlapi.model.OWLObjectPropertyAssertionAxiom;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSLoadRuleFileTest {
+
+    public KReSLoadRuleFileTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+    }
+
+    @After
+    public void tearDown() {
+    }
+
+    /**
+     * Test of KReSLoadRuleFile method, of class KReSLoadRuleFile.
+     */
+    @Test
+    public void testKReSLoadRuleFile() throws OWLOntologyStorageException {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       KReSONManager onm = new ONManager(null,configuration);
+       Dictionary<String, Object> configuration2 = new Hashtable<String, 
Object>();
+//     configuration2.put(KReSRuleStore.RULE_ONTOLOGY, "");
+       configuration2.put(KReSRuleStore.RULE_ONTOLOGY_NAMESPACE, 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#";);
+        RuleStore store  = new 
KReSRuleStore(onm,configuration2,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        RuleStore newstore = new KReSRuleStore(new 
ONManager(null,configuration),configuration2,store.getOntology());
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        OWLOntology result = load.getStore().getOntology();
+
+
+        ////////////////////////////////////////////////////////////////////
+        //Create ontology
+        OWLOntologyManager owlmanager = OWLManager.createOWLOntologyManager();
+        OWLOntology owlmodel = newstore.getOntology();
+        OWLDataFactory factory = owlmanager.getOWLDataFactory();
+        String ID = 
owlmodel.getOntologyID().toString().replace("<","").replace(">","")+"#";
+        System.out.println(ID);
+        //KReSRule
+        OWLClass ontocls = factory.getOWLClass(IRI.create(ID + "KReSRule"));
+
+        //MyRuleX
+        String rule = "PREFIX var http://kres.iksproject.eu/rules# ." +
+                 "PREFIX dbs 
http://andriry.altervista.org/tesiSpecialistica/dbs_l1.owl# ." +
+                 "PREFIX lmm 
http://www.ontologydesignpatterns.org/ont/lmm/LMM_L1.owl# ." +
+                 "rule1[dbs:Table(?x) -> lmm:Meaning(?x)]";
+        OWLNamedIndividual ontoind = 
factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleX"));
+        OWLClassAssertionAxiom classAssertion = 
factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        OWLDataProperty dataprop = 
factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        OWLDataPropertyAssertionAxiom dataPropAssertion = 
factory.getOWLDataPropertyAssertionAxiom(dataprop, ontoind, "My comment to the 
rule X");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,rule);
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleA
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleA"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule A");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleABody -> MyRuleAHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleB
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleB"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule B");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleBBody -> MyRuleBHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleC
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleC"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule C");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleCBody -> MyRuleCHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleD
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleD"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule D");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleDBody -> MyRuleDHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleE
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleE"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule E");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleEBody -> MyRuleEHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //MyRuleF
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRuleF"));
+        classAssertion = factory.getOWLClassAssertionAxiom(ontocls, ontoind);
+        owlmanager.addAxiom(owlmodel, classAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the rule F");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasBodyAndHead"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"MyRuleFBody -> MyRuleFHead");
+        owlmanager.addAxiom(owlmodel,dataPropAssertion);
+
+        //Recipe
+        ontocls = factory.getOWLClass(IRI.create(ID + "Recipe"));
+
+        //Add sequence
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the recipe");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+
+        OWLObjectProperty objprop = 
factory.getOWLObjectProperty(IRI.create(ID+"hasRule"));
+
+        OWLNamedIndividual ruleind = 
factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleC"));
+        OWLObjectPropertyAssertionAxiom objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleB"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleA"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"startWith"));
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleC"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop,ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"endWith"));
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleA"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop,ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = 
factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes";));
+        OWLNamedIndividual ruleindp = 
factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleC"));
+        OWLNamedIndividual ruleindf = 
factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleB"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ruleindp, ruleindf);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ruleindp = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleB"));
+        ruleindf = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleA"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ruleindp, ruleindf);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasSequence"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleC, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleB, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleA";);
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+
+        //Add sequence
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe2"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the recipe 2");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"hasRule"));
+
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleD"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleE"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"startWith"));
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleE"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop,ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"endWith"));
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleD"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop,ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = 
factory.getOWLObjectProperty(IRI.create("http://www.ontologydesignpatterns.org/cp/owl/sequence.owl#directlyPrecedes";));
+        ruleindp = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleE"));
+        ruleindf = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleD"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ruleindp, ruleindf);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe2"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasSequence"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleE, 
http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleD";);
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+
+        //Add sequence
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe3"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasDescription"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind, "My comment to the recipe 3");
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"hasRule"));
+
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleF"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop, ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        objprop = factory.getOWLObjectProperty(IRI.create(ID+"startWith"));
+        ruleind = factory.getOWLNamedIndividual(IRI.create(ID+"MyRuleF"));
+        objectPropAssertion = 
factory.getOWLObjectPropertyAssertionAxiom(objprop,ontoind, ruleind);
+        owlmanager.addAxiom(owlmodel,objectPropAssertion);
+
+        ontoind = factory.getOWLNamedIndividual(IRI.create(ID + "MyRecipe3"));
+        dataprop = factory.getOWLDataProperty(IRI.create(ID+"hasSequence"));
+        dataPropAssertion = factory.getOWLDataPropertyAssertionAxiom(dataprop, 
ontoind,"http://kres.iks-project.eu/ontology/meta/rmi.owl#MyRuleF";);
+        owlmanager.addAxiom(owlmodel, dataPropAssertion);
+        ////////////////////////////////////////////////////////////////////
+
+        //Get axiom
+        int numexp = owlmodel.getAxiomCount();
+        Set<OWLAxiom> expaxiom = owlmodel.getAxioms();
+        int numres = result.getAxiomCount();
+       if(result!=null){
+            int num = 0;
+            Iterator<OWLAxiom> axiom = result.getAxioms().iterator();
+
+            while(axiom.hasNext()){
+
+                OWLAxiom ax = axiom.next();
+                if(expaxiom.contains(ax))
+                    num++;
+            }
+        System.out.println(numexp+" "+numres+" "+num+" "+numres);
+        assertEquals(numexp-numres, num-numres);
+        //assertEquals(numexp,(numres+12));
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{
+            fail("Some problem accours");
+        }
+    }
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRecipeTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRecipeTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRecipeTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRecipeTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,109 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSLoadRuleFile;
+import org.apache.stanbol.rules.manager.changes.KReSRemoveRecipe;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSRemoveRecipeTest {
+
+    public KReSRemoveRecipeTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       onm = new ONManager(null, new Hashtable<String, Object>());
+       store = new KReSRuleStore(onm, 
configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+    }
+
+    @After
+    public void tearDown() {
+       store = null;
+       onm = null;
+    }
+
+    public RuleStore store = null;
+    public KReSONManager onm = null;
+
+    /**
+     * Test of removeRule method, of class KReSRemoveRecipe.
+     */
+    @Test
+    public void testRemoveRule_String() throws OWLOntologyCreationException {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        String owlID = 
store.getOntology().getOntologyID().toString().replace("<", "").replace(">", 
"") + "#";
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        OWLOntology owlstart = load.getStore().getOntology();
+        String recipeName = owlID+"MyRecipe";
+        KReSRemoveRecipe instance = new KReSRemoveRecipe(load.getStore());
+
+        boolean expResult = true;
+        boolean result = instance.removeRecipe(IRI.create(recipeName));
+        OWLOntology owlend = instance.getStore().getOntology();
+
+        if(result){
+        
assertEquals(expResult,(owlstart.getAxiomCount()>owlend.getAxiomCount()));
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{fail("Some errors occur with removeRule of KReSRemoveRule.");}
+    }
+
+    /**
+     * Test of removeRule method, of class KReSRemoveRecipe.
+     */
+    @Test
+    public void testRemoveRuleName_String() throws 
OWLOntologyCreationException {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        OWLOntology owlstart = load.getStore().getOntology();
+        String recipeName ="MyRecipe";
+        KReSRemoveRecipe instance = new KReSRemoveRecipe(load.getStore());
+
+        boolean expResult = true;
+        boolean result = instance.removeRecipe(recipeName);
+        OWLOntology owlend = instance.getStore().getOntology();
+
+        if(result){
+        
assertEquals(expResult,(owlstart.getAxiomCount()>owlend.getAxiomCount()));
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{fail("Some errors occur with removeRule of KReSRemoveRule.");}
+    }
+
+   
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRuleTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRuleTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRuleTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRemoveRuleTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,105 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
+
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.stanbol.ontologymanager.ontonet.api.KReSONManager;
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSAddRule;
+import org.apache.stanbol.rules.manager.changes.KReSLoadRuleFile;
+import org.apache.stanbol.rules.manager.changes.KReSRemoveRule;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.model.IRI;
+import org.semanticweb.owlapi.model.OWLOntologyStorageException;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSRemoveRuleTest {
+
+    public KReSRemoveRuleTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+       Dictionary<String, Object> configuration = new Hashtable<String, 
Object>();
+       onm = new ONManager(null, new Hashtable<String, Object>());
+       store = new KReSRuleStore(onm, 
configuration,"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+    }
+
+    @After
+    public void tearDown() {
+       store = null;
+       onm = null;
+    }
+
+    public RuleStore store = null;
+    public KReSONManager onm = null;
+
+    /**
+     * Test of removeRule method, of class KReSRemoveRule.
+     */
+    @Test
+    public void testRemoveRule() {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        KReSAddRule rule = new KReSAddRule(load.getStore());
+        rule.addRule("MyRuleProva","Body -> Head",null);
+        String ruleName = "MyRuleProva";
+        KReSRemoveRule instance = new KReSRemoveRule(rule.getStore());
+        boolean expResult = true;
+        boolean result = instance.removeRule(ruleName);
+        if(result){
+        assertEquals(expResult, result);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{fail("Some errors occur with removeRule of KReSRemoveRule.");}
+    }
+
+    /**
+     * Test of removeRule method, of class KReSRemoveRule.
+     */
+    @Test
+    public void testRemoveSingleRule() throws OWLOntologyStorageException {
+//        RuleStore store  = new 
KReSRuleStore("./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+        String owlID = 
store.getOntology().getOntologyID().toString().replace("<", "").replace(">", 
"") + "#";
+
+        //Load the example file
+        KReSLoadRuleFile load = new 
KReSLoadRuleFile("./src/main/resources/RuleOntology/TestRuleFileExample.txt",store);
+        IRI rule = IRI.create(owlID+"MyRuleB");
+        IRI recipe = IRI.create(owlID+"MyRecipe");
+        KReSRemoveRule instance = new KReSRemoveRule(load.getStore());
+        boolean expResult = true;
+        boolean result = instance.removeRuleFromRecipe(rule, recipe);
+       
+        if(result){
+            assertEquals(expResult, result);
+        // TODO review the generated test code and remove the default call to 
fail.
+        }else{fail("Some errors occur with removeRule of KReSRemoveRule.");}
+    }
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRuleStoreTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRuleStoreTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRuleStoreTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/KReSRuleStoreTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,102 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+package org.apache.stanbol.rules.manager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.Dictionary;
+import java.util.Hashtable;
+
+import org.apache.stanbol.ontologymanager.ontonet.impl.ONManager;
+import org.apache.stanbol.rules.base.api.RuleStore;
+import org.apache.stanbol.rules.manager.changes.KReSRuleStore;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.semanticweb.owlapi.apibinding.OWLManager;
+import org.semanticweb.owlapi.model.OWLOntology;
+import org.semanticweb.owlapi.model.OWLOntologyCreationException;
+import org.semanticweb.owlapi.model.OWLOntologyManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ *
+ * @author elvio
+ */
+public class KReSRuleStoreTest {
+
+       private Logger log = LoggerFactory.getLogger(getClass());
+
+    public KReSRuleStoreTest() {
+    }
+
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+    }
+
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+    }
+
+    @Before
+    public void setUp() {
+               Dictionary<String, Object> configuration = new 
Hashtable<String, Object>();
+               store = new KReSRuleStore(new ONManager(null, configuration),
+                               configuration,
+                               
"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl");
+               blankStore = new KReSRuleStore(new ONManager(null, 
configuration),
+                               configuration, "");
+    }
+
+    @After
+    public void tearDown() {
+               store = null;
+               blankStore = null;
+    }
+
+       public RuleStore store = null, blankStore = null;
+
+    @Test
+    public void testKReSRuleStore(){
+        OWLOntology owlmodel = store.getOntology();
+               log.debug("Path for default store config is "
+                               + blankStore.getFilePath());
+               assertNotNull(owlmodel);
+            OWLOntologyManager owlmanager = 
OWLManager.createOWLOntologyManager();
+               String src = "";
+            try{
+                       src = 
"./src/main/resources/RuleOntology/TestKReSOntologyRules.owl";
+                       assertEquals(owlmodel, owlmanager
+                                       .loadOntologyFromOntologyDocument(new 
File(src)));
+                }catch (Exception e){
+                       try {
+                               src = 
"./src/main/resources/RuleOntology/OffLineKReSOntologyRules.owl";
+                               assertEquals(owlmodel, owlmanager
+                                               
.loadOntologyFromOntologyDocument(new File(src)));
+                       } catch (OWLOntologyCreationException ex) {
+                               fail("OWLOntologyCreationException caught when 
loading from "
+                                               + src);
+                }
+        }
+    }
+
+    @Test
+    public void testKReSRuleStore_2(){
+               OWLOntology owlmodel = blankStore.getOntology();
+               System.out.println("Path for default store config is "
+                               + blankStore.getFilePath());
+               assertNotNull(owlmodel);
+            assertTrue(!owlmodel.isEmpty());
+        }
+
+}
\ No newline at end of file

Added: 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/parse/KReSRuleParserTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/parse/KReSRuleParserTest.java?rev=1082166&view=auto
==============================================================================
--- 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/parse/KReSRuleParserTest.java
 (added)
+++ 
incubator/stanbol/trunk/kres/rules/manager/src/test/java/org/apache/stanbol/rules/manager/parse/KReSRuleParserTest.java
 Wed Mar 16 15:31:08 2011
@@ -0,0 +1,48 @@
+package org.apache.stanbol.rules.manager.parse;
+
+import org.apache.stanbol.rules.base.api.KReSRule;
+import org.apache.stanbol.rules.base.api.util.KReSRuleList;
+import org.apache.stanbol.rules.manager.KReSKB;
+import org.apache.stanbol.rules.manager.parse.KReSRuleParser;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+/**
+ * 
+ * @author andrea.nuzzolese
+ *
+ */
+public class KReSRuleParserTest {
+
+       private static String kReSRule;
+       
+       @BeforeClass
+       public static void setup() {
+               kReSRule = "ProvaParent = 
<http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#> . " +
+               "rule1[ has(ProvaParent:hasParent, ?x, ?y) . 
has(ProvaParent:hasBrother, ?y, ?z) -> " +
+               "has(ProvaParent:hasUncle, ?x, ?z) ]";
+       }
+       
+       @Test
+       public void testParser(){
+               try{
+                       KReSKB kReSKB = KReSRuleParser.parse(kReSRule);
+                       if(kReSKB != null){
+                               KReSRuleList kReSRuleList = 
kReSKB.getkReSRuleList();
+                               if(kReSRuleList != null){
+                                       for(KReSRule kReSRule : kReSRuleList){
+                                               System.out.println("RULE : 
"+kReSRule.toString());
+                                       }
+                               }
+                               System.out.println("RULE LIST IS NULL");
+                       }
+                       else{
+                               System.out.println("KB IS NULL");
+                       }
+               }catch (Exception e) {
+                       e.printStackTrace();
+               }
+       }
+       
+}


Reply via email to