Author: alexdma
Date: Mon Mar  7 15:30:11 2011
New Revision: 1078810

URL: http://svn.apache.org/viewvc?rev=1078810&view=rev
Log:
STANBOL-99 :
- Replaced standard TcManager in Semion refactorer unit test with inner 
subclass that manually binds WeightedTcProvider and QueryEngine implementations
- Added org.apache.clerezza.jena.sparql and org.apache.clerezza.simple.storage 
dependencies in refactorer POM
- Removed unused imports in SemionRefactorerImpl

Modified:
    incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml
    
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
    
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java

Modified: 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml?rev=1078810&r1=1078809&r2=1078810&view=diff
==============================================================================
--- incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml 
(original)
+++ incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/pom.xml 
Mon Mar  7 15:30:11 2011
@@ -81,6 +81,18 @@
                        <version>0.12-incubating-SNAPSHOT</version>
                        <scope>provided</scope>
                </dependency>
+                               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>org.apache.clerezza.rdf.jena.sparql</artifactId>
+                       <version>0.5-incubating-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
+                               <dependency>
+                       <groupId>org.apache.clerezza</groupId>
+                       
<artifactId>org.apache.clerezza.rdf.simple.storage</artifactId>
+                       <version>0.7-incubating-SNAPSHOT</version>
+                       <scope>provided</scope>
+               </dependency>
                <dependency>
                        <groupId>org.slf4j</groupId>
                        <artifactId>slf4j-api</artifactId>

Modified: 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java?rev=1078810&r1=1078809&r2=1078810&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
 (original)
+++ 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/main/java/eu/iksproject/kres/semion/refactorer/SemionRefactorerImpl.java
 Mon Mar  7 15:30:11 2011
@@ -12,10 +12,6 @@ import org.apache.clerezza.rdf.core.acce
 import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
 import org.apache.clerezza.rdf.core.impl.SimpleMGraph;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
-import org.apache.clerezza.rdf.core.sparql.NoQueryEngineException;
-import org.apache.clerezza.rdf.core.sparql.ParseException;
-import org.apache.clerezza.rdf.core.sparql.QueryParser;
-import org.apache.clerezza.rdf.core.sparql.query.ConstructQuery;
 import org.apache.felix.scr.annotations.Activate;
 import org.apache.felix.scr.annotations.Component;
 import org.apache.felix.scr.annotations.Deactivate;
@@ -43,7 +39,6 @@ import com.hp.hpl.jena.query.Syntax;
 import com.hp.hpl.jena.rdf.model.Model;
 import com.hp.hpl.jena.sparql.function.FunctionRegistry;
 import com.hp.hpl.jena.sparql.pfunction.PropertyFunctionRegistry;
-import com.hp.hpl.jena.tdb.TDBFactory;
 import com.hp.hpl.jena.update.UpdateAction;
 
 import eu.iksproject.kres.api.manager.DuplicateIDException;

Modified: 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
URL: 
http://svn.apache.org/viewvc/incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java?rev=1078810&r1=1078809&r2=1078810&view=diff
==============================================================================
--- 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
 (original)
+++ 
incubator/stanbol/trunk/kres/eu.iksproject.kres.semion.refactorer/src/test/java/eu/iksproject/kres/semion/refactorer/SemionRefactoringTest.java
 Mon Mar  7 15:30:11 2011
@@ -8,7 +8,11 @@ import java.util.Hashtable;
 import java.util.Set;
 
 import org.apache.clerezza.rdf.core.access.TcManager;
+import org.apache.clerezza.rdf.core.access.WeightedTcProvider;
 import org.apache.clerezza.rdf.core.serializedform.Serializer;
+import org.apache.clerezza.rdf.core.sparql.QueryEngine;
+import org.apache.clerezza.rdf.jena.sparql.JenaSparqlEngine;
+import org.apache.clerezza.rdf.simple.storage.SimpleTcProvider;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.semanticweb.owlapi.apibinding.OWLManager;
@@ -42,69 +46,69 @@ public class SemionRefactoringTest {
        static RuleStore ruleStore;
        static OWLOntology ontology;
        static IRI recipeIRI;
-       
+
        @BeforeClass
-       public static void setup(){
-               
+       public static void setup() {
+
                recipeIRI = IRI
                                
.create("http://kres.iks-project.eu/ontology/meta/rmi_config.owl#MyTestRecipe";);
-               
+
                InputStream ontologyStream = SemionRefactoringTest.class
                                
.getResourceAsStream("/META-INF/test/testKReSOnt.owl");
                InputStream recipeStream = SemionRefactoringTest.class
                                .getResourceAsStream("/META-INF/test/rmi.owl");
-               
+
                try {
                        final OWLOntology recipeModel = OWLManager
                                        .createOWLOntologyManager()
                                        
.loadOntologyFromOntologyDocument(recipeStream);
                        ontology = OWLManager.createOWLOntologyManager()
                                        
.loadOntologyFromOntologyDocument(ontologyStream);
-                       
+
                        ruleStore = new RuleStore() {
-                               
+
                                @Override
                                public void setStore(OWLOntology owl) {
                                        // TODO Auto-generated method stub
-                                       
+
                                }
-                               
+
                                @Override
                                public void saveOntology() throws 
OWLOntologyStorageException {
                                        // TODO Auto-generated method stub
-                                       
+
                                }
-                               
+
                                @Override
                                public RecipeList listRecipes() {
                                        // TODO Auto-generated method stub
                                        return null;
                                }
-                               
+
                                @Override
                                public Set<IRI> listIRIRecipes() {
                                        // TODO Auto-generated method stub
                                        return null;
                                }
-                               
+
                                @Override
                                public String getRuleStoreNamespace() {
                                        // TODO Auto-generated method stub
                                        return null;
                                }
-                               
+
                                @Override
                                public Recipe getRecipe(IRI recipeIRI)
                                                throws NoSuchRecipeException {
                                        Recipe recipe = null;
-                                       
-                                       if(recipeIRI!=null){
+
+                                       if (recipeIRI != null) {
                                                OWLDataFactory factory = 
OWLManager.getOWLDataFactory();
                                                OWLIndividual recipeIndividual 
= factory
                                                                
.getOWLNamedIndividual(recipeIRI);
-                                               if(recipeIndividual != null){
+                                               if (recipeIndividual != null) {
                                                        String ruleNS = 
"http://kres.iks-project.eu/ontology/meta/rmi.owl#";;
-                                                       
+
                                                        /**
                                                         * First get the recipe 
description in the
                                                         * rule/recipe ontology.
@@ -112,16 +116,16 @@ public class SemionRefactoringTest {
                                                        OWLDataProperty 
hasDescription = factory
                                                                        
.getOWLDataProperty(IRI.create(ruleNS
                                                                                
        + "hasDescription"));
-                                                       
+
                                                        String 
recipeDescription = null;
-                                                       
+
                                                        Set<OWLLiteral> 
descriptions = recipeIndividual
                                                                        
.getDataPropertyValues(hasDescription,
                                                                                
        recipeModel);
-                                                       for(OWLLiteral 
description : descriptions){
+                                                       for (OWLLiteral 
description : descriptions) {
                                                                
recipeDescription = description.getLiteral();
                                                        }
-                                                       
+
                                                        /**
                                                         * Then retrieve the 
rules associated to the recipe
                                                         * in the rule store.
@@ -132,9 +136,9 @@ public class SemionRefactoringTest {
                                                        Set<OWLIndividual> 
rules = recipeIndividual
                                                                        
.getObjectPropertyValues(objectProperty,
                                                                                
        recipeModel);
-                                                       
+
                                                        String 
kReSRulesInKReSSyntax = "";
-                                                       
+
                                                        /**
                                                         * Fetch the rule 
content expressed as a literal in
                                                         * KReSRule Syntax.
@@ -142,13 +146,13 @@ public class SemionRefactoringTest {
                                                        OWLDataProperty 
hasBodyAndHead = factory
                                                                        
.getOWLDataProperty(IRI.create(ruleNS
                                                                                
        + "hasBodyAndHead"));
-                                                       for(OWLIndividual rule 
: rules){
-                                                                
+                                                       for (OWLIndividual rule 
: rules) {
+
                                                                Set<OWLLiteral> 
kReSRuleLiterals = rule
                                                                                
.getDataPropertyValues(hasBodyAndHead,
                                                                                
                recipeModel);
-                                                               
-                                                               for(OWLLiteral 
kReSRuleLiteral : kReSRuleLiterals){
+
+                                                               for (OWLLiteral 
kReSRuleLiteral : kReSRuleLiterals) {
                                                                        String 
ruleTmp = kReSRuleLiteral
                                                                                
        .getLiteral().replace("&lt;", "<");
                                                                        ruleTmp 
= ruleTmp.replace("&gt;", ">");
@@ -157,11 +161,11 @@ public class SemionRefactoringTest {
                                                                                
                        .getProperty("line.separator");
                                                                }
                                                        }
-                                                       
+
                                                        /**
                                                         * Create the Recipe 
object.
                                                         */
-                                                       
+
                                                        KReSRuleList ruleList = 
KReSRuleParser.parse(
                                                                        
kReSRulesInKReSSyntax).getkReSRuleList();
                                                        recipe = new 
RecipeImpl(recipeIRI,
@@ -170,16 +174,16 @@ public class SemionRefactoringTest {
                                                        throw new 
NoSuchRecipeException(recipeIRI);
                                                }
                                        }
-                                       
+
                                        return recipe;
                                }
-                               
+
                                @Override
                                public OWLOntology getOntology() {
                                        // TODO Auto-generated method stub
                                        return null;
                                }
-                               
+
                                @Override
                                public String getFilePath() {
                                        // TODO Auto-generated method stub
@@ -197,7 +201,7 @@ public class SemionRefactoringTest {
                                                String kReSRuleInKReSSyntax)
                                                throws NoSuchRecipeException {
                                        return null;
-                                       
+
                                }
 
                                @Override
@@ -205,48 +209,60 @@ public class SemionRefactoringTest {
                                                String kReSRuleInKReSSyntax) {
                                        return null;
                                        // TODO Auto-generated method stub
-                                       
+
                                }
 
                                @Override
                                public void createRecipe(String recipeID,
                                                String rulesInKReSSyntax) {
                                        // TODO Auto-generated method stub
-                                       
+
                                }
 
-                @Override
-                public boolean removeRecipe(Recipe recipe) {
+                               @Override
+                               public boolean removeRecipe(Recipe recipe) {
                                        throw new UnsupportedOperationException(
                                                        "Not supported yet.");
-                }
+                               }
 
-                @Override
-                public boolean removeRecipe(IRI recipeIRI) {
+                               @Override
+                               public boolean removeRecipe(IRI recipeIRI) {
                                        throw new UnsupportedOperationException(
                                                        "Not supported yet.");
-                }
+                               }
 
-                @Override
-                public boolean removeRule(KReSRule rule) {
+                               @Override
+                               public boolean removeRule(KReSRule rule) {
                                        throw new UnsupportedOperationException(
                                                        "Not supported yet.");
-                }
+                               }
                        };
                } catch (OWLOntologyCreationException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
        }
-       
+
        @Test
        public void refactoringTest() throws Exception {
                Dictionary<String, Object> emptyConfig = new Hashtable<String, 
Object>();
                KReSONManager onm = new ONManager(null, emptyConfig);
+
+               class SpecialTcManager extends TcManager {
+                       public SpecialTcManager(QueryEngine qe, 
WeightedTcProvider wtcp) {
+                               super();
+                               bindQueryEngine(qe);
+                               bindWeightedTcProvider(wtcp);
+                       }
+               }
+
+               QueryEngine qe = new JenaSparqlEngine();
+               WeightedTcProvider wtcp = new SimpleTcProvider();
+               TcManager tcm = new SpecialTcManager(qe, wtcp);
+
                SemionRefactorer refactorer = new SemionRefactorerImpl(null,
-                               new Serializer(), new TcManager(), onm, new 
SemionManagerImpl(
-                                               onm), ruleStore, new 
KReSReasonerImpl(emptyConfig),
-                               emptyConfig);
+                               new Serializer(), tcm, onm, new 
SemionManagerImpl(onm),
+                               ruleStore, new KReSReasonerImpl(emptyConfig), 
emptyConfig);
                try {
                        refactorer.ontologyRefactoring(ontology, recipeIRI);
                } catch (SemionRefactoringException e) {
@@ -255,5 +271,5 @@ public class SemionRefactoringTest {
                        fail("Error while refactoring: no such recipe");
                }
        }
-       
+
 }


Reply via email to