1717
1818import io .netty .buffer .ByteBuf ;
1919import java .io .File ;
20+ import java .io .IOException ;
2021import java .nio .ByteBuffer ;
2122import org .agrona .MutableDirectBuffer ;
2223import static org .hamcrest .CoreMatchers .is ;
@@ -51,7 +52,7 @@ public class CursorTest {
5152 public final TemporaryFolder tmp = new TemporaryFolder ();
5253
5354 @ Test (expected = ClosedException .class )
54- public void closedCursorRejectsSubsequentGets () throws Exception {
55+ public void closedCursorRejectsSubsequentGets () {
5556 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
5657 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE );
5758 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -62,7 +63,7 @@ public void closedCursorRejectsSubsequentGets() throws Exception {
6263 }
6364
6465 @ Test
65- public void count () throws Exception {
66+ public void count () {
6667 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
6768 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
6869 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -79,7 +80,7 @@ public void count() throws Exception {
7980 }
8081
8182 @ Test
82- public void cursorByteBufProxy () throws Exception {
83+ public void cursorByteBufProxy () {
8384 final Env <ByteBuf > env = makeEnv (new ByteBufProxy ());
8485 final Dbi <ByteBuf > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
8586 try (final Txn <ByteBuf > txn = env .txnWrite ()) {
@@ -119,7 +120,7 @@ public void cursorByteBufProxy() throws Exception {
119120 }
120121
121122 @ Test
122- public void cursorByteBufferOptimal () throws Exception {
123+ public void cursorByteBufferOptimal () {
123124 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
124125 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
125126 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -159,7 +160,7 @@ public void cursorByteBufferOptimal() throws Exception {
159160 }
160161
161162 @ Test
162- public void cursorByteBufferSafe () throws Exception {
163+ public void cursorByteBufferSafe () {
163164 final Env <ByteBuffer > env = makeEnv (PROXY_SAFE );
164165 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
165166 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -199,7 +200,7 @@ public void cursorByteBufferSafe() throws Exception {
199200 }
200201
201202 @ Test (expected = CommittedException .class )
202- public void cursorCannotCloseIfTransactionCommitted () throws Exception {
203+ public void cursorCannotCloseIfTransactionCommitted () {
203204 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
204205 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
205206 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -214,7 +215,7 @@ public void cursorCannotCloseIfTransactionCommitted() throws Exception {
214215 }
215216
216217 @ Test
217- public void cursorMutableDirectBuffer () throws Exception {
218+ public void cursorMutableDirectBuffer () {
218219 final Env <MutableDirectBuffer > env = makeEnv (PROXY_MDB );
219220 final Dbi <MutableDirectBuffer > db = env .openDbi (DB_1 , MDB_CREATE ,
220221 MDB_DUPSORT );
@@ -255,7 +256,7 @@ public void cursorMutableDirectBuffer() throws Exception {
255256 }
256257
257258 @ Test
258- public void delete () throws Exception {
259+ public void delete () {
259260 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
260261 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
261262 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -275,7 +276,7 @@ public void delete() throws Exception {
275276 }
276277
277278 @ Test
278- public void renewTxRo () throws Exception {
279+ public void renewTxRo () {
279280 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
280281 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE );
281282
@@ -292,7 +293,7 @@ public void renewTxRo() throws Exception {
292293 }
293294
294295 @ Test (expected = ReadOnlyRequiredException .class )
295- public void renewTxRw () throws Exception {
296+ public void renewTxRw () {
296297 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
297298 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE );
298299 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -304,7 +305,7 @@ public void renewTxRw() throws Exception {
304305 }
305306
306307 @ Test
307- public void repeatedCloseCausesNotError () throws Exception {
308+ public void repeatedCloseCausesNotError () {
308309 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
309310 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
310311 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -315,7 +316,7 @@ public void repeatedCloseCausesNotError() throws Exception {
315316 }
316317
317318 @ Test
318- public void reserve () throws Exception {
319+ public void reserve () {
319320 final Env <ByteBuffer > env = makeEnv (PROXY_OPTIMAL );
320321 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE , MDB_DUPSORT );
321322 try (final Txn <ByteBuffer > txn = env .txnWrite ()) {
@@ -331,13 +332,17 @@ public void reserve() throws Exception {
331332 }
332333 }
333334
334- private <T > Env <T > makeEnv (final BufferProxy <T > proxy ) throws Exception {
335- final Env <T > env = create (proxy );
336- final File path = tmp .newFile ();
337- env .setMapSize (1_024 * 1_024 );
338- env .setMaxDbs (1 );
339- env .setMaxReaders (1 );
340- env .open (path , POSIX_MODE , MDB_NOSUBDIR );
341- return env ;
335+ private <T > Env <T > makeEnv (final BufferProxy <T > proxy ) {
336+ try {
337+ final Env <T > env = create (proxy );
338+ final File path = tmp .newFile ();
339+ env .setMapSize (1_024 * 1_024 );
340+ env .setMaxDbs (1 );
341+ env .setMaxReaders (1 );
342+ env .open (path , POSIX_MODE , MDB_NOSUBDIR );
343+ return env ;
344+ } catch (IOException e ) {
345+ throw new RuntimeException (e );
346+ }
342347 }
343348}
0 commit comments