hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shiv...@apache.org
Subject incubator-hawq git commit: HAWQ-5. Fix to HBaseAccessor prepareTableOpen unit test
Date Thu, 01 Oct 2015 21:27:38 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/HAWQ-5 93cb85b41 -> 27a6043b5


HAWQ-5. Fix to HBaseAccessor prepareTableOpen unit test


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/27a6043b
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/27a6043b
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/27a6043b

Branch: refs/heads/HAWQ-5
Commit: 27a6043b579e8692224725eb648db176277701fd
Parents: 93cb85b
Author: Shivram Mani <shivram.mani@gmail.com>
Authored: Thu Oct 1 14:24:07 2015 -0700
Committer: Shivram Mani <shivram.mani@gmail.com>
Committed: Thu Oct 1 14:24:07 2015 -0700

----------------------------------------------------------------------
 .../pxf/plugins/hbase/HBaseAccessorTest.java    | 23 +++++++++++++-------
 1 file changed, 15 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/27a6043b/pxf/pxf-hbase/src/test/java/com/pivotal/pxf/plugins/hbase/HBaseAccessorTest.java
----------------------------------------------------------------------
diff --git a/pxf/pxf-hbase/src/test/java/com/pivotal/pxf/plugins/hbase/HBaseAccessorTest.java
b/pxf/pxf-hbase/src/test/java/com/pivotal/pxf/plugins/hbase/HBaseAccessorTest.java
index 5fb8988..5341b45 100644
--- a/pxf/pxf-hbase/src/test/java/com/pivotal/pxf/plugins/hbase/HBaseAccessorTest.java
+++ b/pxf/pxf-hbase/src/test/java/com/pivotal/pxf/plugins/hbase/HBaseAccessorTest.java
@@ -3,9 +3,9 @@ package com.pivotal.pxf.plugins.hbase;
 import com.pivotal.pxf.api.utilities.InputData;
 import com.pivotal.pxf.plugins.hbase.utilities.HBaseTupleDescription;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.hbase.client.*;
 import org.apache.hadoop.hbase.HBaseConfiguration;
-import org.apache.hadoop.hbase.client.HTable;
-import org.apache.hadoop.hbase.client.Scan;
+import org.apache.hadoop.hbase.TableName;
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -20,15 +20,16 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.*;
 
 @RunWith(PowerMockRunner.class)
-@PrepareForTest({HBaseAccessor.class, HBaseConfiguration.class})
+@PrepareForTest({HBaseAccessor.class, HBaseConfiguration.class, ConnectionFactory.class})
 public class HBaseAccessorTest {
-    static final String tableName = "fishy HBase table";
+    static final String tableName = "fishy_HBase_table";
 
     InputData inputData;
     HBaseTupleDescription tupleDescription;
-    HTable table;
+    Table table;
     Scan scanDetails;
     Configuration hbaseConfiguration;
+    Connection hbaseConnection;
     HBaseAccessor accessor;
 
     /*
@@ -79,7 +80,6 @@ public class HBaseAccessorTest {
         when(inputData.getFragmentMetadata()).thenReturn(null);
 
         accessor = new HBaseAccessor(inputData);
-
         try {
             accessor.openForRead();
             fail("should throw no metadata exception");
@@ -113,8 +113,15 @@ public class HBaseAccessorTest {
 
         hbaseConfiguration = mock(Configuration.class);
         when(HBaseConfiguration.create()).thenReturn(hbaseConfiguration);
-        table = mock(HTable.class);
-        PowerMockito.whenNew(HTable.class).withArguments(hbaseConfiguration, tableName.getBytes()).thenReturn(table);
+        //table = mock(HTable.class);
+        //PowerMockito.whenNew(HTable.class).withArguments(hbaseConfiguration, tableName.getBytes()).thenReturn(table);
+
+        // Make sure we mock static functions in ConnectionFactory
+        PowerMockito.mockStatic(ConnectionFactory.class);
+        hbaseConnection = mock(Connection.class);
+        when(ConnectionFactory.createConnection(hbaseConfiguration)).thenReturn(hbaseConnection);
+        table = mock(Table.class);
+        when(hbaseConnection.getTable(TableName.valueOf(tableName))).thenReturn(table);
     }
 
     /*


Mime
View raw message