You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by st...@apache.org on 2015/10/07 08:10:00 UTC

hbase git commit: HBASE-14502 Purge use of jmock and remove as dependency (Gabor Liptak)

Repository: hbase
Updated Branches:
  refs/heads/master 406cb58ac -> 298721b25


HBASE-14502 Purge use of jmock and remove as dependency (Gabor Liptak)


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/298721b2
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/298721b2
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/298721b2

Branch: refs/heads/master
Commit: 298721b259cc63ca13c35c1eb0cffe36fd553ce0
Parents: 406cb58
Author: stack <st...@apache.org>
Authored: Tue Oct 6 23:09:50 2015 -0700
Committer: stack <st...@apache.org>
Committed: Tue Oct 6 23:09:50 2015 -0700

----------------------------------------------------------------------
 hbase-resource-bundle/pom.xml                   |   5 -
 .../hadoop/hbase/regionserver/TestBulkLoad.java | 127 ++++++++++---------
 pom.xml                                         |  17 ---
 3 files changed, 67 insertions(+), 82 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/298721b2/hbase-resource-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/hbase-resource-bundle/pom.xml b/hbase-resource-bundle/pom.xml
index d90ed6f..2d3a04c 100644
--- a/hbase-resource-bundle/pom.xml
+++ b/hbase-resource-bundle/pom.xml
@@ -58,11 +58,6 @@
       <artifactId>mockito-all</artifactId>
       <scope>provided</scope>
     </dependency>
-    <dependency>
-      <groupId>org.jmock</groupId>
-      <artifactId>jmock-junit4</artifactId>
-      <scope>provided</scope>
-    </dependency>
   </dependencies>
   <build>
     <plugins>

http://git-wip-us.apache.org/repos/asf/hbase/blob/298721b2/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoad.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoad.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoad.java
index b599b26..3a7aff0 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoad.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/TestBulkLoad.java
@@ -57,11 +57,14 @@ import org.apache.hadoop.hbase.wal.WALKey;
 import org.hamcrest.Description;
 import org.hamcrest.Matcher;
 import org.hamcrest.TypeSafeMatcher;
-import org.jmock.Expectations;
-import org.jmock.api.Action;
-import org.jmock.api.Invocation;
-import org.jmock.integration.junit4.JUnitRuleMockery;
-import org.jmock.lib.concurrent.Synchroniser;
+
+import static org.mockito.Matchers.*;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
 import org.junit.Before;
 import org.junit.ClassRule;
 import org.junit.Rule;
@@ -78,54 +81,15 @@ public class TestBulkLoad {
 
   @ClassRule
   public static TemporaryFolder testFolder = new TemporaryFolder();
-  @Rule
-  public final JUnitRuleMockery context = new JUnitRuleMockery() {{
-    setThreadingPolicy(new Synchroniser());
-  }};
-  private final WAL log = context.mock(WAL.class);
+  private final WAL log = mock(WAL.class);
   private final Configuration conf = HBaseConfiguration.create();
   private final Random random = new Random();
   private final byte[] randomBytes = new byte[100];
   private final byte[] family1 = Bytes.toBytes("family1");
   private final byte[] family2 = Bytes.toBytes("family2");
-  private final Expectations callOnce;
   @Rule
   public TestName name = new TestName();
 
-  private static class AppendAction implements Action {
-    @Override
-    public void describeTo(Description arg0) {
-      // TODO Auto-generated method stub
-    }
-
-    @Override
-    public Object invoke(Invocation invocation) throws Throwable {
-      WALKey walKey = (WALKey)invocation.getParameter(2);
-      MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
-      if (mvcc != null) {
-        MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
-        walKey.setWriteEntry(we);
-      }
-      return 01L;
-    }
-
-    public static Action append(Object... args) {
-      return new AppendAction();
-    }
-  }
-
-  public TestBulkLoad() throws IOException {
-    callOnce = new Expectations() {
-      {
-        oneOf(log).append(with(any(HTableDescriptor.class)), with(any(HRegionInfo.class)),
-                with(any(WALKey.class)), with(bulkLogWalEditType(WALEdit.BULK_LOAD)),
-                with(any(boolean.class)));
-        will(AppendAction.append());
-        oneOf(log).sync(with(any(long.class)));
-      }
-    };
-  }
-
   @Before
   public void before() throws IOException {
     random.nextBytes(randomBytes);
@@ -141,19 +105,23 @@ public class TestBulkLoad {
     storeFileName = (new Path(storeFileName)).getName();
     List<String> storeFileNames = new ArrayList<String>();
     storeFileNames.add(storeFileName);
-    final Matcher<WALEdit> bulkEventMatcher = bulkLogWalEdit(WALEdit.BULK_LOAD,
-      tableName.toBytes(), familyName, storeFileNames);
-    Expectations expection = new Expectations() {
-      {
-        oneOf(log).append(with(any(HTableDescriptor.class)), with(any(HRegionInfo.class)),
-                with(any(WALKey.class)), with(bulkEventMatcher), with(any(boolean.class)));
-        will(new AppendAction());
-        oneOf(log).sync(with(any(long.class)));
-      }
-    };
-    context.checking(expection);
+    when(log.append(any(HTableDescriptor.class), any(HRegionInfo.class), any(WALKey.class),
+            argThat(bulkLogWalEdit(WALEdit.BULK_LOAD, tableName.toBytes(),
+                    familyName, storeFileNames)),
+            any(boolean.class))).thenAnswer(new Answer() {
+      public Object answer(InvocationOnMock invocation) {
+        WALKey walKey = invocation.getArgumentAt(2, WALKey.class);
+        MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
+        if (mvcc != null) {
+          MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
+          walKey.setWriteEntry(we);
+        }
+        return 01L;
+      };
+    });
     testRegionWithFamiliesAndSpecifiedTableName(tableName, family1)
         .bulkLoadHFiles(familyPaths, false, null);
+    verify(log).sync(anyLong());
   }
 
   @Test
@@ -164,23 +132,62 @@ public class TestBulkLoad {
 
   @Test
   public void shouldBulkLoadSingleFamilyHLog() throws IOException {
-    context.checking(callOnce);
+    when(log.append(any(HTableDescriptor.class), any(HRegionInfo.class),
+            any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
+            any(boolean.class))).thenAnswer(new Answer() {
+      public Object answer(InvocationOnMock invocation) {
+        WALKey walKey = invocation.getArgumentAt(2, WALKey.class);
+        MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
+        if (mvcc != null) {
+          MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
+          walKey.setWriteEntry(we);
+        }
+        return 01L;
+      };
+    });
     testRegionWithFamilies(family1).bulkLoadHFiles(withFamilyPathsFor(family1), false, null);
+    verify(log).sync(anyLong());
   }
 
   @Test
   public void shouldBulkLoadManyFamilyHLog() throws IOException {
-    context.checking(callOnce);
+    when(log.append(any(HTableDescriptor.class), any(HRegionInfo.class),
+            any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
+            any(boolean.class))).thenAnswer(new Answer() {
+              public Object answer(InvocationOnMock invocation) {
+                WALKey walKey = invocation.getArgumentAt(2, WALKey.class);
+                MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
+                if (mvcc != null) {
+                  MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
+                  walKey.setWriteEntry(we);
+                }
+                return 01L;
+              };
+            });
     testRegionWithFamilies(family1, family2).bulkLoadHFiles(withFamilyPathsFor(family1, family2),
-        false, null);
+            false, null);
+    verify(log).sync(anyLong());
   }
 
   @Test
   public void shouldBulkLoadManyFamilyHLogEvenWhenTableNameNamespaceSpecified() throws IOException {
-    context.checking(callOnce);
+    when(log.append(any(HTableDescriptor.class), any(HRegionInfo.class),
+            any(WALKey.class), argThat(bulkLogWalEditType(WALEdit.BULK_LOAD)),
+            any(boolean.class))).thenAnswer(new Answer() {
+      public Object answer(InvocationOnMock invocation) {
+        WALKey walKey = invocation.getArgumentAt(2, WALKey.class);
+        MultiVersionConcurrencyControl mvcc = walKey.getMvcc();
+        if (mvcc != null) {
+          MultiVersionConcurrencyControl.WriteEntry we = mvcc.begin();
+          walKey.setWriteEntry(we);
+        }
+        return 01L;
+      };
+    });
     TableName tableName = TableName.valueOf("test", "test");
     testRegionWithFamiliesAndSpecifiedTableName(tableName, family1, family2)
         .bulkLoadHFiles(withFamilyPathsFor(family1, family2), false, null);
+    verify(log).sync(anyLong());
   }
 
   @Test(expected = DoNotRetryIOException.class)

http://git-wip-us.apache.org/repos/asf/hbase/blob/298721b2/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 46cd59e..948e319 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1233,7 +1233,6 @@
     <jetty.version>6.1.26</jetty.version>
     <jetty.jspapi.version>6.1.14</jetty.jspapi.version>
     <jersey.version>1.9</jersey.version>
-    <jmock-junit4.version>2.6.0</jmock-junit4.version>
     <jruby.version>1.6.8</jruby.version>
     <junit.version>4.12</junit.version>
     <hamcrest.version>1.3</hamcrest.version>
@@ -1771,18 +1770,6 @@
         <version>${spy.version}</version>
         <optional>true</optional>
     </dependency>
-      <dependency>
-        <groupId>org.jmock</groupId>
-        <artifactId>jmock-junit4</artifactId>
-        <version>${jmock-junit4.version}</version>
-        <scope>test</scope>
-        <exclusions>
-          <exclusion>
-            <artifactId>junit-dep</artifactId>
-            <groupId>junit</groupId>
-          </exclusion>
-        </exclusions>
-      </dependency>
      <dependency>
        <groupId>org.bouncycastle</groupId>
        <artifactId>bcprov-jdk16</artifactId>
@@ -1812,10 +1799,6 @@
       <groupId>org.mockito</groupId>
       <artifactId>mockito-all</artifactId>
     </dependency>
-    <dependency>
-      <groupId>org.jmock</groupId>
-      <artifactId>jmock-junit4</artifactId>
-    </dependency>
   </dependencies>
   <!--
   To publish, use the following settings.xml file ( placed in ~/.m2/settings.xml )