hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From st...@apache.org
Subject hbase git commit: HBASE-14502 Purge use of jmock and remove as dependency (Gabor Liptak)
Date Wed, 07 Oct 2015 06:10:25 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1 2d21cb296 -> fd002eaea


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/fd002eae
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/fd002eae
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/fd002eae

Branch: refs/heads/branch-1
Commit: fd002eaeadb4c56457cdf5a9e8ccafb361abd7bb
Parents: 2d21cb2
Author: stack <stack@apache.org>
Authored: Tue Oct 6 23:09:50 2015 -0700
Committer: stack <stack@apache.org>
Committed: Tue Oct 6 23:10:16 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/fd002eae/hbase-resource-bundle/pom.xml
----------------------------------------------------------------------
diff --git a/hbase-resource-bundle/pom.xml b/hbase-resource-bundle/pom.xml
index d346b40..14de736 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/fd002eae/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 1e10511..092f3ef 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/fd002eae/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index aef5dc2..9751762 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1158,7 +1158,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>
@@ -1708,18 +1707,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>
@@ -1749,10 +1736,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 )


Mime
View raw message