You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by ct...@apache.org on 2019/08/16 03:34:05 UTC

[accumulo] 02/02: Use newer importDirectory method for unit test of #1299

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

ctubbsii pushed a commit to branch 2.0
in repository https://gitbox.apache.org/repos/asf/accumulo.git

commit 6aa4c5f643d7e4fa26567403a09fc4b5e180b1a8
Author: Christopher Tubbs <ct...@apache.org>
AuthorDate: Thu Aug 15 22:33:11 2019 -0400

    Use newer importDirectory method for unit test of #1299
    
    Switch ImportDirectoryCommandTest to use the newer (non-deprecated) bulk
    import API, and ensure the mock object is verified.
---
 .../shell/commands/ImportDirectoryCommandTest.java | 27 ++++++++++++++--------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java b/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
index 556ad5a..3d075d6 100644
--- a/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
+++ b/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
@@ -24,6 +24,7 @@ import static org.easymock.EasyMock.verify;
 
 import org.apache.accumulo.core.client.AccumuloClient;
 import org.apache.accumulo.core.client.admin.TableOperations;
+import org.apache.accumulo.core.clientImpl.bulk.BulkImport;
 import org.apache.accumulo.shell.Shell;
 import org.apache.commons.cli.CommandLine;
 import org.junit.After;
@@ -38,6 +39,7 @@ public class ImportDirectoryCommandTest {
   private CommandLine cli;
   private Shell shellState;
   private TableOperations tableOperations;
+  private BulkImport bulkImport;
 
   @Before
   public void setup() {
@@ -50,11 +52,12 @@ public class ImportDirectoryCommandTest {
     cli = createMock(CommandLine.class);
     shellState = createMock(Shell.class);
     tableOperations = createMock(TableOperations.class);
+    bulkImport = createMock(BulkImport.class);
   }
 
   @After
   public void verifyMocks() {
-    verify(client, cli, shellState, tableOperations);
+    verify(client, cli, shellState, tableOperations, bulkImport);
   }
 
   /**
@@ -65,7 +68,7 @@ public class ImportDirectoryCommandTest {
    */
   @Test
   public void testOriginalCmdForm() throws Exception {
-    String[] cliArgs = {"in_dir", "fail_dir", "false"};
+    String[] cliArgs = {"in_dir", "false"};
 
     // no -t option, use current table context
     expect(cli.hasOption("t")).andReturn(false).once();
@@ -78,11 +81,14 @@ public class ImportDirectoryCommandTest {
     shellState.checkTableState();
     expectLastCall().once();
 
-    tableOperations.importDirectory("tablename", "in_dir", "fail_dir", false);
+    expect(tableOperations.importDirectory("in_dir")).andReturn(bulkImport).once();
+    expect(bulkImport.to("tablename")).andReturn(bulkImport).once();
+    expect(bulkImport.tableTime(false)).andReturn(bulkImport).once();
+    bulkImport.load();
     expectLastCall().once();
 
-    replay(client, cli, shellState, tableOperations);
-    cmd.execute("importdirectory in_dir fail_dir false", cli, shellState);
+    replay(client, cli, shellState, tableOperations, bulkImport);
+    cmd.execute("importdirectory in_dir false", cli, shellState);
   }
 
   /**
@@ -93,7 +99,7 @@ public class ImportDirectoryCommandTest {
    */
   @Test
   public void testPassTableOptCmdForm() throws Exception {
-    String[] cliArgs = {"in_dir", "fail_dir", "false"};
+    String[] cliArgs = {"in_dir", "false"};
 
     // -t option specified, table is from option
     expect(cli.hasOption("t")).andReturn(true).once();
@@ -106,10 +112,13 @@ public class ImportDirectoryCommandTest {
 
     // shellState.checkTableState() is NOT called
 
-    tableOperations.importDirectory("passedName", "in_dir", "fail_dir", false);
+    expect(tableOperations.importDirectory("in_dir")).andReturn(bulkImport).once();
+    expect(bulkImport.to("passedName")).andReturn(bulkImport).once();
+    expect(bulkImport.tableTime(false)).andReturn(bulkImport).once();
+    bulkImport.load();
     expectLastCall().once();
 
-    replay(client, cli, shellState, tableOperations);
-    cmd.execute("importdirectory in_dir fail_dir false", cli, shellState);
+    replay(client, cli, shellState, tableOperations, bulkImport);
+    cmd.execute("importdirectory in_dir false", cli, shellState);
   }
 }