Skip to content

Commit 921aa3e

Browse files
alanpaxtonrhubner
authored andcommitted
Polish the test message - sense was inverted when it failed
1 parent 3d61363 commit 921aa3e

1 file changed

Lines changed: 12 additions & 6 deletions

File tree

java/src/test/java/org/rocksdb/MultiGetCorruptionTest.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
import static java.nio.charset.StandardCharsets.UTF_8;
44
import static org.assertj.core.api.Assertions.assertThat;
55

6-
import java.io.*;
6+
import java.io.File;
7+
import java.io.IOException;
8+
import java.io.RandomAccessFile;
79
import java.util.ArrayList;
810
import java.util.List;
11+
import org.hamcrest.CustomTypeSafeMatcher;
912
import org.hamcrest.Description;
10-
import org.hamcrest.TypeSafeMatcher;
1113
import org.junit.ClassRule;
1214
import org.junit.Rule;
1315
import org.junit.Test;
@@ -50,15 +52,17 @@ public void multiGetKeyException() throws RocksDBException, IOException {
5052
try (Options options = new Options().setCreateIfMissing(true).setParanoidChecks(true);
5153
RocksDB db = RocksDB.openReadOnly(options, dbFolder.getRoot().getAbsolutePath())) {
5254
exception.expect(RocksDBException.class);
53-
exception.expect(new TypeSafeMatcher<RocksDBException>() {
55+
exception.expect(new CustomTypeSafeMatcher<RocksDBException>(
56+
"Status.Code equal to Corruption") {
5457
@Override
5558
protected boolean matchesSafely(RocksDBException e) {
5659
return e.getStatus().getCode() == Status.Code.Corruption;
5760
}
5861

5962
@Override
60-
public void describeTo(Description description) {
61-
description.appendText("Status.Code is not equal to Corruption");
63+
protected void describeMismatchSafely(RocksDBException e, Description mismatchDescription) {
64+
mismatchDescription.appendText(
65+
"was " + e.getStatus().getCodeString() + " " + e.getMessage());
6266
}
6367
});
6468

@@ -72,7 +76,9 @@ private void createCorruptedDatabase() throws RocksDBException, IOException {
7276
try (Options options = new Options().setCreateIfMissing(true).setParanoidChecks(true);
7377
RocksDB db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath())) {
7478
db.put(KEY, VALUE);
75-
db.flush(new FlushOptions().setWaitForFlush(true));
79+
try (FlushOptions flushOptions = new FlushOptions().setWaitForFlush(true)) {
80+
db.flush(flushOptions);
81+
}
7682
}
7783

7884
File[] files = dbFolder.getRoot().listFiles((dir, name) -> name.endsWith("sst"));

0 commit comments

Comments
 (0)