01: package org.ontoware.rdf2go.impl.autopersist;
02:
03: import java.io.File;
04: import java.io.IOException;
05:
06: import junit.framework.TestCase;
07:
08: import org.ontoware.rdf2go.RDF2Go;
09: import org.ontoware.rdf2go.exception.ModelRuntimeException;
10: import org.ontoware.rdf2go.impl.jena24.ModelFactoryImpl;
11: import org.ontoware.rdf2go.model.node.impl.URIImpl;
12:
13: public class AutopersistsTest extends TestCase {
14:
15: protected void setUp() {
16: RDF2Go.register(new ModelFactoryImpl());
17: }
18:
19: /*
20: * Test method for
21: * 'org.ontoware.rdf2go.impl.autopersist.ModelImplAutoPersist.ModelImplAutoPersist(File,
22: * int, Reasoning)'
23: */
24: public void testModelImplAutoPersist() throws IOException,
25: ModelRuntimeException {
26: File testdata = new File("./target/temp/test-data");
27: testdata.mkdirs();
28: File f = new File(testdata, "modelimplautopersist.test");
29: f.delete();
30: @SuppressWarnings("unused")
31: ModelImplAutoPersist miap = new ModelImplAutoPersist(RDF2Go
32: .getModelFactory().createModel(), f, 100);
33: }
34:
35: /*
36: * Test method for
37: * 'org.ontoware.rdf2go.impl.autopersist.ModelImplAutoPersist.addStatement(Resource,
38: * URI, Node)'
39: */
40: public void testAddStatementResourceURINode() throws IOException,
41: ModelRuntimeException {
42: File testdata = new File("./target/temp/test-data");
43: testdata.mkdirs();
44: File f = new File(testdata, "modelimplautopersist.test");
45: ModelImplAutoPersist miap = new ModelImplAutoPersist(RDF2Go
46: .getModelFactory().createModel(), f, 1);
47: miap.addStatement("urn:test:s", new URIImpl("urn:test:p"),
48: "Test");
49: assertEquals(1, miap.openchanges());
50: assertFalse(f.exists());
51: miap.addStatement("urn:test:s", new URIImpl("urn:test:p"),
52: "Test2");
53: assertEquals(0, miap.openchanges());
54: assertTrue(f.exists());
55: long fModified = f.length();
56: miap.addStatement("urn:test:s", new URIImpl("urn:test:p"),
57: "Test3");
58: assertEquals(1, miap.openchanges());
59: miap.addStatement("urn:test:s", new URIImpl("urn:test:p"),
60: "Test4");
61: assertEquals(0, miap.openchanges());
62: long f2Modified = f.length();
63: assertNotSame(fModified, f2Modified);
64: }
65:
66: /*
67: * Test method for
68: * 'org.ontoware.rdf2go.impl.autopersist.ModelImplAutoPersist.save()'
69: */
70: public void testSave() {
71:
72: }
73:
74: /*
75: * Test method for
76: * 'org.ontoware.rdf2go.impl.autopersist.ModelImplAutoPersist.load()'
77: */
78: public void testLoad() {
79:
80: }
81:
82: }
|