You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@bookkeeper.apache.org by GitBox <gi...@apache.org> on 2018/11/22 19:20:44 UTC
[GitHub] sijie closed pull request #1829: Move utility method from
LedgerMetadata to test
sijie closed pull request #1829: Move utility method from LedgerMetadata to test
URL: https://github.com/apache/bookkeeper/pull/1829
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
index 5fd5f06eee..8756f74dfa 100644
--- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
+++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/client/LedgerMetadata.java
@@ -551,38 +551,6 @@ static LedgerMetadata parseVersion1Config(BufferedReader reader) throws IOExcept
}
}
- /**
- * Routine to compare two {@code Map<String, byte[]>}; Since the values in the map are {@code byte[]}, we can't use
- * {@code Map.equals}.
- * @param first
- * The first map
- * @param second
- * The second map to compare with
- * @return true if the 2 maps contain the exact set of {@code <K,V>} pairs.
- */
- public static boolean areByteArrayValMapsEqual(Map<String, byte[]> first, Map<String, byte[]> second) {
- if (first == null && second == null) {
- return true;
- }
-
- // above check confirms that both are not null;
- // if one is null the other isn't; so they must
- // be different
- if (first == null || second == null) {
- return false;
- }
-
- if (first.size() != second.size()) {
- return false;
- }
- for (Map.Entry<String, byte[]> entry : first.entrySet()) {
- if (!Arrays.equals(entry.getValue(), second.get(entry.getKey()))) {
- return false;
- }
- }
- return true;
- }
-
@Override
public String toString() {
return toStringRepresentation(true);
diff --git a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookieWriteLedgerTest.java b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookieWriteLedgerTest.java
index 52360faa2d..a3fe0706f8 100644
--- a/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookieWriteLedgerTest.java
+++ b/bookkeeper-server/src/test/java/org/apache/bookkeeper/client/BookieWriteLedgerTest.java
@@ -39,6 +39,7 @@
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
@@ -588,12 +589,44 @@ public void testLedgerCreateWithCustomMetadata() throws Exception {
lh = bkc.openLedger(ledgerId, digestType, ledgerPassword);
Map<String, byte[]> outputCustomMetadataMap = lh.getCustomMetadata();
assertTrue("Can't retrieve proper Custom Data",
- LedgerMetadata.areByteArrayValMapsEqual(inputCustomMetadataMap, outputCustomMetadataMap));
+ areByteArrayValMapsEqual(inputCustomMetadataMap, outputCustomMetadataMap));
lh.close();
bkc.deleteLedger(ledgerId);
}
}
+ /**
+ * Routine to compare two {@code Map<String, byte[]>}; Since the values in the map are {@code byte[]}, we can't use
+ * {@code Map.equals}.
+ * @param first
+ * The first map
+ * @param second
+ * The second map to compare with
+ * @return true if the 2 maps contain the exact set of {@code <K,V>} pairs.
+ */
+ public static boolean areByteArrayValMapsEqual(Map<String, byte[]> first, Map<String, byte[]> second) {
+ if (first == null && second == null) {
+ return true;
+ }
+
+ // above check confirms that both are not null;
+ // if one is null the other isn't; so they must
+ // be different
+ if (first == null || second == null) {
+ return false;
+ }
+
+ if (first.size() != second.size()) {
+ return false;
+ }
+ for (Map.Entry<String, byte[]> entry : first.entrySet()) {
+ if (!Arrays.equals(entry.getValue(), second.get(entry.getKey()))) {
+ return false;
+ }
+ }
+ return true;
+ }
+
/*
* Verify the functionality of Advanced Ledger which accepts ledgerId as
* input and returns LedgerHandleAdv. LedgerHandleAdv takes entryId for
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services