2020import org .lmdbjava .Txn .CommittedException ;
2121import org .lmdbjava .Txn .NotResetException ;
2222import org .lmdbjava .Txn .ReadOnlyRequiredException ;
23+ import org .lmdbjava .Txn .ReadWriteRequiredException ;
2324import org .lmdbjava .Txn .ResetException ;
2425import static org .lmdbjava .TxnFlags .MDB_RDONLY ;
2526
@@ -41,8 +42,27 @@ public void before() throws Exception {
4142
4243 }
4344
45+ @ Test (expected = CommittedException .class )
46+ public void testCheckNotCommitted () throws Exception {
47+ final Txn tx = new Txn (env , MDB_RDONLY );
48+ tx .commit ();
49+ tx .checkNotCommitted ();
50+ }
51+
52+ @ Test (expected = ReadOnlyRequiredException .class )
53+ public void testCheckReadOnly () throws Exception {
54+ final Txn tx = new Txn (env );
55+ tx .checkReadOnly ();
56+ }
57+
58+ @ Test (expected = ReadWriteRequiredException .class )
59+ public void testCheckWritesAllowed () throws Exception {
60+ final Txn tx = new Txn (env , MDB_RDONLY );
61+ tx .checkWritesAllowed ();
62+ }
63+
4464 @ Test
45- @ Ignore
65+ @ Ignore ( value = "Travis CI failure; suspect older liblmdb version" )
4666 public void testGetId () throws Exception {
4767 Txn tx = new Txn (env );
4868 Dbi db = new Dbi (tx , DB_1 , MDB_CREATE );
@@ -112,6 +132,8 @@ public void txReadOnly() throws Exception {
112132 assertThat (tx .isCommitted (), is (false ));
113133 assertThat (tx .isReadOnly (), is (true ));
114134 assertThat (tx .isReset (), is (false ));
135+ tx .checkNotCommitted ();
136+ tx .checkReadOnly ();
115137 tx .reset ();
116138 assertThat (tx .isReset (), is (true ));
117139 tx .renew ();
@@ -126,6 +148,8 @@ public void txReadWrite() throws Exception {
126148 assertThat (tx .getParent (), is (nullValue ()));
127149 assertThat (tx .isCommitted (), is (false ));
128150 assertThat (tx .isReadOnly (), is (false ));
151+ tx .checkNotCommitted ();
152+ tx .checkWritesAllowed ();
129153 tx .commit ();
130154 assertThat (tx .isCommitted (), is (true ));
131155 }
0 commit comments