This is an automated email from the ASF dual-hosted git repository.

sijie pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/bookkeeper.git


The following commit(s) were added to refs/heads/master by this push:
     new b52869b  Move utility method from LedgerMetadata to test
b52869b is described below

commit b52869bfff2caf8d2fd525a25828e95a3014a2e9
Author: Ivan Kelly <[email protected]>
AuthorDate: Thu Nov 22 19:20:42 2018 +0000

    Move utility method from LedgerMetadata to test
    
    The method is only used in the test, so it should live there.
    
    Master issue: #281
    
    
    Reviewers: Sijie Guo <[email protected]>, Enrico Olivelli 
<[email protected]>
    
    This closes #1829 from ivankelly/move-junk
---
 .../apache/bookkeeper/client/LedgerMetadata.java   | 32 --------------------
 .../bookkeeper/client/BookieWriteLedgerTest.java   | 35 +++++++++++++++++++++-
 2 files changed, 34 insertions(+), 33 deletions(-)

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 026cc97..7b40e73 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
@@ -553,38 +553,6 @@ public class LedgerMetadata implements 
org.apache.bookkeeper.client.api.LedgerMe
         }
     }
 
-    /**
-     * 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 52360fa..a3fe070 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 io.netty.buffer.UnpooledByteBufAllocator;
 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 class BookieWriteLedgerTest extends
             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

Reply via email to