|
44 | 44 | import static org.lmdbjava.TestUtils.DB_2; |
45 | 45 | import static org.lmdbjava.TestUtils.DB_3; |
46 | 46 | import static org.lmdbjava.TestUtils.DB_4; |
47 | | -import static org.lmdbjava.TestUtils.POSIX_MODE; |
48 | 47 | import static org.lmdbjava.TestUtils.bb; |
49 | 48 | import static org.lmdbjava.TestUtils.bbNative; |
50 | 49 | import static org.lmdbjava.TestUtils.getNativeInt; |
|
63 | 62 | import java.util.LinkedList; |
64 | 63 | import java.util.List; |
65 | 64 | import java.util.Map; |
66 | | -import java.util.NoSuchElementException; |
67 | 65 | import java.util.function.Function; |
68 | 66 | import java.util.stream.Collectors; |
69 | 67 | import java.util.stream.Stream; |
|
87 | 85 | */ |
88 | 86 | @Disabled // Waiting for the merge of stroomdev66's cursor tests |
89 | 87 | @ParameterizedClass(name = "{index}: dbi: {0}") |
90 | | -@ArgumentsSource(CursorIterableTest.MyArgumentProvider.class) |
| 88 | +@ArgumentsSource(CursorIterableIntegerDupTest.MyArgumentProvider.class) |
91 | 89 | public final class CursorIterableIntegerDupTest { |
92 | 90 |
|
93 | 91 | private static final DbiFlagSet DBI_FLAGS = DbiFlagSet.of( |
@@ -128,7 +126,8 @@ public void before() throws IOException { |
128 | 126 | .setMapSize(KIBIBYTES.toBytes(256)) |
129 | 127 | .setMaxReaders(1) |
130 | 128 | .setMaxDbs(3) |
131 | | - .open(file.toFile(), POSIX_MODE, MDB_NOSUBDIR); |
| 129 | + .setEnvFlags(MDB_NOSUBDIR) |
| 130 | + .open(file); |
132 | 131 |
|
133 | 132 | populateExpectedEntriesDeque(); |
134 | 133 | } |
@@ -187,16 +186,15 @@ private void populateDatabase(final Dbi<ByteBuffer> dbi) { |
187 | 186 | } |
188 | 187 | txn.commit(); |
189 | 188 | } |
190 | | - |
191 | | - try (Txn<ByteBuffer> txn = env.txnRead(); |
192 | | - CursorIterable<ByteBuffer> c = dbi.iterate(txn)) { |
193 | | - |
| 189 | +// try (Txn<ByteBuffer> txn = env.txnRead(); |
| 190 | +// CursorIterable<ByteBuffer> c = dbi.iterate(txn)) { |
| 191 | +// |
194 | 192 | // for (final KeyVal<ByteBuffer> kv : c) { |
195 | 193 | // System.out.print(getNativeInt(kv.key()) + " => " + kv.val().getInt()); |
196 | 194 | // System.out.print(", "); |
197 | 195 | // } |
198 | 196 | // System.out.println(); |
199 | | - } |
| 197 | +// } |
200 | 198 | } |
201 | 199 |
|
202 | 200 | private int[] rangeInc(final int fromInc, final int toInc) { |
@@ -278,6 +276,7 @@ public void iterate() { |
278 | 276 |
|
279 | 277 | for (final KeyVal<ByteBuffer> kv : c) { |
280 | 278 | final Map.Entry<Integer, Integer> entry = expectedEntriesDeque.pollFirst(); |
| 279 | + assertThat(entry).isNotNull(); |
281 | 280 | // System.out.println(entry.getKey() + " => " + entry.getValue()); |
282 | 281 | assertThat(getNativeInt(kv.key())).isEqualTo(entry.getKey()); |
283 | 282 | assertThat(kv.val().getInt()).isEqualTo(entry.getValue()); |
@@ -308,24 +307,6 @@ public void lessThanTest() { |
308 | 307 | verify(lessThan(bbNative(8)), 2, 4, 6); |
309 | 308 | } |
310 | 309 |
|
311 | | - public void nextThrowsNoSuchElementExceptionIfNoMoreElements() { |
312 | | - Assertions.assertThatThrownBy(() -> { |
313 | | - populateExpectedEntriesDeque(); |
314 | | - final Dbi<ByteBuffer> db = getDb(); |
315 | | - try (Txn<ByteBuffer> txn = env.txnRead(); |
316 | | - CursorIterable<ByteBuffer> c = db.iterate(txn)) { |
317 | | - final Iterator<KeyVal<ByteBuffer>> i = c.iterator(); |
318 | | - while (i.hasNext()) { |
319 | | - final KeyVal<ByteBuffer> kv = i.next(); |
320 | | - assertThat(getNativeInt(kv.key())).isEqualTo(expectedEntriesDeque.pollFirst().getKey()); |
321 | | - assertThat(kv.val().getInt()).isEqualTo(expectedEntriesDeque.pollFirst().getValue()); |
322 | | - } |
323 | | - assertThat(i.hasNext()).isEqualTo(false); |
324 | | - i.next(); |
325 | | - } |
326 | | - }).isInstanceOf(NoSuchElementException.class); |
327 | | - } |
328 | | - |
329 | 310 | @Test |
330 | 311 | public void openBackwardTest() { |
331 | 312 | verify(openBackward(bbNative(7), bbNative(2)), 6, 4); |
@@ -355,7 +336,12 @@ public void openClosedBackwardTestWithGuava() { |
355 | 336 | bb2.reset(); |
356 | 337 | return guava.compare(array1, array2); |
357 | 338 | }; |
358 | | - final Dbi<ByteBuffer> guavaDbi = env.openDbi(DB_1, comparator, MDB_CREATE); |
| 339 | + |
| 340 | + final Dbi<ByteBuffer> guavaDbi = env.buildDbi() |
| 341 | + .setDbName(DB_1).withIteratorComparator(ignored -> comparator) |
| 342 | + .setDbiFlags(MDB_CREATE) |
| 343 | + .open(); |
| 344 | + |
359 | 345 | populateDatabase(guavaDbi); |
360 | 346 | verify(openClosedBackward(bbNative(7), bbNative(2)), guavaDbi, 6, 4, 2); |
361 | 347 | verify(openClosedBackward(bbNative(8), bbNative(4)), guavaDbi, 6, 4); |
|
0 commit comments