3939import org .lmdbjava .Env .Builder ;
4040import org .lmdbjava .Env .InvalidCopyDestination ;
4141import org .lmdbjava .Env .MapFullException ;
42+ import static org .lmdbjava .Env .create ;
4243import static org .lmdbjava .Env .open ;
4344import static org .lmdbjava .EnvFlags .MDB_NOSUBDIR ;
4445import static org .lmdbjava .EnvFlags .MDB_RDONLY_ENV ;
@@ -56,7 +57,7 @@ public final class EnvTest {
5657 @ Test
5758 public void byteUnit () throws IOException {
5859 final File path = tmp .newFile ();
59- final Env <ByteBuffer > env = Env . byteBuffer ().setMapSize (MEBIBYTES .toBytes (1 )).open (
60+ final Env <ByteBuffer > env = create ().setMapSize (MEBIBYTES .toBytes (1 )).open (
6061 path , MDB_NOSUBDIR );
6162 final EnvInfo info = env .info ();
6263 assertThat (info .mapSize , is (MEBIBYTES .toBytes (1 )));
@@ -65,31 +66,31 @@ public void byteUnit() throws IOException {
6566 @ Test (expected = AlreadyOpenException .class )
6667 public void cannotChangeMapSizeAfterOpen () throws IOException {
6768 final File path = tmp .newFile ();
68- final Builder <ByteBuffer > builder = Env . byteBuffer ();
69+ final Builder <ByteBuffer > builder = create ();
6970 builder .open (path , MDB_NOSUBDIR );
7071 builder .setMapSize (1 );
7172 }
7273
7374 @ Test (expected = AlreadyOpenException .class )
7475 public void cannotChangeMaxDbsAfterOpen () throws IOException {
7576 final File path = tmp .newFile ();
76- final Builder <ByteBuffer > builder = Env . byteBuffer ();
77+ final Builder <ByteBuffer > builder = create ();
7778 builder .open (path , MDB_NOSUBDIR );
7879 builder .setMaxDbs (1 );
7980 }
8081
8182 @ Test (expected = AlreadyOpenException .class )
8283 public void cannotChangeMaxReadersAfterOpen () throws IOException {
8384 final File path = tmp .newFile ();
84- final Builder <ByteBuffer > builder = Env . byteBuffer ();
85+ final Builder <ByteBuffer > builder = create ();
8586 builder .open (path , MDB_NOSUBDIR );
8687 builder .setMaxReaders (1 );
8788 }
8889
8990 @ Test (expected = AlreadyClosedException .class )
9091 public void cannotInfoOnceClosed () throws IOException {
9192 final File path = tmp .newFile ();
92- final Env <ByteBuffer > env = Env . byteBuffer ()
93+ final Env <ByteBuffer > env = create ()
9394 .open (path , MDB_NOSUBDIR );
9495 env .close ();
9596 env .info ();
@@ -98,14 +99,14 @@ public void cannotInfoOnceClosed() throws IOException {
9899 @ Test (expected = AlreadyOpenException .class )
99100 public void cannotOpenTwice () throws IOException {
100101 final File path = tmp .newFile ();
101- final Builder <ByteBuffer > builder = Env . byteBuffer ();
102+ final Builder <ByteBuffer > builder = create ();
102103 builder .open (path , MDB_NOSUBDIR );
103104 builder .open (path , MDB_NOSUBDIR );
104105 }
105106
106107 @ Test (expected = IllegalArgumentException .class )
107108 public void cannotOverflowMapSize () {
108- final Builder <ByteBuffer > builder = Env . byteBuffer ();
109+ final Builder <ByteBuffer > builder = create ();
109110 final int mb = 1_024 * 1_024 ;
110111 final int size = mb * 2_048 ; // as per issue 18
111112 builder .setMapSize (size );
@@ -114,7 +115,7 @@ public void cannotOverflowMapSize() {
114115 @ Test (expected = AlreadyClosedException .class )
115116 public void cannotStatOnceClosed () throws IOException {
116117 final File path = tmp .newFile ();
117- final Env <ByteBuffer > env = Env . byteBuffer ()
118+ final Env <ByteBuffer > env = create ()
118119 .open (path , MDB_NOSUBDIR );
119120 env .close ();
120121 env .stat ();
@@ -123,7 +124,7 @@ public void cannotStatOnceClosed() throws IOException {
123124 @ Test (expected = AlreadyClosedException .class )
124125 public void cannotSyncOnceClosed () throws IOException {
125126 final File path = tmp .newFile ();
126- final Env <ByteBuffer > env = Env . byteBuffer ()
127+ final Env <ByteBuffer > env = create ()
127128 .open (path , MDB_NOSUBDIR );
128129 env .close ();
129130 env .sync (false );
@@ -136,7 +137,7 @@ public void copy() throws IOException {
136137 assertThat (dest .isDirectory (), is (true ));
137138 assertThat (dest .list ().length , is (0 ));
138139 final File src = tmp .newFolder ();
139- try (final Env <ByteBuffer > env = Env . byteBuffer ().open (src )) {
140+ try (final Env <ByteBuffer > env = create ().open (src )) {
140141 env .copy (dest , MDB_CP_COMPACT );
141142 assertThat (dest .list ().length , is (1 ));
142143 }
@@ -146,7 +147,7 @@ public void copy() throws IOException {
146147 public void copyRejectsFileDestination () throws IOException {
147148 final File dest = tmp .newFile ();
148149 final File src = tmp .newFolder ();
149- try (final Env <ByteBuffer > env = Env . byteBuffer ().open (src )) {
150+ try (final Env <ByteBuffer > env = create ().open (src )) {
150151 env .copy (dest , MDB_CP_COMPACT );
151152 }
152153 }
@@ -156,7 +157,7 @@ public void copyRejectsMissingDestination() throws IOException {
156157 final File dest = tmp .newFolder ();
157158 assertThat (dest .delete (), is (true ));
158159 final File src = tmp .newFolder ();
159- try (final Env <ByteBuffer > env = Env . byteBuffer ().open (src )) {
160+ try (final Env <ByteBuffer > env = create ().open (src )) {
160161 env .copy (dest , MDB_CP_COMPACT );
161162 }
162163 }
@@ -167,15 +168,15 @@ public void copyRejectsNonEmptyDestination() throws IOException {
167168 final File subDir = new File (dest , "hello" );
168169 assertThat (subDir .mkdir (), is (true ));
169170 final File src = tmp .newFolder ();
170- try (final Env <ByteBuffer > env = Env . byteBuffer ().open (src )) {
171+ try (final Env <ByteBuffer > env = create ().open (src )) {
171172 env .copy (dest , MDB_CP_COMPACT );
172173 }
173174 }
174175
175176 @ Test
176177 public void createAsDirectory () throws IOException {
177178 final File path = tmp .newFolder ();
178- final Env <ByteBuffer > env = Env . byteBuffer ().open (path );
179+ final Env <ByteBuffer > env = create ().open (path );
179180 assertThat (path .isDirectory (), is (true ));
180181 env .sync (false );
181182 env .close ();
@@ -186,7 +187,7 @@ public void createAsDirectory() throws IOException {
186187 @ Test
187188 public void createAsFile () throws IOException {
188189 final File path = tmp .newFile ();
189- try (final Env <ByteBuffer > env = Env . byteBuffer ()
190+ try (final Env <ByteBuffer > env = create ()
190191 .setMapSize (1_024 * 1_024 )
191192 .setMaxDbs (1 )
192193 .setMaxReaders (1 )
@@ -199,7 +200,7 @@ public void createAsFile() throws IOException {
199200 @ Test
200201 public void info () throws IOException {
201202 final File path = tmp .newFile ();
202- final Env <ByteBuffer > env = Env . byteBuffer ()
203+ final Env <ByteBuffer > env = create ()
203204 .setMaxReaders (4 )
204205 .setMapSize (123_456 )
205206 .open (path , MDB_NOSUBDIR );
@@ -222,7 +223,7 @@ public void mapFull() throws IOException {
222223 final ByteBuffer key = allocateDirect (500 );
223224 final ByteBuffer val = allocateDirect (1_024 );
224225 final Random rnd = new Random ();
225- try (final Env <ByteBuffer > env = Env . byteBuffer ().setMapSize (MEBIBYTES .toBytes (8 ))
226+ try (final Env <ByteBuffer > env = create ().setMapSize (MEBIBYTES .toBytes (8 ))
226227 .setMaxDbs (1 ).open (path )) {
227228 final Dbi <ByteBuffer > db = env .openDbi (DB_1 , MDB_CREATE );
228229 for (;;) {
@@ -238,11 +239,11 @@ public void mapFull() throws IOException {
238239 @ Test
239240 public void readOnlySupported () throws IOException {
240241 final File path = tmp .newFolder ();
241- try (final Env <ByteBuffer > rwEnv = Env . byteBuffer ().open (path )) {
242+ try (final Env <ByteBuffer > rwEnv = create ().open (path )) {
242243 final Dbi <ByteBuffer > rwDb = rwEnv .openDbi (DB_1 , MDB_CREATE );
243244 rwDb .put (bb (1 ), bb (42 ));
244245 }
245- final Env <ByteBuffer > roEnv = Env . byteBuffer ().open (path , MDB_RDONLY_ENV );
246+ final Env <ByteBuffer > roEnv = create ().open (path , MDB_RDONLY_ENV );
246247 final Dbi <ByteBuffer > roDb = roEnv .openDbi (DB_1 );
247248 try (final Txn <ByteBuffer > roTxn = roEnv .txnRead ()) {
248249 assertThat (roDb .get (roTxn , bb (1 )), notNullValue ());
@@ -252,7 +253,7 @@ public void readOnlySupported() throws IOException {
252253 @ Test
253254 public void stats () throws IOException {
254255 final File path = tmp .newFile ();
255- final Env <ByteBuffer > env = Env . byteBuffer ()
256+ final Env <ByteBuffer > env = create ()
256257 .open (path , MDB_NOSUBDIR );
257258 final Stat stat = env .stat ();
258259 assertThat (stat , is (notNullValue ()));
0 commit comments