Hi,

I am looking into refactoring some code to use TDB-backed Jena Models rather 
than in-memory Jena Models.

I wrote some tests to try and understand what resource management I will need 
to perform, specifically the opening and closing of TBD-backed models.

In the following test the Model m does not report itself as closed after I have 
called m's close( ) method.  It also does not report itself as closed if I 
close the Dataset, then m, then test if m is closed.

Am I missing something?

Thanks,
--Stephan

public class TDBFactoryTest {
        
        @Test
        public void test() {
                String tdb_directory = "/opt/var/tdb/mdsa";
                File location = new File(tdb_directory);
                Dataset ds = TDBFactory.createDataset(tdb_directory);
                Model m = ds.getDefaultModel();
                OntModel o = 
ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
                o.addSubModel(m);
                
                assertFalse("expected OntModel to not be closed", 
o.isClosed()); // PASSES
                assertFalse("expected OntModel to not be empty", o.isEmpty()); 
// PASSES
                
                // ... print out some statements ...
                
                o.removeSubModel(m);
                o.close();
                
                assertTrue("expected OntModel to be closed",o.isClosed()); // 
PASSES
                assertFalse("expected Model to not be closed", m.isClosed()); 
// PASSES
                
                TDB.sync(m);
                m.close();
                assertTrue("expected Model to be closed",m.isClosed()); // 
FAILS!
                
                ds.close();
                //assertTrue("expected Dataset to be closed", null); // test 
for closure?
        }
}

Reply via email to