Java Code Examples for com.bigdata.rdf.store.AbstractTripleStore#getStatementCount()

The following examples show how to use com.bigdata.rdf.store.AbstractTripleStore#getStatementCount() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BigdataGASRunner.java    From database with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void loadFiles() throws IOException {

    final BigdataOptionData opt = getOptionData();

    final Journal jnl = opt.jnl;
    final String namespace = opt.namespace;
    final String[] loadSet = opt.loadSet.toArray(new String[0]);

    // Load data using the unisolated view.
    final AbstractTripleStore kb = (AbstractTripleStore) jnl
            .getResourceLocator().locate(namespace, ITx.UNISOLATED);

    if (opt.newKB && loadSet.length > 0) {

        final BigdataSail sail = new BigdataSail(kb);
        try {
            try {
                sail.initialize();
                loadFiles(sail, loadSet);
            } finally {
                if (sail.isOpen())
                    sail.shutDown();
            }
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
    }

    // total #of edges in that graph.
    opt.nedges = kb.getStatementCount();

}
 
Example 2
Source File: TestRuleOwlHasValue.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 * (x rdf:type a), (a rdf:type owl:Restriction), (a owl:onProperty p), (a owl:hasValue v) -&gt; (x p v)
 * </pre>
 * @throws Exception 
 */
public void test_OwlHasValue() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI X = new URIImpl("http://www.foo.org/X");
        URI P = new URIImpl("http://www.foo.org/P");
        URI V = new URIImpl("http://www.foo.org/V");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(A, RDF.TYPE, X);
        buffer.add(X, RDF.TYPE, OWL.RESTRICTION);
        buffer.add(X, OWL.ONPROPERTY, P);
        buffer.add(X, OWL.HASVALUE, V);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(A, RDF.TYPE, X));
        assertTrue(store.hasStatement(X, RDF.TYPE, OWL.RESTRICTION));
        assertTrue(store.hasStatement(X, OWL.ONPROPERTY, P));
        assertTrue(store.hasStatement(X, OWL.HASVALUE, V));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlHasValue(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(A, RDF.TYPE, X));
        assertTrue(store.hasStatement(X, RDF.TYPE, OWL.RESTRICTION));
        assertTrue(store.hasStatement(X, OWL.ONPROPERTY, P));
        assertTrue(store.hasStatement(X, OWL.HASVALUE, V));

        // entailed
        assertTrue(store.hasStatement(A, P, V));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 3
Source File: TestRuleOwlFunctionalProperty.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public void test_RuleOwlFunctionalProperty() throws Exception {

        AbstractTripleStore store = getStore();

        try {

            URI john = new URIImpl("http://www.foo.org/john");
            URI mary = new URIImpl("http://www.foo.org/mary");
            URI susie = new URIImpl("http://www.foo.org/susie");
            URI wife = new URIImpl("http://www.foo.org/wife");

            IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
            
            buffer.add(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY);
            buffer.add(john, wife, mary);

            // write on the store.
            buffer.flush();

            // verify statement(s).
            assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY));
            assertTrue(store.hasStatement(john, wife, mary));
            final long nbefore = store.getStatementCount();

            final Vocabulary vocab = store.getVocabulary();

            final Rule r = new RuleOwlFunctionalProperty(store.getSPORelation()
                    .getNamespace(), vocab);

            // apply the rule.
            applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/);

            /*
             * validate the state of the primary store.
             */

            // told
            assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.FUNCTIONALPROPERTY));
            assertTrue(store.hasStatement(john, wife, mary));

            // final #of statements in the store.
            assertEquals(nbefore, store.getStatementCount());

            // add another value for the functional property
            buffer.add(john, wife, susie);
            buffer.flush();

            applyRule(store, r, -1/*solutionCount*/, 2/*mutationCount*/);
            
            assertTrue(store.hasStatement(mary, OWL.SAMEAS, susie));
            assertTrue(store.hasStatement(susie, OWL.SAMEAS, mary));

            // final #of statements in the store.
            assertEquals(nbefore+3, store.getStatementCount());
            
            
//            try {
//            	
//	            // apply the rule.
//	            applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/);
//	            
//	            fail("should have violated the functional property");
//	            
//            } catch (Exception ex) {
//            	
//                if (!InnerCause.isInnerCause(ex,
//                        ConstraintViolationException.class)) {
//                    fail("Expected: " + ConstraintViolationException.class);
//                }
//                
////            	final ExecutionExceptions ex2 = (ExecutionExceptions)
////            			InnerCause.getInnerCause(ex, ExecutionExceptions.class);
////            	
////            	Throwable t = ex2.causes().get(0);
////            	while (t.getCause() != null)
////            		t = t.getCause();
////            	
////            	if (!(t instanceof ConstraintViolationException))
////            		fail("inner cause should be a ConstraintViolationException");
//            	
//            }

        } finally {

            store.__tearDownUnitTest();

        }
        
    }
 
Example 4
Source File: TestRuleOwlFunctionalProperty.java    From database with GNU General Public License v2.0 4 votes vote down vote up
public void test_RuleOwlInverseFunctionalProperty() throws Exception {

        AbstractTripleStore store = getStore();

        try {

            URI john = new URIImpl("http://www.foo.org/john");
            URI paul = new URIImpl("http://www.foo.org/paul");
            URI mary = new URIImpl("http://www.foo.org/mary");
            URI wife = new URIImpl("http://www.foo.org/wife");

            IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
            
            buffer.add(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY);
            buffer.add(john, wife, mary);

            // write on the store.
            buffer.flush();

            // verify statement(s).
            assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY));
            assertTrue(store.hasStatement(john, wife, mary));
            final long nbefore = store.getStatementCount();

            final Vocabulary vocab = store.getVocabulary();

            final Rule r = new RuleOwlInverseFunctionalProperty(store.getSPORelation()
                    .getNamespace(), vocab);

            // apply the rule.
            applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/);

            /*
             * validate the state of the primary store.
             */

            // told
            assertTrue(store.hasStatement(wife, RDF.TYPE, OWL.INVERSEFUNCTIONALPROPERTY));
            assertTrue(store.hasStatement(john, wife, mary));

            // final #of statements in the store.
            assertEquals(nbefore, store.getStatementCount());

            // add another S for the inverse functional property
            buffer.add(paul, wife, mary);
            buffer.flush();

            applyRule(store, r, -1/*solutionCount*/, 2/*mutationCount*/);
            
            assertTrue(store.hasStatement(john, OWL.SAMEAS, paul));
            assertTrue(store.hasStatement(paul, OWL.SAMEAS, john));

            // final #of statements in the store.
            assertEquals(nbefore+3, store.getStatementCount());
            
//            try {
//            	
//	            // apply the rule.
//	            applyRule(store, r, -1/*solutionCount*/,0/*mutationCount*/);
//	            
//	            fail("should have violated the inverse functional property");
//	            
//            } catch (Exception ex) {
//            	
//                if (!InnerCause.isInnerCause(ex,
//                        ConstraintViolationException.class)) {
//                    fail("Expected: " + ConstraintViolationException.class);
//                }
////            	final ExecutionExceptions ex2 = (ExecutionExceptions)
////            			InnerCause.getInnerCause(ex, ExecutionExceptions.class);
////            	
////            	Throwable t = ex2.causes().get(0);
////            	while (t.getCause() != null)
////            		t = t.getCause();
////            	
////            	if (!(t instanceof ConstraintViolationException))
////            		fail("inner cause should be a ConstraintViolationException");
//            	
//            }

        } finally {

            store.__tearDownUnitTest();

        }
        
    }
 
Example 5
Source File: TestRuleOwlTransitiveProperty.java    From database with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 * (a rdf:type owl:TransitiveProperty), (x a y), (y a z) -&gt; (x a z)
 * </pre>
 * @throws Exception 
 */
public void test_OwlTranstitiveProperty1() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");
        URI Z = new URIImpl("http://www.foo.org/Z");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY);
        buffer.add(X, A, Y);
        buffer.add(Y, A, Z);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY));
        assertTrue(store.hasStatement(X, A, Y));
        assertTrue(store.hasStatement(Y, A, Z));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlTransitiveProperty1(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(A, RDF.TYPE, OWL.TRANSITIVEPROPERTY));
        assertTrue(store.hasStatement(X, A, Y));
        assertTrue(store.hasStatement(Y, A, Z));

        // entailed
        assertTrue(store.hasStatement(X, A, Z));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 6
Source File: TestRuleOwlSymmetricProperty.java    From database with GNU General Public License v2.0 2 votes vote down vote up
public void test_Rule() throws Exception {

        AbstractTripleStore store = getStore();

        try {

            URI A = new URIImpl("http://www.foo.org/A");
            URI B = new URIImpl("http://www.foo.org/B");
            URI X = new URIImpl("http://www.foo.org/X");

            IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
            
            buffer.add(X, RDF.TYPE, OWL.SYMMETRICPROPERTY);
            buffer.add(A, X, B);

            // write on the store.
            buffer.flush();

            // verify statement(s).
            assertTrue(store.hasStatement(X, RDF.TYPE, OWL.SYMMETRICPROPERTY));
            assertTrue(store.hasStatement(A, X, B));
            final long nbefore = store.getStatementCount();

            final Vocabulary vocab = store.getVocabulary();

            final Rule r = new RuleOwlSymmetricProperty(store.getSPORelation()
                    .getNamespace(), vocab);

            // apply the rule.
            applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

            /*
             * validate the state of the primary store.
             */

            // told
            assertTrue(store.hasStatement(X, RDF.TYPE, OWL.SYMMETRICPROPERTY));
            assertTrue(store.hasStatement(A, X, B));

            // entailed
            assertTrue(store.hasStatement(B, X, A));

            // final #of statements in the store.
            assertEquals(nbefore + 1, store.getStatementCount());

        } finally {

            store.__tearDownUnitTest();

        }
        
    }
 
Example 7
Source File: TestRuleOwlInverseOf.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 *   owl:InverseOf1 : (a owl:inverseOf b) -&gt; (b owl:inverseOf a)
 * </pre>
 * @throws Exception 
 */
public void test_owlInverseOf1() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(X, OWL.INVERSEOF, Y);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(X, OWL.INVERSEOF, Y));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlInverseOf1(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(X, OWL.INVERSEOF, Y));

        // entailed
        assertTrue(store.hasStatement(Y, OWL.INVERSEOF, X));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 8
Source File: TestRuleOwlInverseOf.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 *   owl:InverseOf2 : (a owl:inverseOf b), (x a z) -&gt; (z b x).
 * </pre>
 * @throws Exception 
 */
public void test_owlInverseOf2() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI B = new URIImpl("http://www.foo.org/B");
        URI Z = new URIImpl("http://www.foo.org/Z");
        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(A, OWL.INVERSEOF, B);
        buffer.add(X, A, Z);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(A, OWL.INVERSEOF, B));
        assertTrue(store.hasStatement(X, A, Z));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlInverseOf2(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/* solutionCount */, 1/* mutationCount */);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(A, OWL.INVERSEOF, B));
        assertTrue(store.hasStatement(X, A, Z));

        // entailed
        assertTrue(store.hasStatement(Z, B, X));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 9
Source File: TestRuleOwlEquivalentClass.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 *  (a owl:equivalentClass b) -&gt; (b owl:equivalentClass a) 
 * </pre>
 * @throws Exception 
 */
public void test_owlEquivalentClass() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI B = new URIImpl("http://www.foo.org/B");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(A, OWL.EQUIVALENTCLASS, B);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(A, OWL.EQUIVALENTCLASS, B));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlEquivalentClass(store.getSPORelation()
                .getNamespace(), vocab);
        
        // apply the rule.
        applyRule(store,r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(A, OWL.EQUIVALENTCLASS, B));

        // entailed
        assertTrue(store.hasStatement(B, OWL.EQUIVALENTCLASS, A));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 10
Source File: TestRuleOwlSameAs.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 * owl:sameAs1: (x owl:sameAs y) -&gt; (y owl:sameAs x)
 * </pre>
 * @throws Exception 
 */
public void test_owlSameAs1() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(X, OWL.SAMEAS, Y);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlSameAs1(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));

        // entailed
        assertTrue(store.hasStatement(Y, OWL.SAMEAS, X));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 11
Source File: TestRuleOwlSameAs.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 * owl:sameAs1b: (x owl:sameAs y), (y owl:sameAs z) -&gt; (x owl:sameAs z)
 * </pre>
 * @throws Exception 
 */
public void test_owlSameAs1b() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");
        URI Z = new URIImpl("http://www.foo.org/Z");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(X, OWL.SAMEAS, Y);
        buffer.add(Y, OWL.SAMEAS, Z);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(Y, OWL.SAMEAS, Z));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlSameAs1b(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(Y, OWL.SAMEAS, Z));

        // entailed
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Z));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 12
Source File: TestRuleOwlSameAs.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * <p>
 * Note: This also verifies that we correctly filter out entailments where
 * <code>a == owl:sameAs</code>.
 * 
 * <pre>
 *  owl:sameAs2: (x owl:sameAs y), (x a z) -&gt; (y a z).
 * </pre>
 * @throws Exception 
 */
public void test_owlSameAs2() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI Z = new URIImpl("http://www.foo.org/Z");
        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(X, OWL.SAMEAS, Y);
        buffer.add(X, A, Z);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(X, A, Z));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlSameAs2(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/* solutionCount */, 1/* mutationCount */);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(X, A, Z));

        // entailed
        assertTrue(store.hasStatement(Y, A, Z));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 13
Source File: TestRuleOwlSameAs.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * <p>
 * Note: This also verifies that we correctly filter out entailments where
 * <code>a == owl:sameAs</code>.
 * 
 * <pre>
 * owl:sameAs3: (x owl:sameAs y), (z a x) -&gt; (z a y).
 * </pre>
 * @throws Exception 
 */
public void test_owlSameAs3() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI Z = new URIImpl("http://www.foo.org/Z");
        URI X = new URIImpl("http://www.foo.org/X");
        URI Y = new URIImpl("http://www.foo.org/Y");

        {

            IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);

            buffer.add(X, OWL.SAMEAS, Y);
            buffer.add(Z, A, X);

            // write on the store.
            buffer.flush();
            
        }
        
        // verify statement(s).
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(Z, A, X));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlSameAs3(store.getSPORelation()
                .getNamespace(), vocab);
        
        // apply the rule.
        applyRule(store,r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(X, OWL.SAMEAS, Y));
        assertTrue(store.hasStatement(Z, A, X));

        // entailed
        assertTrue(store.hasStatement(Z, A, Y));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}
 
Example 14
Source File: TestRuleOwlEquivalentProperty.java    From database with GNU General Public License v2.0 2 votes vote down vote up
/**
 * Test where the data satisifies the rule exactly once.
 * 
 * <pre>
 *  (a owl:equivalentProperty b) -&gt; (b owl:equivalentProperty a) 
 * </pre>
 * @throws Exception 
 */
public void test_owlEquivalentProperty() throws Exception {

    AbstractTripleStore store = getStore();

    try {

        URI A = new URIImpl("http://www.foo.org/A");
        URI B = new URIImpl("http://www.foo.org/B");

        IStatementBuffer buffer = new StatementBuffer(store, 100/* capacity */);
        
        buffer.add(A, OWL.EQUIVALENTPROPERTY, B);

        // write on the store.
        buffer.flush();

        // verify statement(s).
        assertTrue(store.hasStatement(A, OWL.EQUIVALENTPROPERTY, B));
        final long nbefore = store.getStatementCount();

        final Vocabulary vocab = store.getVocabulary();

        final Rule r = new RuleOwlEquivalentProperty(store.getSPORelation()
                .getNamespace(), vocab);

        // apply the rule.
        applyRule(store, r, -1/*solutionCount*/,1/*mutationCount*/);

        /*
         * validate the state of the primary store.
         */

        // told
        assertTrue(store.hasStatement(A, OWL.EQUIVALENTPROPERTY, B));

        // entailed
        assertTrue(store.hasStatement(B, OWL.EQUIVALENTPROPERTY, A));

        // final #of statements in the store.
        assertEquals(nbefore + 1, store.getStatementCount());

    } finally {

        store.__tearDownUnitTest();

    }
    
}