sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject [2/2] sqoop git commit: SQOOP-2763: Sqoop2: Sqoop shell is accepting non existing arguments
Date Tue, 05 Jan 2016 14:32:43 GMT
SQOOP-2763: Sqoop2: Sqoop shell is accepting non existing arguments

(Dian Fu via Jarek Jarcec Cecho)


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

Branch: refs/heads/sqoop2
Commit: c40c23c9e6cb398816ee16ccbd4ee77c0b3df57e
Parents: 073da06
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Tue Jan 5 06:31:58 2016 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Tue Jan 5 06:31:58 2016 -0800

----------------------------------------------------------------------
 common/pom.xml                                  |   5 +
 .../org/apache/sqoop/cli/SqoopGnuParser.java    |  41 ++++
 shell/pom.xml                                   |  10 -
 .../org/apache/sqoop/shell/SqoopFunction.java   |   2 +-
 .../apache/sqoop/shell/utils/ConfigOptions.java |   4 +-
 .../apache/sqoop/shell/TestCloneCommand.java    |  10 +
 .../apache/sqoop/shell/TestCreateCommand.java   |  10 +
 .../apache/sqoop/shell/TestDeleteCommand.java   |  50 ++--
 .../apache/sqoop/shell/TestDisableCommand.java  |  38 ++-
 .../apache/sqoop/shell/TestEnableCommand.java   |  38 ++-
 .../apache/sqoop/shell/TestGrantCommand.java    | 100 ++++----
 .../apache/sqoop/shell/TestRevokeCommand.java   | 108 +++++----
 .../org/apache/sqoop/shell/TestSetCommand.java  |  88 ++++---
 .../org/apache/sqoop/shell/TestShowCommand.java | 239 ++++++++++---------
 .../apache/sqoop/shell/TestStartCommand.java    |  24 +-
 .../apache/sqoop/shell/TestStatusCommand.java   |  22 +-
 .../org/apache/sqoop/shell/TestStopCommand.java |  22 +-
 .../apache/sqoop/shell/TestUpdateCommand.java   |  10 +
 .../sqoop/tools/tool/RepositoryDumpTool.java    |   6 +-
 .../sqoop/tools/tool/RepositoryLoadTool.java    |   4 +-
 20 files changed, 509 insertions(+), 322 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/common/pom.xml
----------------------------------------------------------------------
diff --git a/common/pom.xml b/common/pom.xml
index 078a785..7237608 100644
--- a/common/pom.xml
+++ b/common/pom.xml
@@ -55,6 +55,11 @@ limitations under the License.
     </dependency>
 
     <dependency>
+      <groupId>commons-cli</groupId>
+      <artifactId>commons-cli</artifactId>
+    </dependency>
+
+    <dependency>
       <groupId>com.google.guava</groupId>
       <artifactId>guava</artifactId>
     </dependency>

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java b/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java
new file mode 100644
index 0000000..41ebdab
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/cli/SqoopGnuParser.java
@@ -0,0 +1,41 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.cli;
+
+import java.util.ListIterator;
+
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.ParseException;
+
+public class SqoopGnuParser extends GnuParser {
+  public SqoopGnuParser() {
+    super();
+  }
+
+  @SuppressWarnings("rawtypes")
+  @Override
+  protected void processOption(final String arg, final ListIterator iter) throws ParseException {
+    boolean hasOption = getOptions().hasOption(arg);
+
+    if (hasOption) {
+      super.processOption(arg, iter);
+    } else {
+      throw new ParseException("Unknown option encountered: " + arg);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/pom.xml
----------------------------------------------------------------------
diff --git a/shell/pom.xml b/shell/pom.xml
index 1949a8e..6f6cf6c 100644
--- a/shell/pom.xml
+++ b/shell/pom.xml
@@ -46,16 +46,6 @@ limitations under the License.
       <artifactId>sqoop-client</artifactId>
     </dependency>
     <dependency>
-      <groupId>commons-cli</groupId>
-      <artifactId>commons-cli</artifactId>
-      <version>${commons-cli.version}</version>
-    </dependency>
-    <dependency>
-      <groupId>commons-lang</groupId>
-      <artifactId>commons-lang</artifactId>
-      <version>${commons-lang.version}</version>
-    </dependency>
-    <dependency>
       <groupId>jline</groupId>
       <artifactId>jline</artifactId>
       <version>${jline.version}</version>

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
index 0845d8e..3f1abcb 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/SqoopFunction.java
@@ -44,7 +44,7 @@ abstract public class SqoopFunction extends Options {
   }
 
   public Object execute(List<String> args) {
-    CommandLine line = ConfigOptions.parseOptions(this, 1, args, true);
+    CommandLine line = ConfigOptions.parseOptions(this, 1, args, false);
 
     try {
       if (validateArgs(line)) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
index 97b6e3b..ff47541 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigOptions.java
@@ -22,11 +22,11 @@ import java.util.List;
 
 import org.apache.commons.cli.CommandLine;
 import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
 import org.apache.commons.cli.Option;
 import org.apache.commons.cli.OptionBuilder;
 import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
+import org.apache.sqoop.cli.SqoopGnuParser;
 import org.apache.sqoop.common.SqoopException;
 import org.apache.sqoop.model.MConfig;
 import org.apache.sqoop.model.MInput;
@@ -105,7 +105,7 @@ public class ConfigOptions {
   public static CommandLine parseOptions(Options options, int start, List<String> arglist, boolean stopAtNonOption) {
     String[] args = arglist.subList(start, arglist.size()).toArray(new String[arglist.size() - start]);
 
-    CommandLineParser parser = new GnuParser();
+    CommandLineParser parser = new SqoopGnuParser();
     CommandLine line;
     try {
       line = parser.parse(options, args, stopAtNonOption);

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
index 53303af..4515b1c 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestCloneCommand.java
@@ -274,6 +274,16 @@ public class TestCloneCommand {
     assertEquals(job.getDriverConfig().getDateTimeInput("driverConfig.DateTime").getValue().getMillis(), 7654321);
   }
 
+  @Test
+  public void testUnknowOption() {
+    try {
+      cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-unknownOption"));
+      fail("Clone command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
+    }
+  }
+
   @SuppressWarnings("unchecked")
   private List<MConfig> getConfig(String configName) {
     List<MInput<?>> list = new ArrayList<MInput<?>>();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
index 1f559b6..c1c23db 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestCreateCommand.java
@@ -301,6 +301,16 @@ public class TestCreateCommand {
     assertTrue(status != null && status == Status.OK);
   }
 
+  @Test
+  public void testUnknowOption() {
+    try {
+      createCmd.execute(Arrays.asList(Constants.FN_ROLE, "-unknownOption"));
+      fail("Create command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
+    }
+  }
+
   @SuppressWarnings("unchecked")
   private List<MConfig> getConfig(String configName) {
     List<MInput<?>> list = new ArrayList<MInput<?>>();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestDeleteCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestDeleteCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestDeleteCommand.java
index 4165bf0..47a8f87 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestDeleteCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestDeleteCommand.java
@@ -22,6 +22,9 @@ import static org.mockito.Mockito.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 
@@ -32,7 +35,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -56,15 +58,15 @@ public class TestDeleteCommand {
 
     // delete link -name link_test
     Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
-      Assert.fail("Delete link should fail as link name is missing!");
+      fail("Delete link should fail as link name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -74,9 +76,9 @@ public class TestDeleteCommand {
 
     try {
       deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-      Assert.fail("Delete link should fail as requested link doesn't exist!");
+      fail("Delete link should fail as requested link doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
     }
   }
 
@@ -86,15 +88,15 @@ public class TestDeleteCommand {
 
     // delete job -name job_test
     Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
-      Assert.fail("Delete job should fail as job name is missing!");
+      fail("Delete job should fail as job name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -104,9 +106,9 @@ public class TestDeleteCommand {
 
     try {
       deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-      Assert.fail("Delete job should fail as requested job doesn't exist!");
+      fail("Delete job should fail as requested job doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
     }
   }
 
@@ -116,15 +118,15 @@ public class TestDeleteCommand {
 
     // delete role -r role_test
     Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-r", "role_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option role
     try {
       status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
-      Assert.fail("Delete role should fail as role name is missing!");
+      fail("Delete role should fail as role name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -134,9 +136,19 @@ public class TestDeleteCommand {
 
     try {
       deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test"));
-      Assert.fail("Delete role should fail as requested role doesn't exist!");
+      fail("Delete role should fail as requested role doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-unknownOption"));
+      fail("Delete command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestDisableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestDisableCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestDisableCommand.java
index a236685..9e4e532 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestDisableCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestDisableCommand.java
@@ -22,6 +22,9 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 
@@ -31,7 +34,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -55,15 +57,15 @@ public class TestDisableCommand {
 
     // disable link -name link_test
     Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
-      Assert.fail("Disable link should fail as link name is missing!");
+      fail("Disable link should fail as link name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -73,9 +75,9 @@ public class TestDisableCommand {
 
     try {
       disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-      Assert.fail("Disable link should fail as requested link doesn't exist!");
+      fail("Disable link should fail as requested link doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
     }
   }
 
@@ -85,15 +87,15 @@ public class TestDisableCommand {
 
     // disable job -j job_test
     Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
-      Assert.fail("Disable job should fail as job name is missing!");
+      fail("Disable job should fail as job name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -103,9 +105,19 @@ public class TestDisableCommand {
 
     try {
       disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-      Assert.fail("Disable job should fail as requested job doesn't exist!");
+      fail("Disable job should fail as requested job doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
+      fail("Disable command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestEnableCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestEnableCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestEnableCommand.java
index 6ce78eb..4c52448 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestEnableCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestEnableCommand.java
@@ -22,6 +22,9 @@ import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doThrow;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 
@@ -31,7 +34,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -55,15 +57,15 @@ public class TestEnableCommand {
 
     // enable link -name link_test
     Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
-      Assert.fail("Enable link should fail as link name is missing!");
+      fail("Enable link should fail as link name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -73,9 +75,9 @@ public class TestEnableCommand {
 
     try {
       enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
-      Assert.fail("Enable link should fail as requested link doesn't exist!");
+      fail("Enable link should fail as requested link doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
     }
   }
 
@@ -85,15 +87,15 @@ public class TestEnableCommand {
 
     // enable job -j job_test
     Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for option name
     try {
       status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
-      Assert.fail("Enable job should fail as job id/name is missing!");
+      fail("Enable job should fail as job id/name is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -103,9 +105,19 @@ public class TestEnableCommand {
 
     try {
       enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-      Assert.fail("Enable job should fail as requested job doesn't exist!");
+      fail("Enable job should fail as requested job doesn't exist!");
     } catch (SqoopException e) {
-      Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+      assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
+      fail("Enable command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestGrantCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestGrantCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestGrantCommand.java
index 9f7f5b8..03a3e0c 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestGrantCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestGrantCommand.java
@@ -21,6 +21,9 @@ package org.apache.sqoop.shell;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.doNothing;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 import java.util.List;
@@ -31,7 +34,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -56,86 +58,86 @@ public class TestGrantCommand {
 
     // grant role -principal_type user -principal principal_test -role role_test
     Status status = (Status) grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_test", "-role", "role_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // principal_type is not correct
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "non_existing_principal_type", "-principal", "principal_test", "-role", "role_test"));
-      Assert.fail("Grant role should fail as principal-type is not among user/group/role!");
+      fail("Grant role should fail as principal-type is not among user/group/role!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // Missing argument for principal_type
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type"));
-      Assert.fail("Grant role should fail as parameters aren't complete!");
+      fail("Grant role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing argument for principal
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal"));
-      Assert.fail("Grant role should fail as parameters aren't complete!");
+      fail("Grant role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing argument for role name
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
-      Assert.fail("Grant role should fail as parameters aren't complete!");
+      fail("Grant role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing options principal-type and principal
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test"));
-      Assert.fail("Grant role should fail as of missing required options!");
+      fail("Grant role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing options principal-type and role name
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal", "principal_test"));
-      Assert.fail("Grant role should fail as of missing required options!");
+      fail("Grant role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing options principal and role name
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "role"));
-      Assert.fail("Grant role should fail as of missing required options!");
+      fail("Grant role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option principal-type
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test", "-principal", "principal_test"));
-      Assert.fail("Grant role should fail as of missing required options!");
+      fail("Grant role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option role
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "group", "-principal", "principal_test"));
-      Assert.fail("Grant role should fail as of missing required options!");
+      fail("Grant role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
   }
 
@@ -146,57 +148,67 @@ public class TestGrantCommand {
 
     // grant privilege -resource-type connector -resource resource_test -action read -principal principal_test -principal_type group -with-grant
     Status status = (Status) grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // resource-type is not correct
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "non_existing_resource_type", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Grant privilege should fail as resource-type is not among server/connector/link/job!");
+      fail("Grant privilege should fail as resource-type is not among server/connector/link/job!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // action is not correct
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "non_existing_action", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Grant privilege should fail as action is not among read/write/all!");
+      fail("Grant privilege should fail as action is not among read/write/all!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // principal-type is not correct
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
-      Assert.fail("Grant privilege should fail as principal-type is not among user/group/role!");
+      fail("Grant privilege should fail as principal-type is not among user/group/role!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // Missing argument for option resource-type
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
-      Assert.fail("Grant privilege should fail as parameters aren't complete!");
+      fail("Grant privilege should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing option principal-type
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-with-grant"));
-      Assert.fail("Grant privilege should fail as of missing required options!");
+      fail("Grant privilege should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option action
     try {
       grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Grant privilege should fail as of missing required options!");
+      fail("Grant privilege should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-unknownOption"));
+      fail("Grant command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestRevokeCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestRevokeCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestRevokeCommand.java
index 88f04f2..967cec6 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestRevokeCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestRevokeCommand.java
@@ -21,6 +21,9 @@ package org.apache.sqoop.shell;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.doNothing;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 import java.util.List;
@@ -31,7 +34,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -56,86 +58,86 @@ public class TestRevokeCommand {
 
     // revoke role -principal_type user -principal principal_test -role role_1
     Status status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_test", "-role", "role_1"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // principal_type is not correct
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "non_existing_principal_type", "-principal", "principal_test", "-role", "role_1"));
-      Assert.fail("Revoke role should fail as principal-type is not among user/group/role!");
+      fail("Revoke role should fail as principal-type is not among user/group/role!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // Missing argument for principal_type
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type"));
-      Assert.fail("Revoke role should fail as parameters aren't complete!");
+      fail("Revoke role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing argument for principal
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal"));
-      Assert.fail("Revoke role should fail as parameters aren't complete!");
+      fail("Revoke role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing argument for role name
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
-      Assert.fail("Revoke role should fail as parameters aren't complete!");
+      fail("Revoke role should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Missing options principal-type and principal
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_1"));
-      Assert.fail("Revoke role should fail as of missing required options!");
+      fail("Revoke role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing options principal-type and role name
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal", "principal_test"));
-      Assert.fail("Revoke role should fail as of missing required options!");
+      fail("Revoke role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing options principal and role name
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "role"));
-      Assert.fail("Revoke role should fail as of missing required options!");
+      fail("Revoke role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option principal-type
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_1", "-principal", "principal_test"));
-      Assert.fail("Revoke role should fail as of missing required options!");
+      fail("Revoke role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option role
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "group", "-principal", "principal_test"));
-      Assert.fail("Revoke role should fail as of missing required options!");
+      fail("Revoke role should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
   }
 
@@ -146,73 +148,83 @@ public class TestRevokeCommand {
 
     // revoke privilege -resource-type connector -resource resource_test -action read -principal principal_test -principal_type group -with-grant
     Status status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // resource-type is not correct
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "non_existing_resource_type", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as resource-type is not among server/connector/link/job!");
+      fail("Revoke privilege should fail as resource-type is not among server/connector/link/job!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // action is not correct
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "non_existing_action", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as action is not among read/write/all!");
+      fail("Revoke privilege should fail as action is not among read/write/all!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // principal-type is not correct
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as principal-type is not among user/group/role!");
+      fail("Revoke privilege should fail as principal-type is not among user/group/role!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("No enum constant"));
+      assertTrue(e.getMessage().contains("No enum constant"));
     }
 
     // Missing argument for option resource-type
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as parameters aren't complete!");
+      fail("Revoke privilege should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
 
     // Revoke all privileges for principal: revoke privilege -principal principal_test -principal_type group -with-grant
     status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing option principal-type
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as of missing required options!");
+      fail("Revoke privilege should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option principal
     try {
       revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal-type", "group", "-with-grant"));
-      Assert.fail("Revoke privilege should fail as of missing required options!");
+      fail("Revoke privilege should fail as of missing required options!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // option resource, resource-type and action must be used together: missing option action
     status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.ERROR);
+    assertTrue(status != null && status == Status.ERROR);
 
     // option resource, resource-type and action must be used together: missing option resource
     status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.ERROR);
+    assertTrue(status != null && status == Status.ERROR);
 
     // option resource, resource-type and action must be used together: missing option resource-type
     status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
-    Assert.assertTrue(status != null && status == Status.ERROR);
+    assertTrue(status != null && status == Status.ERROR);
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-unknownOption"));
+      fail("Revoke command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestSetCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestSetCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestSetCommand.java
index b231cf2..93e1e3e 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestSetCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestSetCommand.java
@@ -18,6 +18,11 @@
 
 package org.apache.sqoop.shell;
 
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
 import java.util.Arrays;
 
 import org.apache.commons.lang.StringUtils;
@@ -27,7 +32,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -50,41 +54,41 @@ public class TestSetCommand {
     ShellEnvironment.cleanup();
     // set server -url http://host-test:7070/sqoop-test
     Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
 
     // use the default webapp path if not specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertTrue(client.getServerUrl().equals("http://host-test:7070/sqoop/"));
+    assertTrue(status != null && status == Status.OK);
+    assertTrue(client.getServerUrl().equals("http://host-test:7070/sqoop/"));
 
     // use the default webapp and port if not specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test/"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertTrue(client.getServerUrl().equals("http://host-test:12000/sqoop/"));
+    assertTrue(status != null && status == Status.OK);
+    assertTrue(client.getServerUrl().equals("http://host-test:12000/sqoop/"));
 
     // option host is ignored when option url is specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-host", "host2-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
 
     // option port is ignored when option url is specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-port", "12000"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
 
     // option webapp is ignored when option url is specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-webapp", "sqoop2-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
 
     // Missing argument for option url
     try {
       status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url"));
-      Assert.fail("Set server should fail as url is missing!");
+      fail("Set server should fail as url is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -93,59 +97,69 @@ public class TestSetCommand {
     ShellEnvironment.cleanup();
     // use option host, port, webapp when option url is not specified
     Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070", "-webapp", "sqoop2-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop2-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop2-test/");
 
     ShellEnvironment.cleanup();
     // use default host if option host is not specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-port", "7070", "-webapp", "sqoop2-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://localhost:7070/sqoop2-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://localhost:7070/sqoop2-test/");
 
     ShellEnvironment.cleanup();
     // use default port if option port is not specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-webapp", "sqoop2-test"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host2-test:12000/sqoop2-test/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host2-test:12000/sqoop2-test/");
 
     ShellEnvironment.cleanup();
     // use default webapp if option webapp is not specified
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop/");
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop/");
   }
 
   @Test
   public void testSetOption() {
     // set option -name verbose -value true
     Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "true"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertTrue(ShellEnvironment.isVerbose());
+    assertTrue(status != null && status == Status.OK);
+    assertTrue(ShellEnvironment.isVerbose());
 
     // set option -name verbose -value 1
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "1"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertTrue(ShellEnvironment.isVerbose());
+    assertTrue(status != null && status == Status.OK);
+    assertTrue(ShellEnvironment.isVerbose());
 
     // set option -name verbose -value 0
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "0"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertFalse(ShellEnvironment.isVerbose());
+    assertTrue(status != null && status == Status.OK);
+    assertFalse(ShellEnvironment.isVerbose());
 
     // set option -name poll-timeout -value 12345
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "12345"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(ShellEnvironment.getPollTimeout(), 12345);
 
     // when value of poll-timeout is not number, poll-timeout should stay the old value
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "abc"));
-    Assert.assertTrue(status != null && status == Status.OK);
-    Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+    assertTrue(status != null && status == Status.OK);
+    assertEquals(ShellEnvironment.getPollTimeout(), 12345);
 
     // skip non exist options, options already set should stay the old value
     status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "non-exist-option", "-value", "opt-value"));
-    Assert.assertTrue(status == null);
-    Assert.assertFalse(ShellEnvironment.isVerbose());
-    Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+    assertTrue(status == null);
+    assertFalse(ShellEnvironment.isVerbose());
+    assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "true", "-unknownOption"));
+      fail("Set command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
index 6463bd5..49affa3 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestShowCommand.java
@@ -21,6 +21,10 @@ package org.apache.sqoop.shell;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertFalse;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -50,7 +54,6 @@ import org.apache.sqoop.utils.MapResourceBundle;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
 import org.codehaus.groovy.tools.shell.IO;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -75,47 +78,47 @@ public class TestShowCommand {
     // show server -host -port -webapp
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "-port", "-webapp"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Server host:"));
-    Assert.assertTrue(str.contains("Server port:"));
-    Assert.assertTrue(str.contains("Server webapp:"));
+    assertTrue(str.contains("Server host:"));
+    assertTrue(str.contains("Server port:"));
+    assertTrue(str.contains("Server webapp:"));
 
     // show server -all
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-all"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Server host:"));
-    Assert.assertTrue(str.contains("Server port:"));
-    Assert.assertTrue(str.contains("Server webapp:"));
+    assertTrue(str.contains("Server host:"));
+    assertTrue(str.contains("Server port:"));
+    assertTrue(str.contains("Server webapp:"));
 
     // show server -host
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Server host:"));
-    Assert.assertFalse(str.contains("Server port:"));
-    Assert.assertFalse(str.contains("Server webapp:"));
+    assertTrue(str.contains("Server host:"));
+    assertFalse(str.contains("Server port:"));
+    assertFalse(str.contains("Server webapp:"));
 
     // show server -port
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-port"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertFalse(str.contains("Server host:"));
-    Assert.assertTrue(str.contains("Server port:"));
-    Assert.assertFalse(str.contains("Server webapp:"));
+    assertFalse(str.contains("Server host:"));
+    assertTrue(str.contains("Server port:"));
+    assertFalse(str.contains("Server webapp:"));
 
     // show server -webapp
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-webapp"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertFalse(str.contains("Server host:"));
-    Assert.assertFalse(str.contains("Server port:"));
-    Assert.assertTrue(str.contains("Server webapp:"));
+    assertFalse(str.contains("Server host:"));
+    assertFalse(str.contains("Server port:"));
+    assertTrue(str.contains("Server webapp:"));
   }
 
   @Test
@@ -125,29 +128,29 @@ public class TestShowCommand {
     // show version -server -client -api
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION, "-server", "-client", "-api"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("server version:"));
-    Assert.assertTrue(str.contains("client version:"));
-    Assert.assertTrue(str.contains("API versions:"));
+    assertTrue(str.contains("server version:"));
+    assertTrue(str.contains("client version:"));
+    assertTrue(str.contains("API versions:"));
 
     // show version -all
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION, "-all"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("server version:"));
-    Assert.assertTrue(str.contains("client version:"));
-    Assert.assertTrue(str.contains("API versions:"));
+    assertTrue(str.contains("server version:"));
+    assertTrue(str.contains("client version:"));
+    assertTrue(str.contains("API versions:"));
 
     // show client version when no option is specified
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertFalse(str.contains("server version:"));
-    Assert.assertTrue(str.contains("client version:"));
-    Assert.assertFalse(str.contains("API versions:"));
+    assertFalse(str.contains("server version:"));
+    assertTrue(str.contains("client version:"));
+    assertFalse(str.contains("API versions:"));
   }
 
   @Test
@@ -162,26 +165,26 @@ public class TestShowCommand {
     // show connector summary
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Name"));
-    Assert.assertTrue(str.contains("Version"));
-    Assert.assertTrue(str.contains("Class"));
-    Assert.assertTrue(str.contains("Supported Directions"));
+    assertTrue(str.contains("Name"));
+    assertTrue(str.contains("Version"));
+    assertTrue(str.contains("Class"));
+    assertTrue(str.contains("Supported Directions"));
 
     // show connector -all
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR, "-all"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("connector(s) to show:"));
+    assertTrue(str.contains("connector(s) to show:"));
 
     // show connector -name test_connector
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR, "-name", "test_connector"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Connector with Name: test_connector"));
+    assertTrue(str.contains("Connector with Name: test_connector"));
   }
 
   @SuppressWarnings({ "rawtypes", "unchecked" })
@@ -194,9 +197,9 @@ public class TestShowCommand {
     // show driver
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_DRIVER_CONFIG));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Driver specific options:"));
+    assertTrue(str.contains("Driver specific options:"));
   }
 
   @Test
@@ -209,25 +212,25 @@ public class TestShowCommand {
     // show link summary
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Name"));
-    Assert.assertTrue(str.contains("Connector Name"));
-    Assert.assertTrue(str.contains("Enabled"));
+    assertTrue(str.contains("Name"));
+    assertTrue(str.contains("Connector Name"));
+    assertTrue(str.contains("Enabled"));
 
     // show link -all
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK, "-all"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("link(s) to show:"));
+    assertTrue(str.contains("link(s) to show:"));
 
     // show link -name linkName
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("link with name"));
+    assertTrue(str.contains("link with name"));
   }
 
   @Test
@@ -246,34 +249,34 @@ public class TestShowCommand {
     // show job summary
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Id"));
-    Assert.assertTrue(str.contains("Name"));
-    Assert.assertTrue(str.contains("From Connector"));
-    Assert.assertTrue(str.contains("To Connector"));
-    Assert.assertTrue(str.contains("Enabled"));
+    assertTrue(str.contains("Id"));
+    assertTrue(str.contains("Name"));
+    assertTrue(str.contains("From Connector"));
+    assertTrue(str.contains("To Connector"));
+    assertTrue(str.contains("Enabled"));
 
     // show job -all
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-all"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("job(s) to show:"));
+    assertTrue(str.contains("job(s) to show:"));
 
     // show job -name jobName
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Job with name"));
+    assertTrue(str.contains("Job with name"));
 
     // show job -connector fromConnectorName
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-connector", "fromConnectorName"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("job(s) to show:"));
+    assertTrue(str.contains("job(s) to show:"));
   }
 
   @Test
@@ -284,36 +287,36 @@ public class TestShowCommand {
     // show submission -details -job jobName
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail", "-job", "jobName"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Submission details"));
+    assertTrue(str.contains("Submission details"));
 
     // show submission -details
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Submission details"));
+    assertTrue(str.contains("Submission details"));
 
     // show submission -job jobName
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-job", "jobName"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Job Name"));
-    Assert.assertTrue(str.contains("External Id"));
-    Assert.assertTrue(str.contains("Status"));
-    Assert.assertTrue(str.contains("Last Update Date"));
+    assertTrue(str.contains("Job Name"));
+    assertTrue(str.contains("External Id"));
+    assertTrue(str.contains("Status"));
+    assertTrue(str.contains("Last Update Date"));
 
     // show submission
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Job Name"));
-    Assert.assertTrue(str.contains("External Id"));
-    Assert.assertTrue(str.contains("Status"));
-    Assert.assertTrue(str.contains("Last Update Date"));
+    assertTrue(str.contains("Job Name"));
+    assertTrue(str.contains("External Id"));
+    assertTrue(str.contains("Status"));
+    assertTrue(str.contains("Last Update Date"));
   }
 
   @Test
@@ -321,24 +324,24 @@ public class TestShowCommand {
     // show option -name verbose
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Verbose ="));
+    assertTrue(str.contains("Verbose ="));
 
     // show option -name poll-timeout
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Poll-timeout ="));
+    assertTrue(str.contains("Poll-timeout ="));
 
     // show all options
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Verbose ="));
-    Assert.assertTrue(str.contains("Poll-timeout ="));
+    assertTrue(str.contains("Verbose ="));
+    assertTrue(str.contains("Poll-timeout ="));
   }
 
   @Test
@@ -347,17 +350,17 @@ public class TestShowCommand {
     // show role -principal-type user -principal principal_1
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_1"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Role Name"));
+    assertTrue(str.contains("Role Name"));
 
     when(client.getRoles()).thenReturn(new ArrayList<MRole>());
     // show role
     out.reset();
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_ROLE));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Role Name"));
+    assertTrue(str.contains("Role Name"));
   }
 
   @Test
@@ -366,17 +369,17 @@ public class TestShowCommand {
     // show principal -role role_test
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL, "-role", "role_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Principal Name"));
-    Assert.assertTrue(str.contains("Principal Type"));
+    assertTrue(str.contains("Principal Name"));
+    assertTrue(str.contains("Principal Type"));
 
     // Missing option role name
     try {
       showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL));
-      Assert.fail("Show principal should fail as role name is missing!");
+      fail("Show principal should fail as role name is missing!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
   }
 
@@ -387,52 +390,62 @@ public class TestShowCommand {
     out.reset();
     Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE,
         "-principal-type", "user", "-principal", "principal_test", "-resource-type", "connector", "-resource", "resource_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     String str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Action"));
-    Assert.assertTrue(str.contains("Resource Name"));
-    Assert.assertTrue(str.contains("Resource Type"));
-    Assert.assertTrue(str.contains("With Grant"));
+    assertTrue(str.contains("Action"));
+    assertTrue(str.contains("Resource Name"));
+    assertTrue(str.contains("Resource Type"));
+    assertTrue(str.contains("With Grant"));
 
     // show privilege -principal-type user -principal principal_test
     status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
     str = new String(out.toByteArray());
-    Assert.assertTrue(str.contains("Action"));
-    Assert.assertTrue(str.contains("Resource Name"));
-    Assert.assertTrue(str.contains("Resource Type"));
-    Assert.assertTrue(str.contains("With Grant"));
+    assertTrue(str.contains("Action"));
+    assertTrue(str.contains("Resource Name"));
+    assertTrue(str.contains("Resource Type"));
+    assertTrue(str.contains("With Grant"));
 
     // options resource-type and resource must be used together: missing option resource
     try {
       showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test", "-resource-type", "connector"));
-      Assert.fail("Show principal should fail as option resource is missing!");
+      fail("Show principal should fail as option resource is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
+      assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
     }
 
     // options resource-type and resource must be used together: missing option resource-type
     try {
       showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test", "-resource", "resource_test"));
-      Assert.fail("Show principal should fail as option resource-type is missing!");
+      fail("Show principal should fail as option resource-type is missing!");
     } catch (SqoopException e) {
-      Assert.assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
+      assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
     }
 
     // Missing option principal-type
     try {
       showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal", "principal_test", "-resource-type", "connector", "-resource", "resource_test"));
-      Assert.fail("Show privilege should fail as option principal-type is missing!");
+      fail("Show privilege should fail as option principal-type is missing!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertTrue(e.getMessage().contains("Missing required option"));
     }
 
     // Missing option principal
     try {
-      showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL, "-principal-type", "group", "-resource-type", "connector", "-resource", "resource_test"));
-      Assert.fail("Show privilege should fail as option principal is missing!");
+      showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "group", "-resource-type", "connector", "-resource", "resource_test"));
+      fail("Show privilege should fail as option principal is missing!");
     } catch (Exception e) {
-      Assert.assertTrue(e.getMessage().contains("Missing required option"));
+      assertTrue(e.getMessage().contains("Missing required option"));
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-unknownOption"));
+      fail("Show principal should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestStartCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestStartCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestStartCommand.java
index b55b087..7dc407c 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestStartCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestStartCommand.java
@@ -21,6 +21,9 @@ package org.apache.sqoop.shell;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 
@@ -32,7 +35,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -57,15 +59,15 @@ public class TestStartCommand {
 
     // start job -name job_test
     Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for name
     try {
       startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
-      Assert.fail("Start job should fail as parameters aren't complete!");
+      fail("Start job should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
     }
   }
 
@@ -75,6 +77,16 @@ public class TestStartCommand {
 
     // start job -name job_test -synchronous
     Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-synchronous"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
+      fail("Start command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/c40c23c9/shell/src/test/java/org/apache/sqoop/shell/TestStatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/test/java/org/apache/sqoop/shell/TestStatusCommand.java b/shell/src/test/java/org/apache/sqoop/shell/TestStatusCommand.java
index 9fac463..ce01842 100644
--- a/shell/src/test/java/org/apache/sqoop/shell/TestStatusCommand.java
+++ b/shell/src/test/java/org/apache/sqoop/shell/TestStatusCommand.java
@@ -21,6 +21,9 @@ package org.apache.sqoop.shell;
 import static org.mockito.Matchers.any;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.when;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
 
 import java.util.Arrays;
 
@@ -31,7 +34,6 @@ import org.apache.sqoop.shell.core.Constants;
 import org.apache.sqoop.shell.core.ShellError;
 import org.apache.sqoop.validation.Status;
 import org.codehaus.groovy.tools.shell.Groovysh;
-import org.testng.Assert;
 import org.testng.annotations.BeforeTest;
 import org.testng.annotations.Test;
 
@@ -56,15 +58,25 @@ public class TestStatusCommand {
 
     // status job -name job_test
     Status status = (Status) statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
-    Assert.assertTrue(status != null && status == Status.OK);
+    assertTrue(status != null && status == Status.OK);
 
     // Missing argument for name
     try {
       statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
-      Assert.fail("Get job status should fail as parameters aren't complete!");
+      fail("Get job status should fail as parameters aren't complete!");
     } catch (SqoopException e) {
-      Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
-      Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
+      assertEquals(ShellError.SHELL_0003, e.getErrorCode());
+      assertTrue(e.getMessage().contains("Missing argument for option"));
+    }
+  }
+
+  @Test
+  public void testUnknowOption() {
+    try {
+      statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
+      fail("Status command should fail as unknown option encountered!");
+    } catch (Exception e) {
+      assertTrue(e.getMessage().contains("Unknown option encountered"));
     }
   }
 }


Mime
View raw message