org.openrdf.sail.memory.MemoryStore Java Examples
The following examples show how to use
org.openrdf.sail.memory.MemoryStore.
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: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests reading objects and their property values from the repository. */ @Test public void testRead() throws Exception { // Create an Anno4j instance and get its repository connection for direct triple access: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); RepositoryConnection repoConnection = anno4j.getRepository().getConnection(); // Add some triples to the repository: repoConnection.add(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(RDF.TYPE), new URIImpl(FOAF.PERSON))); repoConnection.add(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(FOAF.MBOX), new LiteralImpl("[email protected]"))); Person p = anno4j.findByID(Person.class, "urn:anno4j_test:p1"); assertNotNull(p); assertEquals("[email protected]", p.getMbox()); }
Example #2
Source File: ConceptQueryTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testGetConcept() throws Exception { // Create an Anno4j object and load the ontology information: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); InputStream is = new ByteArrayInputStream(ONTOLOGY_RDFS_TURTLE.getBytes("UTF-8")); anno4j.getRepository().getConnection().add(is, "http://example.org/v2/", RDFFormat.TURTLE); // Test resources are mapped to their correct concepts: assertEquals(Cabrio.class, anno4j.getConcept("http://example.org/v2/r8spyder")); assertEquals(Car.class, anno4j.getConcept("http://example.org/v2/golf")); assertEquals(Camper.class, anno4j.getConcept("http://example.org/v2/vario")); // Resources with unknown type are mapped to ResourceObject: assertEquals(ResourceObject.class, anno4j.getConcept("http://example.org/v2/318i")); // Resources with multiple types are mapped to any of them: Class<? extends ResourceObject> t5Concept = anno4j.getConcept("http://example.org/v2/t5"); assertTrue(t5Concept.equals(Car.class) || t5Concept.equals(Truck.class)); }
Example #3
Source File: BigdataSparqlTest.java From database with GNU General Public License v2.0 | 6 votes |
@Override protected Repository newRepository() throws RepositoryException { if (true) { final Properties props = getProperties(); if (cannotInlineTests.contains(testURI)){ // The test can not be run using XSD inlining. props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false"); props.setProperty(Options.INLINE_DATE_TIMES, "false"); } if(unicodeStrengthIdentical.contains(testURI)) { // Force identical Unicode comparisons. props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString()); props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString()); } final BigdataSail sail = new BigdataSail(props); // return new DatasetRepository(new BigdataSailRepository(sail)); return new BigdataSailRepository(sail); } else { return new DatasetRepository(new SailRepository(new MemoryStore())); } }
Example #4
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests propagation of updates across different objects for the same resource. */ @Test public void testUpgradePropagation() throws Exception { // Create an Anno4j instance and get its object connection: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); ObjectConnection connection = anno4j.getObjectRepository().getConnection(); // Get two objects for the same resource: Annotation a = anno4j.createObject(Annotation.class, (Resource) new URIImpl("urn:anno4j_test:a1")); Annotation b = anno4j.findByID(Annotation.class, "urn:anno4j_test:a1"); // Test that both objects have the same values after setting at one: a.setBodyTexts(Sets.newHashSet("a")); assertEquals(Sets.newHashSet("a"), a.getBodyTexts()); assertEquals(Sets.newHashSet("a"), b.getBodyTexts()); // Refresh objects: connection.refresh(a); connection.refresh(b); // Test other way round (after values have been cached): b.setBodyTexts(Sets.newHashSet("a", "b")); assertEquals(Sets.newHashSet("a", "b"), new HashSet<>(a.getBodyTexts())); assertEquals(Sets.newHashSet("a", "b"), new HashSet<>(b.getBodyTexts())); }
Example #5
Source File: ConceptQueryTest.java From anno4j with Apache License 2.0 | 6 votes |
@Test public void testGetConcepts() throws Exception { // Create an Anno4j object and load the ontology information: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); InputStream is = new ByteArrayInputStream(ONTOLOGY_RDFS_TURTLE.getBytes("UTF-8")); anno4j.getRepository().getConnection().add(is, "http://example.org/v2/", RDFFormat.TURTLE); // Test resources are mapped to their correct concepts: assertEquals(Sets.<Class<?>>newHashSet(Cabrio.class), anno4j.getConcepts("http://example.org/v2/r8spyder")); assertEquals(Sets.<Class<?>>newHashSet(Car.class), anno4j.getConcepts("http://example.org/v2/golf")); assertEquals(Sets.<Class<?>>newHashSet(Camper.class), anno4j.getConcepts("http://example.org/v2/vario")); // Resources with unknown type are mapped to ResourceObject: assertEquals(Sets.<Class<?>>newHashSet(ResourceObject.class), anno4j.getConcepts("http://example.org/v2/318i")); // Test resource with multiple specific types: assertEquals(Sets.<Class<?>>newHashSet(Car.class, Truck.class), anno4j.getConcepts("http://example.org/v2/t5")); }
Example #6
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests retrieving resources with a more general type than specified in the repository. */ @Test public void testReadGeneralType() throws Exception { // Create an Anno4j instance and get its repository connection for direct triple access: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); RepositoryConnection repoConnection = anno4j.getRepository().getConnection(); // Add some triples to the repository: repoConnection.add(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(RDF.TYPE), new URIImpl(FOAF.PERSON))); ResourceObject p = anno4j.findByID(Person.class, "urn:anno4j_test:p1"); assertNotNull(p); p = anno4j.findByID(Agent.class, "urn:anno4j_test:p1"); assertNotNull(p); p = anno4j.findByID(ResourceObject.class, "urn:anno4j_test:p1"); assertNotNull(p); }
Example #7
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests reading of resources that do not have a type assigned in the repository. */ @Test public void testReadNoType() throws Exception { // Create an Anno4j instance and get its repository connection for direct triple access: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); RepositoryConnection repoConnection = anno4j.getRepository().getConnection(); // Resource urn:anno4j_test:p1 is present but does not have a rdf:type repoConnection.add(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(FOAF.MBOX), new LiteralImpl("[email protected]"))); // Try retrieving the resource with a specific type: Person p = anno4j.findByID(Person.class, "urn:anno4j_test:p1"); assertNull(p); }
Example #8
Source File: RangeQueriesTest.java From cumulusrdf with Apache License 2.0 | 6 votes |
/** * Setup fixture for this test case. * * @throws Exception never, otherwise the test fails. */ @BeforeClass public static void setUp() throws Exception { _repository = new SailRepository(new MemoryStore()); _repository.initialize(); _tripleStore = newTripleStore(); _tripleStore.enableRangeIndexesSupport(); _tripleStore.open(); assertTrue("Ranges have not been enabled for this triple store!", _tripleStore.isRangeIndexesSupportEnabled()); _tripleStore.bulkLoad(DATA, RDFFormat.NTRIPLES); _repositoryConnection = _repository.getConnection(); _repositoryConnection.add(new File(DATA), "http://nb-base-uri-not-actually-used", RDFFormat.NTRIPLES); }
Example #9
Source File: InterfaceTypeSpecTest.java From anno4j with Apache License 2.0 | 6 votes |
@Before public void setUp() throws Exception { generationConfig = new OntGenerationConfig(); List<String> identifierLangPreference = Arrays.asList("en", "de", OntGenerationConfig.UNTYPED_LITERAL); List<String> javaDocLangPreference = Arrays.asList("de", "en", OntGenerationConfig.UNTYPED_LITERAL); generationConfig.setIdentifierLanguagePreference(identifierLangPreference); generationConfig.setJavaDocLanguagePreference(javaDocLangPreference); // Prevent persisting of schema information from other tests (would be rooted to ex:Vehicle): Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), new IDGeneratorAnno4jURN(), null, false); modelBuilder = new OWLJavaFileGenerator(anno4j); // Create a RDFS model builder instance: VehicleOntologyLoader.addVehicleOntology(modelBuilder); // Build the ontology model: modelBuilder.build(); }
Example #10
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests re-creation of already created objects in a different context. */ @Test public void testCreateExistingOtherContext() throws Exception { // Create an Anno4j instance and get its object connection: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); ObjectConnection connection = anno4j.getObjectRepository().getConnection(); // Create an object: Person a = anno4j.createObject(Person.class, (Resource) new URIImpl("urn:anno4j_test:p1")); a.setMbox("[email protected]"); // Create another object with the same IRI: Person b = anno4j.createObject(Person.class, new URIImpl("urn:anno4j_test:context1"), new URIImpl("urn:anno4j_test:p1")); // The new object should NOT have a value for the property foaf:mbox: assertNull(b.getMbox()); // The objects should be comparable (because the resource identified by an IRI is always the same): assertTrue(a.equals(b) && b.equals(a)); // Modification done to the second object should NOT persist to the first (after refreshing): b.setMbox("[email protected]"); connection.refresh(a); assertEquals("[email protected]", a.getMbox()); }
Example #11
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests re-creation of already created objects in the same context. */ @Test public void testCreateExisting() throws Exception { // Create an Anno4j instance and get its object connection: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); ObjectConnection connection = anno4j.getObjectRepository().getConnection(); // Create an object: Person a = anno4j.createObject(Person.class, (Resource) new URIImpl("urn:anno4j_test:p1")); a.setMbox("[email protected]"); // Create another object with the same IRI: Person b = anno4j.createObject(Person.class, (Resource) new URIImpl("urn:anno4j_test:p1")); // The new object should have the same value for the property foaf:mbox: assertEquals("[email protected]", b.getMbox()); // The objects should be comparable: assertTrue(a.equals(b) && b.equals(a)); // Modification done to the second object should persist to the first (after refreshing): b.setMbox("[email protected]"); connection.refresh(a); assertEquals("[email protected]", a.getMbox()); }
Example #12
Source File: CRUDTest.java From anno4j with Apache License 2.0 | 6 votes |
/** * Tests basic object creation and persistence of triples. */ @Test public void testCreate() throws Exception { // Create an Anno4j instance and get its repository connection for direct triple access: Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), null, false); RepositoryConnection repoConnection = anno4j.getRepository().getConnection(); // Test simple object creation: Person p = anno4j.createObject(Person.class, (Resource) new URIImpl("urn:anno4j_test:p1")); p.setMbox("[email protected]"); // Two statments (rdf:type, foaf:mbox) should be created: Collection<Statement> statements = getStatements(repoConnection); assertEquals(2, statements.size()); assertTrue(statements.contains(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(RDF.TYPE), new URIImpl(FOAF.PERSON)))); assertTrue(statements.contains(new StatementImpl(new URIImpl("urn:anno4j_test:p1"), new URIImpl(FOAF.MBOX), new LiteralImpl("[email protected]")))); }
Example #13
Source File: RepositoryConnectionTest.java From database with GNU General Public License v2.0 | 6 votes |
@Test public void testAddStatement() throws Exception { testCon.add(bob, name, nameBob); assertTrue(NEWLY_ADDED, testCon.hasStatement(bob, name, nameBob, false)); Statement statement = vf.createStatement(alice, name, nameAlice); testCon.add(statement); assertTrue(NEWLY_ADDED, testCon.hasStatement(statement, false)); assertTrue(NEWLY_ADDED, testCon.hasStatement(alice, name, nameAlice, false)); Repository tempRep = new SailRepository(new MemoryStore()); tempRep.initialize(); RepositoryConnection con = tempRep.getConnection(); con.add(testCon.getStatements(null, null, null, false)); assertTrue("Temp Repository should contain newly added statement", con.hasStatement(bob, name, nameBob, false)); con.close(); tempRep.shutDown(); }
Example #14
Source File: SPARQLInferenceTest.java From neo4j-sparql-extension with GNU General Public License v3.0 | 6 votes |
@Before public void before() throws RepositoryException, IOException, RDFParseException, MalformedQueryException, QueryResultParseException, QueryResultHandlerException { repo = new SailRepository(new MemoryStore()); repo.initialize(); conn = repo.getConnection(); vf = conn.getValueFactory(); conn.add(getResource(data), "file://", RDFFormat.TURTLE); SPARQLResultsXMLParserFactory factory = new SPARQLResultsXMLParserFactory(); parser = factory.getParser(); parser.setValueFactory(vf); List<Rule> rules; rules = Rules.fromOntology(getResource(data)); QueryRewriter rewriter = new QueryRewriter(conn, rules); query = (TupleQuery) rewriter.rewrite(QueryLanguage.SPARQL, queryString); nonInfQuery = conn.prepareTupleQuery(QueryLanguage.SPARQL, queryString); System.out.println("== QUERY (" + this.name + ") =="); System.out.println(nonInfQuery); System.out.println("== REWRITTEN QUERY (" + this.name + ") =="); System.out.println(query); }
Example #15
Source File: ProxyCompileTool.java From anno4j with Apache License 2.0 | 6 votes |
/** * Creates an Anno4j instance that can use the concepts contained in the given JAR file. * @param ontologyJar A JAR file containing concepts. * @param classLoader The class loader to use. * @param persistSchemaAnnotations Whether schema annotations should be scanned. * @return Returns an Anno4j instance. * @throws Exception Thrown on error. */ private static Anno4j getAnno4jWithClassLoader(File ontologyJar, ClassLoader classLoader, boolean persistSchemaAnnotations) throws Exception { Set<URL> clazzes = new HashSet<>(); clazzes.addAll(ClasspathHelper.forManifest(ontologyJar.toURI().toURL())); Anno4j anno4j = new Anno4j(new SailRepository(new MemoryStore()), new IDGeneratorAnno4jURN(), null, persistSchemaAnnotations, clazzes); // Register concepts found in JAR: RoleMapper mapper = anno4j.getObjectRepository().getConnection().getObjectFactory().getResolver().getRoleMapper(); for (final String className : getClassNamesInJar(ontologyJar)) { Class<?> clazz = classLoader.loadClass(className); if(clazz.getAnnotation(Iri.class) != null) { mapper.addConcept(clazz); } } return anno4j; }
Example #16
Source File: TestTicket355.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeQuery(new SailRepository(new MemoryStore())); // try with Bigdata: final BigdataSail sail = getSail(); try { executeQuery(new BigdataSailRepository(sail)); } finally { sail.__tearDownUnitTest(); } }
Example #17
Source File: BigdataArbitraryLengthPathTest.java From database with GNU General Public License v2.0 | 5 votes |
protected SailRepository newRepository() throws RepositoryException { if (true) { final Properties props = getProperties(); // if (cannotInlineTests.contains(testURI)){ // // The test can not be run using XSD inlining. // props.setProperty(Options.INLINE_XSD_DATATYPE_LITERALS, "false"); // props.setProperty(Options.INLINE_DATE_TIMES, "false"); // } // // if(unicodeStrengthIdentical.contains(testURI)) { // // Force identical Unicode comparisons. // props.setProperty(Options.COLLATOR, CollatorEnum.JDK.toString()); // props.setProperty(Options.STRENGTH, StrengthEnum.Identical.toString()); // } final BigdataSail sail = new BigdataSail(props); return new BigdataSailRepository(sail); } else { /* * Run against openrdf. */ SailRepository repo = new SailRepository(new MemoryStore()); return repo; } }
Example #18
Source File: IntegrationTestSupertypeLayer.java From cumulusrdf with Apache License 2.0 | 5 votes |
/** * Setup fixture for this test. */ @BeforeClass public static void init() throws Exception { inMemoryRepository = new SailRepository(new MemoryStore()); cumulusRepository = new SailRepository(new CumulusRDFSail(new TripleStore())); inMemoryRepository.initialize(); cumulusRepository.initialize(); localConnection = inMemoryRepository.getConnection(); cumulusConnection = cumulusRepository.getConnection(); }
Example #19
Source File: TestTicket276.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeQuery(new SailRepository(new MemoryStore())); final BigdataSail sail = getSail(); try { // fails with UnsupportedOperationException executeQuery(new BigdataSailRepository(sail)); } finally { sail.__tearDownUnitTest(); } }
Example #20
Source File: TestTicket353.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeQuery(new SailRepository(new MemoryStore())); // try with Bigdata: final BigdataSail sail = getSail(); try { executeQuery(new BigdataSailRepository(sail)); } finally { sail.__tearDownUnitTest(); } }
Example #21
Source File: TestTicket967.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeTest(new SailRepository(new MemoryStore())); // try with Bigdata: try { executeTest(new BigdataSailRepository(getSail())); } finally { getSail().__tearDownUnitTest(); } }
Example #22
Source File: RecommendationServiceTest.java From anno4j with Apache License 2.0 | 5 votes |
@Before public void setUp() throws Exception { SailRepository repository = new SailRepository(new MemoryStore()); repository.initialize(); anno4j = new Anno4j(); anno4j.setRepository(repository); queryService = anno4j.createQueryService(); queryService.addPrefix(ANNO4JREC.PREFIX, ANNO4JREC.NS); }
Example #23
Source File: TestTicket1681.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeQuery(new SailRepository(new MemoryStore())); final BigdataSail sail = getSail(); try { executeQuery(new BigdataSailRepository(sail)); } finally { sail.__tearDownUnitTest(); } }
Example #24
Source File: TestTicket275.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeQuery(new SailRepository(new MemoryStore())); final BigdataSail sail = getSail(); try { executeQuery(new BigdataSailRepository(sail)); } finally { sail.__tearDownUnitTest(); } }
Example #25
Source File: TestTicket348.java From database with GNU General Public License v2.0 | 5 votes |
public void testBug() throws Exception { // try with Sesame MemoryStore: executeTest(new SailRepository(new MemoryStore())); // try with Bigdata: try { executeTest(new BigdataSailRepository(getSail())); } finally { getSail().__tearDownUnitTest(); } }
Example #26
Source File: MergeTest.java From anno4j with Apache License 2.0 | 5 votes |
public void testMergeBlankNodeFromOtherRepository() throws Exception { SailRepository repo = new SailRepository(new MemoryStore()); repo.initialize(); ObjectRepositoryFactory orf = new ObjectRepositoryFactory(); ObjectRepository or = orf.createRepository(config, repo); ObjectConnection oc = or.getConnection(); ValueFactory vf = oc.getValueFactory(); Node n1 = oc.addDesignation(oc.getObject(vf.createBNode()), Node.class); Node n2 = oc.addDesignation(oc.getObject(vf.createBNode()), Node.class); n1.setSibling(n2); n2.setSibling(n1); Node m1 = (Node) con.getObject(con.addObject(n1)); assertNotNull(m1.getSibling()); }
Example #27
Source File: RangeQueryOptimizationTest.java From cumulusrdf with Apache License 2.0 | 5 votes |
@BeforeClass public static void setUp() throws Exception { // Set up standard Sesame Repository for comparison EMBEDDED_REPOSITORY = new SailRepository(new MemoryStore()); EMBEDDED_REPOSITORY.initialize(); EMBEDDED_REPOSITORY_CONNECTION = EMBEDDED_REPOSITORY.getConnection(); EMBEDDED_REPOSITORY_CONNECTION.add(DATAFILE, null, RDFFormat.N3); _tripleStore = new TripleStore(); _sail = new CumulusRDFSail(_tripleStore); _repository = new SailRepository(_sail); _repository.initialize(); CUMULUS_CONNECTION = _repository.getConnection(); }
Example #28
Source File: TestRDFSInverseInferencer.java From semweb4j with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testRDFSPlusInversesInferencer() throws RepositoryException { // create a Sail stack Sail sail = new MemoryStore(); sail = new ForwardChainingRDFSPlusInverseInferencer(sail); // create a Repository Repository repository = new SailRepository(sail); try { repository.initialize(); } catch (RepositoryException e) { throw new RuntimeException(e); } URI a = new URIImpl("urn:test:a"); URI b = new URIImpl("urn:test:b"); URI c = new URIImpl("urn:test:c"); URI d = new URIImpl("urn:test:d"); URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty; repository.getConnection().add(a, b, c, new Resource[0]); Assert.assertFalse(repository.getConnection().hasStatement(c, d, a, true, new Resource[0])); repository.getConnection().add(b, nrlInverse, d, new Resource[0]); Assert.assertTrue(repository.getConnection().hasStatement(c, d, a, true, new Resource[0])); }
Example #29
Source File: TestRDFSInverseInferencer.java From semweb4j with BSD 2-Clause "Simplified" License | 5 votes |
@Test public void testStrangeBug() throws RepositoryException { // create a Sail stack Sail sail = new MemoryStore(); sail = new ForwardChainingRDFSPlusInverseInferencer(sail); // create a Repository Repository repository = new SailRepository(sail); try { repository.initialize(); } catch (RepositoryException e) { throw new RuntimeException(e); } URI p = new URIImpl("urn:rel:p"); URI q = new URIImpl("urn:rel:q"); URI nrlInverse = ForwardChainingRDFSPlusInverseInferencerConnection.NRL_InverseProperty; URI defaultContext = null; // new Resource[0] RepositoryConnection con = repository.getConnection(); // add p-hasInverse-q con.add(p, nrlInverse, q, defaultContext); assertTrue("just added p-haInv-q, should stil be there", con.hasStatement(p, nrlInverse, q, true, defaultContext) ); assertTrue("expect inferred stmt: q-hasInv-p", con.hasStatement(q, nrlInverse, p, true, defaultContext) ); // add (redundant) inverse stmt: q-hasInv-p con.add(q, nrlInverse, p, defaultContext); assertTrue("added p-haInv-q, should stil be there", con.hasStatement(p, nrlInverse, q, true, defaultContext) ); assertTrue( con.hasStatement(p, nrlInverse, q, true, defaultContext) ); assertTrue("added q-hasInv-p, should still be there", con.hasStatement(q, nrlInverse, p, true, defaultContext) ); }
Example #30
Source File: RepositoryModelTest.java From semweb4j with BSD 2-Clause "Simplified" License | 5 votes |
@Override @Test public void testRemoveAll() throws Exception { Repository repo = new SailRepository(new MemoryStore()); repo.initialize(); RepositoryModelSet modelSet = new RepositoryModelSet(repo); modelSet.open(); URI context1 = new URIImpl("uri:context1"); URI context2 = new URIImpl("uri:context2"); modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl( "uri:p1"), new URIImpl("uri:r2")); modelSet.addStatement(context1, new URIImpl("uri:r1"), new URIImpl( "uri:p1"), new URIImpl("uri:r3")); modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl( "uri:p2"), new URIImpl("uri:r5")); modelSet.addStatement(context2, new URIImpl("uri:r4"), new URIImpl( "uri:p2"), new URIImpl("uri:r6")); Model model1 = modelSet.getModel(context1); model1.open(); Model model2 = modelSet.getModel(context2); model2.open(); assertEquals(4, modelSet.size()); assertEquals(2, model1.size()); assertEquals(2, model2.size()); model2.removeAll(); assertEquals(2, modelSet.size()); assertEquals(2, model1.size()); assertEquals(0, model2.size()); model1.close(); model2.close(); }