001: /*
002: * Copyright Aduna (http://www.aduna-software.com/) (c) 2007.
003: *
004: * Licensed under the Aduna BSD-style license.
005: */
006: package org.openrdf.repository;
007:
008: import org.openrdf.model.Statement;
009: import org.openrdf.model.URI;
010: import org.openrdf.model.vocabulary.RDF;
011: import org.openrdf.model.vocabulary.RDFS;
012:
013: /**
014: * @author jeen
015: * @author Arjohn Kampman
016: */
017: public abstract class RDFSchemaRepositoryConnectionTest extends
018: RepositoryConnectionTest {
019:
020: private URI person;
021:
022: private URI woman;
023:
024: private URI man;
025:
026: public RDFSchemaRepositoryConnectionTest(String name) {
027: super (name);
028: }
029:
030: @Override
031: public void setUp() throws Exception {
032: super .setUp();
033:
034: person = vf.createURI(FOAF_NS + "Person");
035: woman = vf.createURI("http://example.org/Woman");
036: man = vf.createURI("http://example.org/Man");
037: }
038:
039: public void testDomainInference() throws Exception {
040: testCon.add(name, RDFS.DOMAIN, person);
041: testCon.add(bob, name, nameBob);
042:
043: assertTrue(testCon.hasStatement(bob, RDF.TYPE, person, true));
044: }
045:
046: public void testSubClassInference() throws Exception {
047: testCon.setAutoCommit(false);
048: testCon.add(woman, RDFS.SUBCLASSOF, person);
049: testCon.add(man, RDFS.SUBCLASSOF, person);
050: testCon.add(alice, RDF.TYPE, woman);
051: testCon.setAutoCommit(true);
052:
053: assertTrue(testCon.hasStatement(alice, RDF.TYPE, person, true));
054: }
055:
056: public void testMakeExplicit() throws Exception {
057: testCon.setAutoCommit(false);
058: testCon.add(woman, RDFS.SUBCLASSOF, person);
059: testCon.add(alice, RDF.TYPE, woman);
060: testCon.setAutoCommit(true);
061:
062: assertTrue(testCon.hasStatement(alice, RDF.TYPE, person, true));
063:
064: testCon.add(alice, RDF.TYPE, person);
065:
066: assertTrue(testCon.hasStatement(alice, RDF.TYPE, person, true));
067: }
068:
069: public void testExplicitFlag() throws Exception {
070: RepositoryResult<Statement> result = testCon.getStatements(
071: RDF.TYPE, RDF.TYPE, null, true);
072: try {
073: assertTrue("result should not be empty", result.hasNext());
074: } finally {
075: result.close();
076: }
077:
078: result = testCon.getStatements(RDF.TYPE, RDF.TYPE, null, false);
079: try {
080: assertFalse("result should be empty", result.hasNext());
081: } finally {
082: result.close();
083: }
084: }
085:
086: public void testInferencerUpdates() throws Exception {
087: testCon.setAutoCommit(false);
088:
089: testCon.add(bob, name, nameBob);
090: testCon.remove(bob, name, nameBob);
091:
092: testCon.setAutoCommit(true);
093:
094: assertFalse(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
095: true));
096: }
097:
098: public void testInferencerQueryDuringTransaction() throws Exception {
099: testCon.setAutoCommit(false);
100:
101: testCon.add(bob, name, nameBob);
102: assertTrue(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
103: true));
104:
105: testCon.setAutoCommit(true);
106: }
107:
108: public void testInferencerTransactionIsolation() throws Exception {
109: testCon.setAutoCommit(false);
110: testCon.add(bob, name, nameBob);
111:
112: assertTrue(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
113: true));
114: assertFalse(testCon2.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
115: true));
116:
117: testCon.setAutoCommit(true);
118:
119: assertTrue(testCon.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
120: true));
121: assertTrue(testCon2.hasStatement(bob, RDF.TYPE, RDFS.RESOURCE,
122: true));
123: }
124: }
|