|
13 | 13 | import static org.assertj.core.api.Assertions.assertThat; |
14 | 14 |
|
15 | 15 | import java.io.File; |
| 16 | +import java.lang.reflect.Field; |
16 | 17 |
|
17 | 18 | import org.eclipse.rdf4j.model.IRI; |
18 | 19 | import org.eclipse.rdf4j.model.ValueFactory; |
@@ -42,20 +43,33 @@ void configEnablesMemoryMappedTxnStatusFile() throws Exception { |
42 | 43 | cfg.setMemoryMappedTxnStatusFileEnabled(true); |
43 | 44 |
|
44 | 45 | NativeStoreFactory factory = new NativeStoreFactory(); |
45 | | - NativeStore sail = (NativeStore) factory.getSail(cfg); |
46 | | - sail.setDataDir(dataDir); |
47 | | - |
48 | | - Repository repo = new SailRepository(sail); |
49 | | - repo.init(); |
50 | | - try (RepositoryConnection conn = repo.getConnection()) { |
51 | | - ValueFactory vf = SimpleValueFactory.getInstance(); |
52 | | - IRI p = vf.createIRI("http://example.com/p"); |
53 | | - conn.add(vf.createIRI("http://example.com/s"), p, vf.createLiteral("o")); |
54 | | - } |
| 46 | + NativeStore sail = (NativeStore) factory.getSail(cfg); |
| 47 | + sail.setDataDir(dataDir); |
| 48 | + |
| 49 | + Repository repo = new SailRepository(sail); |
| 50 | + repo.init(); |
| 51 | + assertThat(extractTxnStatusFile(sail)).isInstanceOf(MemoryMappedTxnStatusFile.class); |
| 52 | + try (RepositoryConnection conn = repo.getConnection()) { |
| 53 | + ValueFactory vf = SimpleValueFactory.getInstance(); |
| 54 | + IRI p = vf.createIRI("http://example.com/p"); |
| 55 | + conn.add(vf.createIRI("http://example.com/s"), p, vf.createLiteral("o")); |
| 56 | + } |
55 | 57 | repo.shutDown(); |
56 | 58 |
|
57 | | - File txnStatusFile = new File(dataDir, TxnStatusFile.FILE_NAME); |
58 | | - assertThat(txnStatusFile).exists(); |
59 | | - assertThat(txnStatusFile.length()).isEqualTo(1L); |
60 | | - } |
| 59 | + File txnStatusFile = new File(dataDir, TxnStatusFile.FILE_NAME); |
| 60 | + assertThat(txnStatusFile).exists(); |
| 61 | + assertThat(txnStatusFile.length()).isEqualTo(1L); |
| 62 | + } |
| 63 | + |
| 64 | + private TxnStatusFile extractTxnStatusFile(NativeStore sail) throws Exception { |
| 65 | + NativeSailStore store = (NativeSailStore) sail.getSailStore(); |
| 66 | + |
| 67 | + Field tripleStoreField = NativeSailStore.class.getDeclaredField("tripleStore"); |
| 68 | + tripleStoreField.setAccessible(true); |
| 69 | + TripleStore tripleStore = (TripleStore) tripleStoreField.get(store); |
| 70 | + |
| 71 | + Field txnStatusFileField = TripleStore.class.getDeclaredField("txnStatusFile"); |
| 72 | + txnStatusFileField.setAccessible(true); |
| 73 | + return (TxnStatusFile) txnStatusFileField.get(tripleStore); |
| 74 | + } |
61 | 75 | } |
0 commit comments