Search in sources :

Example 1 with RunSingleSPARQL

use of org.apache.stanbol.commons.owl.RunSingleSPARQL in project stanbol by apache.

the class RunSingleSPARQLTest method testCreateSPARQLQueryExecutionFactory.

/**
     * Test of testCreateSPARQLQueryExecutionFactory() method, of class RunSingleSPARQL.
     */
@Test
public void testCreateSPARQLQueryExecutionFactory() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("xsd", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("owl", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("rdf", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    map.put("ex", "<http://www.semanticweb.org/ontologies/2010/6/ProvaParent.owl#>");
    String query = "SELECT * WHERE {?p rdf:type ex:Person .}";
    RunSingleSPARQL instance = new RunSingleSPARQL(owl, map);
    QueryExecution queryExecution = instance.createSPARQLQueryExecutionFactory(query);
    if (queryExecution == null) {
        fail("Some errors occurred in createSPARQLQueryExecutionFactory of KReSRunSPARQL");
    }
    ResultSet result = queryExecution.execSelect();
    if (result != null) {
        int m = 0;
        while (result.hasNext()) {
            result.next();
            m++;
        }
        queryExecution.close();
        assertEquals(3, m);
    // TODO review the generated test code and remove the default call to fail.
    } else {
        fail("Some errors occur in createSPARQLQueryExecutionFactory of KReSRunSPARQL");
    }
}
Also used : HashMap(java.util.HashMap) RunSingleSPARQL(org.apache.stanbol.commons.owl.RunSingleSPARQL) ResultSet(com.hp.hpl.jena.query.ResultSet) QueryExecution(com.hp.hpl.jena.query.QueryExecution) Test(org.junit.Test)

Example 2 with RunSingleSPARQL

use of org.apache.stanbol.commons.owl.RunSingleSPARQL in project stanbol by apache.

the class RunSingleSPARQLTest method testRemoveSPARQLprefix.

/**
     * Test of removeSPARQLprefix method, of class RunSingleSPARQL.
     */
@Test
public void testRemoveSPARQLprefix() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("xsd", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("owl", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("rdf", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    map.put("ex", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    RunSingleSPARQL instance = new RunSingleSPARQL(owl, map);
    boolean result = instance.removeSPARQLprefix("ex");
    if (result) {
        Map<String, String> mymap = instance.getSPARQLprefix();
        assertEquals(false, mymap.containsKey("ex"));
    // TODO review the generated test code and remove the default call to fail.
    } else {
        fail("Some errors occur in removeSPARQLprefix of KReSRunSPARQL.");
    }
}
Also used : HashMap(java.util.HashMap) RunSingleSPARQL(org.apache.stanbol.commons.owl.RunSingleSPARQL) Test(org.junit.Test)

Example 3 with RunSingleSPARQL

use of org.apache.stanbol.commons.owl.RunSingleSPARQL in project stanbol by apache.

the class RunSingleSPARQLTest method testGetSPARQLprefix.

/**
     * Test of getSPARQLprefix method, of class RunSingleSPARQL.
     */
@Test
public void testGetSPARQLprefix() {
    Map<String, String> map = new HashMap<String, String>();
    map.put("rdfs", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("xsd", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("owl", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("rdf", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    map.put("ex", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    RunSingleSPARQL instance = new RunSingleSPARQL(owl, map);
    Map<String, String> expResult = map;
    Map<String, String> result = instance.getSPARQLprefix();
    if (!result.isEmpty()) {
        assertEquals(expResult, result);
    } else {
        // TODO review the generated test code and remove the default call to fail.
        fail("Some errors occur in getSPARQLprefix of KReSRunSPARQL.");
    }
}
Also used : HashMap(java.util.HashMap) RunSingleSPARQL(org.apache.stanbol.commons.owl.RunSingleSPARQL) Test(org.junit.Test)

Example 4 with RunSingleSPARQL

use of org.apache.stanbol.commons.owl.RunSingleSPARQL in project stanbol by apache.

the class RunSingleSPARQLTest method testAddSPARQLprefix.

/**
     * Test of addSPARQLprefix method, of class RunSingleSPARQL.
     */
@Test
public void testAddSPARQLprefix() {
    String label = "mylabel";
    String prefix = "<http://prova.mylabel.org#>";
    Map<String, String> map = new HashMap<String, String>();
    map.put("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
    map.put("xsd", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("owl", "<http://www.w3.org/2000/01/rdf-schema#>");
    map.put("rdf", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    map.put("ex", "<http://www.w3.org/1999/02/22-rdf-syntax-ns#>");
    RunSingleSPARQL instance = new RunSingleSPARQL(owl, map);
    boolean result = instance.addSPARQLprefix(label, prefix);
    if (result) {
        Map<String, String> mymap = instance.getSPARQLprefix();
        assertEquals(prefix, mymap.get(label));
    // TODO review the generated test code and remove the default call to fail.
    } else {
        fail("Some errors occur in addSPARQLprefix of KReSRunSPARQL.");
    }
}
Also used : HashMap(java.util.HashMap) RunSingleSPARQL(org.apache.stanbol.commons.owl.RunSingleSPARQL) Test(org.junit.Test)

Aggregations

HashMap (java.util.HashMap)4 RunSingleSPARQL (org.apache.stanbol.commons.owl.RunSingleSPARQL)4 Test (org.junit.Test)4 QueryExecution (com.hp.hpl.jena.query.QueryExecution)1 ResultSet (com.hp.hpl.jena.query.ResultSet)1