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 4e67b51dcadedecfdf70ab7f58cfffc10682513f
Merge: a6b72c5 19bdeb4
Author: Christopher Tubbs <ctubb...@apache.org>
AuthorDate: Thu Aug 15 22:31:45 2019 -0400

    Merge branch '1.9' into 2.0

 .../shell/commands/ImportDirectoryCommandTest.java | 79 +++++++++-------------
 .../org/apache/accumulo/test/ShellServerIT.java    |  4 --
 2 files changed, 32 insertions(+), 51 deletions(-)

diff --cc 
shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
index 963d919,06694fd..556ad5a
--- 
a/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
+++ 
b/shell/src/test/java/org/apache/accumulo/shell/commands/ImportDirectoryCommandTest.java
@@@ -16,9 -16,13 +16,13 @@@
   */
  package org.apache.accumulo.shell.commands;
  
+ import static org.easymock.EasyMock.createMock;
+ import static org.easymock.EasyMock.expect;
  import static org.easymock.EasyMock.expectLastCall;
+ import static org.easymock.EasyMock.replay;
+ import static org.easymock.EasyMock.verify;
  
 -import org.apache.accumulo.core.client.Connector;
 +import org.apache.accumulo.core.client.AccumuloClient;
  import org.apache.accumulo.core.client.admin.TableOperations;
  import org.apache.accumulo.shell.Shell;
  import org.apache.commons.cli.CommandLine;
@@@ -42,11 -46,15 +46,15 @@@ public class ImportDirectoryCommandTes
      // Initialize that internal state
      cmd.getOptions();
  
-     client = EasyMock.createMock(AccumuloClient.class);
-     cli = EasyMock.createMock(CommandLine.class);
-     shellState = EasyMock.createMock(Shell.class);
-     tableOperations = EasyMock.createMock(TableOperations.class);
 -    conn = createMock(Connector.class);
++    client = createMock(AccumuloClient.class);
+     cli = createMock(CommandLine.class);
+     shellState = createMock(Shell.class);
+     tableOperations = createMock(TableOperations.class);
+   }
  
+   @After
+   public void verifyMocks() {
 -    verify(conn, cli, shellState, tableOperations);
++    verify(client, cli, shellState, tableOperations);
    }
  
    /**
@@@ -57,33 -65,24 +65,24 @@@
     */
    @Test
    public void testOriginalCmdForm() throws Exception {
- 
      String[] cliArgs = {"in_dir", "fail_dir", "false"};
-     //
-     // EasyMock.expect(cli.hasOption('t')).andReturn(false);
  
-     EasyMock.expect(cli.hasOption("t")).andReturn(false);
+     // no -t option, use current table context
+     expect(cli.hasOption("t")).andReturn(false).once();
+     expect(shellState.getTableName()).andReturn("tablename").once();
  
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
- 
-     EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
-     EasyMock.expect(shellState.getTableName()).andReturn("tablename");
+     expect(cli.getArgs()).andReturn(cliArgs).atLeastOnce();
 -    expect(shellState.getConnector()).andReturn(conn).atLeastOnce();
 -    expect(conn.tableOperations()).andReturn(tableOperations);
++    expect(shellState.getAccumuloClient()).andReturn(client).atLeastOnce();
++    expect(client.tableOperations()).andReturn(tableOperations);
  
      shellState.checkTableState();
-     expectLastCall().andVoid();
- 
-     // Table exists
-     EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
+     expectLastCall().once();
  
      tableOperations.importDirectory("tablename", "in_dir", "fail_dir", false);
-     expectLastCall().times(3);
- 
-     EasyMock.replay(client, cli, shellState, tableOperations);
+     expectLastCall().once();
  
 -    replay(conn, cli, shellState, tableOperations);
++    replay(client, cli, shellState, tableOperations);
      cmd.execute("importdirectory in_dir fail_dir false", cli, shellState);
- 
    }
  
    /**
@@@ -94,37 -93,23 +93,23 @@@
     */
    @Test
    public void testPassTableOptCmdForm() throws Exception {
- 
      String[] cliArgs = {"in_dir", "fail_dir", "false"};
-     //
-     // EasyMock.expect(cli.hasOption('t')).andReturn(false);
  
-     EasyMock.expect(cli.hasOption("t")).andReturn(true);
-     EasyMock.expect(cli.hasOption("t")).andReturn(true);
-     EasyMock.expect(cli.getOptionValue("t")).andReturn("passedName");
+     // -t option specified, table is from option
+     expect(cli.hasOption("t")).andReturn(true).once();
+     expect(cli.getOptionValue("t")).andReturn("passedName").once();
+     expect(tableOperations.exists("passedName")).andReturn(true).once();
  
-     EasyMock.expect(tableOperations.exists("passedName")).andReturn(true);
-     EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
-     EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
+     expect(cli.getArgs()).andReturn(cliArgs).atLeastOnce();
 -    expect(shellState.getConnector()).andReturn(conn).atLeastOnce();
 -    expect(conn.tableOperations()).andReturn(tableOperations).atLeastOnce();
++    expect(shellState.getAccumuloClient()).andReturn(client).atLeastOnce();
++    expect(client.tableOperations()).andReturn(tableOperations).atLeastOnce();
  
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
-     EasyMock.expect(cli.getArgs()).andReturn(cliArgs);
- 
-     EasyMock.expect(shellState.getAccumuloClient()).andReturn(client);
- 
-     shellState.checkTableState();
-     expectLastCall().andVoid();
- 
-     // Table exists
-     EasyMock.expect(client.tableOperations()).andReturn(tableOperations);
+     // shellState.checkTableState() is NOT called
  
      tableOperations.importDirectory("passedName", "in_dir", "fail_dir", 
false);
-     expectLastCall().times(3);
- 
-     EasyMock.replay(client, cli, shellState, tableOperations);
+     expectLastCall().once();
  
 -    replay(conn, cli, shellState, tableOperations);
++    replay(client, cli, shellState, tableOperations);
      cmd.execute("importdirectory in_dir fail_dir false", cli, shellState);
- 
    }
  }

Reply via email to