You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sqoop.apache.org by ja...@apache.org on 2016/01/14 21:06:50 UTC

[1/2] sqoop git commit: SQOOP-2758: Sqoop2: Add integration test for shell

Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 88654b95f -> 67214a48c


http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/ShowCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/ShowCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/ShowCommandTest.java
new file mode 100644
index 0000000..9fd4811
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/ShowCommandTest.java
@@ -0,0 +1,300 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.ShowCommand;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.codehaus.groovy.tools.shell.IO;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+import static org.testng.Assert.*;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class ShowCommandTest extends ShellTestCase {
+  private ByteArrayOutputStream out;
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new ShowCommand(shell);
+  }
+
+  @Test
+  public void testShowOption() {
+    resetIO();
+
+    // show option -name verbose
+    Status status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose"));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Verbose ="));
+
+    // show option -name poll-timeout
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Poll-timeout ="));
+
+    // show all options
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Verbose ="));
+    assertTrue(str.contains("Poll-timeout ="));
+  }
+
+  @Test
+  public void testShowServer() throws Exception {
+    resetIO();
+
+    // show server -host -port -webapp
+    Status status = (Status)  execute(Arrays.asList(Constants.FN_SERVER, "-host", "-port", "-webapp"));
+    assertTrue(status != null && status == Status.OK);
+    String outPuts = new String(out.toByteArray());
+    assertTrue(outPuts.contains("Server host:"));
+    assertTrue(outPuts.contains("Server port:"));
+    assertTrue(outPuts.contains("Server webapp:"));
+
+    // show server -all
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-all"));
+    assertTrue(status != null && status == Status.OK);
+    outPuts = new String(out.toByteArray());
+    assertTrue(outPuts.contains("Server host:"));
+    assertTrue(outPuts.contains("Server port:"));
+    assertTrue(outPuts.contains("Server webapp:"));
+
+    // show server -host
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-host"));
+    assertTrue(status != null && status == Status.OK);
+    outPuts = new String(out.toByteArray());
+    assertTrue(outPuts.contains("Server host:"));
+    assertFalse(outPuts.contains("Server port:"));
+    assertFalse(outPuts.contains("Server webapp:"));
+
+    // show server -port
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-port"));
+    assertTrue(status != null && status == Status.OK);
+    outPuts = new String(out.toByteArray());
+    assertFalse(outPuts.contains("Server host:"));
+    assertTrue(outPuts.contains("Server port:"));
+    assertFalse(outPuts.contains("Server webapp:"));
+
+    // show server -webapp
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-webapp"));
+    assertTrue(status != null && status == Status.OK);
+    outPuts = new String(out.toByteArray());
+    assertFalse(outPuts.contains("Server host:"));
+    assertFalse(outPuts.contains("Server port:"));
+    assertTrue(outPuts.contains("Server webapp:"));
+  }
+
+  @Test
+  public void testShowVersion() {
+    resetIO();
+
+    // show version -server -client -api
+    Status status = (Status) execute(Arrays.asList(Constants.FN_VERSION, "-server", "-client", "-api"));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("server version:"));
+    assertTrue(str.contains("client version:"));
+    assertTrue(str.contains("API versions:"));
+
+    // show version -all
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_VERSION, "-all"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    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) execute(Arrays.asList(Constants.FN_VERSION));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertFalse(str.contains("server version:"));
+    assertTrue(str.contains("client version:"));
+    assertFalse(str.contains("API versions:"));
+  }
+
+  @Test
+  public void testShowConnector() {
+    resetIO();
+
+    // show connector summary
+    Status status = (Status) execute(Arrays.asList(Constants.FN_CONNECTOR));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Name"));
+    assertTrue(str.contains("Version"));
+    assertTrue(str.contains("Class"));
+    assertTrue(str.contains("Supported Directions"));
+
+    // show connector -all
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_CONNECTOR, "-all"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("connector(s) to show:"));
+
+    // show connector -name test_connector
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_CONNECTOR, "-name", "generic-jdbc-connector"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Connector with Name: generic-jdbc-connector"));
+  }
+
+  @Test
+  public void testShowDriver() {
+    resetIO();
+
+    // show driver
+    Status status = (Status) execute(Arrays.asList(Constants.FN_DRIVER_CONFIG));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Driver specific options:"));
+  }
+
+  @Test
+  public void testShowLink() {
+    createLink("linkName");
+    resetIO();
+
+    // show link summary
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Name"));
+    assertTrue(str.contains("Connector Name"));
+    assertTrue(str.contains("Enabled"));
+
+    // show link -all
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-all"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("link(s) to show:"));
+
+    // show link -name linkName
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("link with name"));
+  }
+
+  @Test
+  public void testShowJob() {
+    createJob("fromLink", "toLink", "jobName");
+    resetIO();
+
+    // show job summary
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    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) execute(Arrays.asList(Constants.FN_JOB, "-all"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("job(s) to show:"));
+
+    // show job -name jobName
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Job with name"));
+
+    // show job -connector generic-jdbc-connector
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-connector", "generic-jdbc-connector"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("job(s) to show:"));
+  }
+
+  @Test
+  public void testShowSubmission() throws Exception {
+    createJob("fromLink", "toLink", "jobForShowCommand");
+    executeJob("jobForShowCommand", false);
+    resetIO();
+
+    // show submission -details -job jobName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail", "-job", "jobForShowCommand"));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Submission details"));
+
+    // show submission -details
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Submission details"));
+
+    // show submission -job jobName
+    out.reset();
+    status = (Status) execute(Arrays.asList(Constants.FN_SUBMISSION, "-job", "jobForShowCommand"));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    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) execute(Arrays.asList(Constants.FN_SUBMISSION));
+    assertTrue(status != null && status == Status.OK);
+    str = new String(out.toByteArray());
+    assertTrue(str.contains("Job Name"));
+    assertTrue(str.contains("External Id"));
+    assertTrue(str.contains("Status"));
+    assertTrue(str.contains("Last Update Date"));
+  }
+
+  private void resetIO() {
+    out = new ByteArrayOutputStream();
+    ShellEnvironment.setIo(new IO(System.in, out, System.err));
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/StartCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/StartCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/StartCommandTest.java
new file mode 100644
index 0000000..5504586
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/StartCommandTest.java
@@ -0,0 +1,77 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MSubmission;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.StartCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.submission.SubmissionStatus;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+import java.util.List;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class StartCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new StartCommand(shell);
+  }
+
+  @Test
+  public void testStartJob() throws Exception {
+    createJob("fromLink1", "toLink1", "jobForTestStartJob1");
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobForTestStartJob1"));
+    assertTrue(status != null && status == Status.OK);
+
+    List<MSubmission> submissions = getClient().getSubmissionsForJob("jobForTestStartJob1");
+    assertEquals(submissions.size(), 1);
+
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Start job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testStartJobWithSyn() throws Exception {
+    createJob("fromLink2", "toLink2", "jobForTestStartJob2");
+    // start job with synchronous
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobForTestStartJob2", "-synchronous"));
+    assertTrue(status != null && status == Status.OK);
+
+    List<MSubmission> submissions = getClient().getSubmissionsForJob("jobForTestStartJob2");
+    assertEquals(submissions.size(), 1);
+    assertTrue(submissions.get(0).getStatus() == SubmissionStatus.FAILED);
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/StatusCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/StatusCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/StatusCommandTest.java
new file mode 100644
index 0000000..7294b05
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/StatusCommandTest.java
@@ -0,0 +1,80 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.StatusCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.codehaus.groovy.tools.shell.IO;
+import org.testng.annotations.Test;
+
+import java.io.ByteArrayOutputStream;
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class StatusCommandTest extends ShellTestCase {
+  private ByteArrayOutputStream out;
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new StatusCommand(shell);
+  }
+
+  @Test
+  public void testShowStatus() throws Exception {
+    resetIO();
+
+    createJob("fromLink", "toLink", "jobForStatusCommand");
+    executeJob("jobForStatusCommand", false);
+
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobForStatusCommand"));
+    assertTrue(status != null && status == Status.OK);
+    String str = new String(out.toByteArray());
+    assertTrue(str.contains("Submission details"));
+    assertTrue(str.contains("Job Name: jobForStatusCommand"));
+    assertTrue(str.contains("Server URL"));
+    assertTrue(str.contains("Created by"));
+    assertTrue(str.contains("Creation date"));
+    assertTrue(str.contains("Lastly updated by"));
+    assertTrue(str.contains("Submission details"));
+
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Show status should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  private void resetIO() {
+    out = new ByteArrayOutputStream();
+    ShellEnvironment.setIo(new IO(System.in, out, System.err));
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/StopCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/StopCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/StopCommandTest.java
new file mode 100644
index 0000000..69110b2
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/StopCommandTest.java
@@ -0,0 +1,63 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.StopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class StopCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new StopCommand(shell);
+  }
+
+  @Test
+  public void testStopCommand() throws Exception {
+    createJob("fromLink1", "toLink1", "jobForTestStopCommand");
+    // start job
+    getClient().startJob("jobForTestStopCommand");
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "jobForTestStopCommand"));
+      fail("The given job is not running!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Stop job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/UpdateCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/UpdateCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/UpdateCommandTest.java
new file mode 100644
index 0000000..f9a35fe
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/UpdateCommandTest.java
@@ -0,0 +1,127 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.UpdateCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class UpdateCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new UpdateCommand(shell);
+  }
+
+  @Test
+  public void testUpdateLink() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    // creaet link
+    createLink("linkName");
+
+    // do the clone test
+    initData("Update\n" +                          // link name: append to the old link name
+            "linkConfig1\n" +            // link config1
+            "linkConfig2\n");            // link config2
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    assertTrue(status != null && status != Status.ERROR);
+    try {
+      getClient().getLink("linkName");
+      fail("The origin link name is not work.");
+    } catch (SqoopException e) {}
+
+    MLink link = getClient().getLink("linkNameUpdate");
+    assertEquals(link.getName(), "linkNameUpdate");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig1").getValue(),
+            "linkConfig1");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig2").getValue(),
+            "linkConfig2");
+  }
+
+  @Test
+  public void testUpdateNonExistingLink() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-name", "non-exist-link"));
+      fail("Update Link should fail as link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testUpdateJob() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    createJob("fromLink", "toLink", "jobName");
+
+    // create job -f link_from -to link_to
+    initData("Update\n" +                              // job name
+            "fromJobConfig1\n" +                      // from job config1
+            "fromJobConfig2\n" +                      // from job config2
+            "toJobConfig1\n" +                        // to job config1
+            "toJobConfig2\n\n\n\n\n\n");              // to job config2 and nothing for driver
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    assertTrue(status != null && status != Status.ERROR);
+
+    try {
+      getClient().getJob("jobName");
+      fail("The origin job name is not work.");
+    } catch (SqoopException e) {}
+
+    MJob job = getClient().getJob("jobNameUpdate");
+    assertEquals(job.getName(), "jobNameUpdate");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig1").getValue(), "fromJobConfig1");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig2").getValue(), "fromJobConfig2");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig1").getValue(), "toJobConfig1");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig2").getValue(), "toJobConfig2");
+  }
+
+  @Test
+  public void testUpdateNonExistingJob() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-jobName"));
+      fail("Update Job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java b/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java
new file mode 100644
index 0000000..4191d97
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java
@@ -0,0 +1,85 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.common.Direction;
+import org.apache.sqoop.connector.spi.ConnectorConfigurableUpgrader;
+import org.apache.sqoop.connector.spi.SqoopConnector;
+import org.apache.sqoop.job.etl.From;
+import org.apache.sqoop.job.etl.To;
+
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * A connector that does not do anything
+ */
+public class TestConnectorForShell extends SqoopConnector {
+
+  private static final From FROM = new From(
+          TestFromInitializerForShell.class,
+          TestPartitionerForShell.class,
+          TestPartitionForShell.class,
+          TestExtractorForShell.class,
+          TestFromDestroyerForShell.class);
+
+  private static final To TO = new To(TestToInitializerForShell.class,
+    TestLoaderForShell.class,
+    TestToDestroyerForShell.class);
+
+  @Override
+  public String getVersion() {
+    return "1.0";
+  }
+
+  @Override
+  public ResourceBundle getBundle(Locale locale) {
+    return ResourceBundle.getBundle("test-connector-for-shell", locale);
+  }
+
+  @Override
+  public Class getLinkConfigurationClass() {
+    return TestLinkConfigurationForShell.class;
+  }
+
+  @Override
+  public Class getJobConfigurationClass(Direction direction) {
+    switch (direction) {
+      case FROM:
+        return TestFromJobConfigurationForShell.class;
+      case TO:
+        return TestToJobConfigurationForShell.class;
+      default:
+        return null;
+    }
+  }
+
+  @Override
+  public From getFrom() {
+    return FROM;
+  }
+
+  @Override
+  public To getTo() {
+    return TO;
+  }
+
+  @Override
+  public ConnectorConfigurableUpgrader getConfigurableUpgrader(String oldConnectorVersion) {
+    return null;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java b/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java
new file mode 100644
index 0000000..cfb832f
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java
@@ -0,0 +1,35 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Extractor;
+import org.apache.sqoop.job.etl.ExtractorContext;
+
+public class TestExtractorForShell extends Extractor<TestLinkConfigurationForShell, TestFromJobConfigurationForShell, TestPartitionForShell> {
+
+  @Override
+  public void extract(ExtractorContext context,
+      TestLinkConfigurationForShell linkConfiguration,
+      TestFromJobConfigurationForShell jobConfiguration,
+      TestPartitionForShell partition) {
+  }
+
+  @Override
+  public long getRowsRead() {
+    return 0;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java
new file mode 100644
index 0000000..4520c39
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Destroyer;
+import org.apache.sqoop.job.etl.DestroyerContext;
+
+public class TestFromDestroyerForShell extends Destroyer<TestLinkConfigurationForShell, TestFromJobConfigurationForShell> {
+  @Override
+  public void destroy(DestroyerContext context, TestLinkConfigurationForShell linkConfig,
+                      TestFromJobConfigurationForShell jobConfig) {
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java
new file mode 100644
index 0000000..82f0d47
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Initializer;
+import org.apache.sqoop.job.etl.InitializerContext;
+
+public class TestFromInitializerForShell extends Initializer<TestLinkConfigurationForShell, TestFromJobConfigurationForShell> {
+  @Override
+  public void initialize(InitializerContext context, TestLinkConfigurationForShell linkConfig,
+                         TestFromJobConfigurationForShell jobConfig) {
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java
new file mode 100644
index 0000000..aa8d5c0
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java
@@ -0,0 +1,28 @@
+/**
+ * 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.
+ */
+import org.apache.sqoop.model.ConfigClass;
+import org.apache.sqoop.model.Input;
+
+@ConfigClass
+public class TestFromJobConfigForShell {
+  @Input
+  public String fromJobConfig1;
+
+  @Input
+  public String fromJobConfig2;
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java
new file mode 100644
index 0000000..9fc9bbd
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java
@@ -0,0 +1,29 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.model.ConfigurationClass;
+import org.apache.sqoop.model.Config;
+
+@ConfigurationClass
+public class TestFromJobConfigurationForShell {
+  @Config public TestFromJobConfigForShell testFromJobConfigForShell;
+
+  public TestFromJobConfigurationForShell() {
+    testFromJobConfigForShell = new TestFromJobConfigForShell();
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java
new file mode 100644
index 0000000..ebb4f94
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java
@@ -0,0 +1,32 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.model.ConfigClass;
+import org.apache.sqoop.model.Input;
+
+/**
+ *
+ */
+@ConfigClass
+public class TestLinkConfigForShell {
+  @Input
+  public String linkConfig1;
+
+  @Input
+  public String linkConfig2;
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java
new file mode 100644
index 0000000..d512d77
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java
@@ -0,0 +1,29 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.model.ConfigurationClass;
+import org.apache.sqoop.model.Config;
+
+@ConfigurationClass
+public class TestLinkConfigurationForShell {
+  @Config public TestLinkConfigForShell testLinkConfigForShell;
+
+  public TestLinkConfigurationForShell() {
+    testLinkConfigForShell = new TestLinkConfigForShell();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java b/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java
new file mode 100644
index 0000000..8f440f2
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java
@@ -0,0 +1,33 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Loader;
+import org.apache.sqoop.job.etl.LoaderContext;
+
+public class TestLoaderForShell extends Loader<TestLinkConfigurationForShell, TestToJobConfigurationForShell> {
+
+  @Override
+  public void load(LoaderContext context, TestLinkConfigurationForShell linkConfiguration,
+                   TestToJobConfigurationForShell toJobConfig) throws Exception {
+  }
+
+  @Override
+  public long getRowsWritten() {
+    return 0;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java b/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java
new file mode 100644
index 0000000..5f5b9a5
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java
@@ -0,0 +1,36 @@
+/**
+ * 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.
+ */
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+
+import org.apache.sqoop.job.etl.Partition;
+
+public class TestPartitionForShell extends Partition {
+  public TestPartitionForShell() {}
+
+  @Override
+  public void readFields(DataInput in) throws IOException {}
+
+  @Override
+  public void write(DataOutput out) throws IOException {}
+
+  @Override
+  public String toString() {return "";}
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java b/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java
new file mode 100644
index 0000000..fa21a52
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java
@@ -0,0 +1,37 @@
+/**
+ * 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.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.sqoop.job.etl.Partition;
+import org.apache.sqoop.job.etl.Partitioner;
+import org.apache.sqoop.job.etl.PartitionerContext;
+
+public class TestPartitionerForShell extends Partitioner<TestLinkConfigurationForShell, TestFromJobConfigurationForShell> {
+  public TestPartitionerForShell() {
+  }
+
+  @Override
+  public List<Partition> getPartitions(PartitionerContext context,
+      TestLinkConfigurationForShell linkConfiguration, TestFromJobConfigurationForShell fromJobConfiguration) {
+    List<Partition> partitionList = new ArrayList<Partition>();
+    partitionList.add(new TestPartitionForShell());
+    return partitionList;
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java b/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java
new file mode 100644
index 0000000..e172204
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Destroyer;
+import org.apache.sqoop.job.etl.DestroyerContext;
+
+public class TestToDestroyerForShell extends Destroyer<TestLinkConfigurationForShell, TestToJobConfigurationForShell> {
+  @Override
+  public void destroy(DestroyerContext context, TestLinkConfigurationForShell linkConfig,
+                      TestToJobConfigurationForShell jobConfig) {
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java b/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java
new file mode 100644
index 0000000..950ef7e
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java
@@ -0,0 +1,27 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.job.etl.Initializer;
+import org.apache.sqoop.job.etl.InitializerContext;
+
+public class TestToInitializerForShell extends Initializer<TestLinkConfigurationForShell, TestToJobConfigurationForShell> {
+  @Override
+  public void initialize(InitializerContext context, TestLinkConfigurationForShell linkConfig,
+                         TestToJobConfigurationForShell jobConfig) {
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java
new file mode 100644
index 0000000..08fa715
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java
@@ -0,0 +1,30 @@
+import org.apache.sqoop.model.ConfigClass;
+import org.apache.sqoop.model.Input;
+
+/**
+ * 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.
+ */
+
+@ConfigClass
+public class TestToJobConfigForShell {
+  @Input
+  public String toJobConfig1;
+
+  @Input
+  public String toJobConfig2;
+
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java
new file mode 100644
index 0000000..22664de
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java
@@ -0,0 +1,29 @@
+/**
+ * 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.
+ */
+
+import org.apache.sqoop.model.ConfigurationClass;
+import org.apache.sqoop.model.Config;
+
+@ConfigurationClass
+public class TestToJobConfigurationForShell {
+  @Config public TestToJobConfigForShell testToJobConfigForShell;
+
+  public TestToJobConfigurationForShell() {
+    testToJobConfigForShell = new TestToJobConfigForShell();
+  }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties b/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties
new file mode 100644
index 0000000..24dfcad
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties
@@ -0,0 +1,18 @@
+# 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.
+
+# Test Connector Properties
+org.apache.sqoop.connector.class = TestConnectorForShell
+org.apache.sqoop.connector.name = test-connector-for-shell

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/TestConnectorForShell/test-connector-for-shell.properties
----------------------------------------------------------------------
diff --git a/test/src/test/resources/TestConnectorForShell/test-connector-for-shell.properties b/test/src/test/resources/TestConnectorForShell/test-connector-for-shell.properties
new file mode 100644
index 0000000..c0a4d2f
--- /dev/null
+++ b/test/src/test/resources/TestConnectorForShell/test-connector-for-shell.properties
@@ -0,0 +1,48 @@
+# 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.
+
+# Generic JDBC Connector Resources
+
+############################
+# Link Config
+#
+testLinkConfigForShell.label = Link configuration
+testLinkConfigForShell.help = help info
+
+testLinkConfigForShell.linkConfig1.label = link config1
+testLinkConfigForShell.linkConfig1.help = link config1 help
+
+testLinkConfigForShell.linkConfig2.label = link config2
+testLinkConfigForShell.linkConfig2.help = link config2 help
+
+# from job Config
+testFromJobConfigForShell.label = from job
+testFromJobConfigForShell.help = from job help
+
+testFromJobConfigForShell.fromJobConfig1.label = from job config1
+testFromJobConfigForShell.fromJobConfig1.help = from job config1 help
+
+testFromJobConfigForShell.fromJobConfig2.label = from job config2
+testFromJobConfigForShell.fromJobConfig2.help = from job config2 help
+
+# to job Config
+testToJobConfigForShell.label = to job
+testToJobConfigForShell.help = to job help
+
+testToJobConfigForShell.toJobConfig1.label = to job config1
+testToJobConfigForShell.toJobConfig1.help = to job config1 help
+
+testToJobConfigForShell.toJobConfig2.label = to job config2
+testToJobConfigForShell.toJobConfig2.help = to job config2 help

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/resources/shell-tests-suite.xml
----------------------------------------------------------------------
diff --git a/test/src/test/resources/shell-tests-suite.xml b/test/src/test/resources/shell-tests-suite.xml
new file mode 100644
index 0000000..e2c0b09
--- /dev/null
+++ b/test/src/test/resources/shell-tests-suite.xml
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd" >
+
+<suite name="ShellTests" verbose="2" parallel="false">
+
+    <listeners>
+        <listener class-name="org.apache.sqoop.test.testng.SqoopTestListener" />
+    </listeners>
+
+    <test name="ShellTests">
+        <packages>
+            <package name="org.apache.sqoop.integration.shell"/>
+        </packages>
+    </test>
+
+</suite>
\ No newline at end of file


[2/2] sqoop git commit: SQOOP-2758: Sqoop2: Add integration test for shell

Posted by ja...@apache.org.
SQOOP-2758: Sqoop2: Add integration test for shell

(Colin Ma 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/67214a48
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/67214a48
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/67214a48

Branch: refs/heads/sqoop2
Commit: 67214a48c5278811da93b7d0a26d2f93eef1f6df
Parents: 88654b9
Author: Jarek Jarcec Cecho <ja...@apache.org>
Authored: Thu Jan 14 12:06:21 2016 -0800
Committer: Jarek Jarcec Cecho <ja...@apache.org>
Committed: Thu Jan 14 12:06:21 2016 -0800

----------------------------------------------------------------------
 .../java/org/apache/sqoop/shell/SetCommand.java |   2 +-
 .../org/apache/sqoop/shell/ShowCommand.java     |   2 +-
 .../org/apache/sqoop/shell/StartCommand.java    |   2 +-
 .../org/apache/sqoop/shell/StatusCommand.java   |   2 +-
 .../org/apache/sqoop/shell/StopCommand.java     |   2 +-
 test/pom.xml                                    |  20 ++
 .../test/infrastructure/SqoopTestCase.java      |  28 +-
 .../providers/SqoopInfrastructureProvider.java  |   8 +-
 ...SqoopInfrastructureProviderForShellTest.java |  37 +++
 ...tySqoopMiniClusterWithExternalConnector.java |  82 +++++
 .../testcases/ConnectorClasspathTestCase.java   | 235 ---------------
 .../sqoop/test/testcases/ShellTestCase.java     |  94 ++++++
 .../apache/sqoop/test/utils/ConnectorUtils.java | 236 +++++++++++++++
 .../connectorloading/ClasspathTest.java         |  25 +-
 .../ConnectorClasspathIsolationTest.java        |  11 +-
 .../SubmissionWithDisabledModelObjectsTest.java |   2 +-
 .../integration/shell/CloneCommandTest.java     | 125 ++++++++
 .../integration/shell/CreateCommandTest.java    | 117 ++++++++
 .../integration/shell/DeleteCommandTest.java    |  97 ++++++
 .../integration/shell/DisableCommandTest.java   |  97 ++++++
 .../integration/shell/EnableCommandTest.java    |  99 ++++++
 .../sqoop/integration/shell/SetCommandTest.java | 152 ++++++++++
 .../integration/shell/ShowCommandTest.java      | 300 +++++++++++++++++++
 .../integration/shell/StartCommandTest.java     |  77 +++++
 .../integration/shell/StatusCommandTest.java    |  80 +++++
 .../integration/shell/StopCommandTest.java      |  63 ++++
 .../integration/shell/UpdateCommandTest.java    | 127 ++++++++
 .../TestConnectorForShell.java                  |  85 ++++++
 .../TestExtractorForShell.java                  |  35 +++
 .../TestFromDestroyerForShell.java              |  27 ++
 .../TestFromInitializerForShell.java            |  27 ++
 .../TestFromJobConfigForShell.java              |  28 ++
 .../TestFromJobConfigurationForShell.java       |  29 ++
 .../TestLinkConfigForShell.java                 |  32 ++
 .../TestLinkConfigurationForShell.java          |  29 ++
 .../TestLoaderForShell.java                     |  33 ++
 .../TestPartitionForShell.java                  |  36 +++
 .../TestPartitionerForShell.java                |  37 +++
 .../TestToDestroyerForShell.java                |  27 ++
 .../TestToInitializerForShell.java              |  27 ++
 .../TestToJobConfigForShell.java                |  30 ++
 .../TestToJobConfigurationForShell.java         |  29 ++
 .../sqoopconnector.properties                   |  18 ++
 .../test-connector-for-shell.properties         |  48 +++
 test/src/test/resources/shell-tests-suite.xml   |  33 ++
 45 files changed, 2465 insertions(+), 267 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/shell/src/main/java/org/apache/sqoop/shell/SetCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/SetCommand.java b/shell/src/main/java/org/apache/sqoop/shell/SetCommand.java
index 0a04e3d..3feaac3 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/SetCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/SetCommand.java
@@ -23,7 +23,7 @@ import org.codehaus.groovy.tools.shell.Groovysh;
 
 public class SetCommand extends SqoopCommand {
 
-  protected SetCommand(Groovysh shell) {
+  public SetCommand(Groovysh shell) {
     super(shell,
       Constants.CMD_SET,
       Constants.CMD_SET_SC,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java b/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
index c148eeb..eb8522a 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/ShowCommand.java
@@ -23,7 +23,7 @@ import org.codehaus.groovy.tools.shell.Groovysh;
 
 public class ShowCommand extends SqoopCommand {
 
-  protected ShowCommand(Groovysh shell) {
+  public ShowCommand(Groovysh shell) {
     super(shell,
       Constants.CMD_SHOW,
       Constants.CMD_SHOW_SC,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/shell/src/main/java/org/apache/sqoop/shell/StartCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StartCommand.java b/shell/src/main/java/org/apache/sqoop/shell/StartCommand.java
index 679c1f7..28abc3d 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StartCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StartCommand.java
@@ -23,7 +23,7 @@ import org.codehaus.groovy.tools.shell.Groovysh;
 
 public class StartCommand extends SqoopCommand {
 
-  protected StartCommand(Groovysh shell) {
+  public StartCommand(Groovysh shell) {
     super(shell,
       Constants.CMD_START,
       Constants.CMD_START_SC,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java b/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
index 6082799..618b79d 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StatusCommand.java
@@ -23,7 +23,7 @@ import org.codehaus.groovy.tools.shell.Groovysh;
 
 public class StatusCommand extends SqoopCommand {
 
-  protected StatusCommand(Groovysh shell) {
+  public StatusCommand(Groovysh shell) {
     super(shell,
       Constants.CMD_STATUS,
       Constants.CMD_STATUS_SC,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/shell/src/main/java/org/apache/sqoop/shell/StopCommand.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/StopCommand.java b/shell/src/main/java/org/apache/sqoop/shell/StopCommand.java
index 83c571a..0afba26 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/StopCommand.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/StopCommand.java
@@ -23,7 +23,7 @@ import org.codehaus.groovy.tools.shell.Groovysh;
 
 public class StopCommand extends SqoopCommand {
 
-  protected StopCommand(Groovysh shell) {
+  public StopCommand(Groovysh shell) {
     super(shell,
       Constants.CMD_STOP,
       Constants.CMD_STOP_SC,

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/pom.xml
----------------------------------------------------------------------
diff --git a/test/pom.xml b/test/pom.xml
index bd1680f..644a9c7 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -42,6 +42,11 @@ limitations under the License.
 
     <dependency>
       <groupId>org.apache.sqoop</groupId>
+      <artifactId>sqoop-shell</artifactId>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.sqoop</groupId>
       <artifactId>sqoop-core</artifactId>
     </dependency>
 
@@ -272,6 +277,21 @@ limitations under the License.
               </properties>
             </configuration>
           </execution>
+          <execution>
+            <id>shell-test</id>
+            <goals>
+              <goal>test</goal>
+            </goals>
+            <phase>integration-test</phase>
+            <configuration>
+              <suiteXmlFiles>
+                <suiteXmlFile>src/test/resources/shell-tests-suite.xml</suiteXmlFile>
+              </suiteXmlFiles>
+              <properties>
+                <suitename>shell-tests</suitename>
+              </properties>
+            </configuration>
+          </execution>
         </executions>
       </plugin>
       <plugin>

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java b/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
index becfa6b..74fe29b 100644
--- a/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/infrastructure/SqoopTestCase.java
@@ -18,9 +18,9 @@
 package org.apache.sqoop.test.infrastructure;
 
 import org.apache.commons.lang.StringUtils;
+import org.apache.hadoop.fs.FileSystem;
 import org.apache.log4j.Logger;
 import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileSystem;
 import org.apache.hadoop.fs.Path;
 import org.apache.hadoop.mapred.JobConf;
 import org.apache.hadoop.security.token.delegation.web.DelegationTokenAuthenticatedURL;
@@ -225,7 +225,14 @@ public class SqoopTestCase implements ITest {
     providerObject.start();
 
     // Add for recall later.
-    PROVIDERS.put(providerClass.getCanonicalName(), providerObject);
+    if (providerObject instanceof SqoopInfrastructureProvider) {
+      // there will be some child class of SqoopInfrastructureProvider,
+      // put all these kind of the providers with key SqoopInfrastructureProvider.class.getCanonicalName()
+      // then, getSqoopServerUrl() will get the correct value
+      PROVIDERS.put(SqoopInfrastructureProvider.class.getCanonicalName(), providerObject);
+    } else {
+      PROVIDERS.put(providerClass.getCanonicalName(), providerObject);
+    }
 
     System.out.println("Infrastructure Provider " + providerClass.getCanonicalName());
 
@@ -405,14 +412,17 @@ public class SqoopTestCase implements ITest {
    * @param jobName Job name
    * @throws Exception
    */
-  public void executeJob(String jobName) throws Exception {
+  public void executeJob(String jobName, boolean isAssertStatus) throws Exception {
     MSubmission finalSubmission = getClient().startJob(jobName, DEFAULT_SUBMISSION_CALLBACKS, 100);
 
     if(finalSubmission.getStatus().isFailure()) {
       LOG.error("Submission has failed: " + finalSubmission.getError().getErrorSummary());
       LOG.error("Corresponding error details: " + finalSubmission.getError().getErrorDetails());
     }
-    assertEquals(SubmissionStatus.SUCCEEDED, finalSubmission.getStatus(), "Submission finished with error: " + finalSubmission.getError().getErrorSummary());
+    if (isAssertStatus) {
+      assertEquals(finalSubmission.getStatus(), SubmissionStatus.SUCCEEDED,
+              "Submission finished with error: " + finalSubmission.getError().getErrorSummary());
+    }
   }
 
   /**
@@ -422,7 +432,7 @@ public class SqoopTestCase implements ITest {
    * @throws Exception
    */
   protected void executeJob(MJob job) throws Exception {
-    executeJob(job.getName());
+    executeJob(job.getName(), true);
   }
 
   /**
@@ -651,4 +661,12 @@ public class SqoopTestCase implements ITest {
     }
     return hadoopConf;
   }
+
+  protected MLink createLink(String linkName, String connectorName) {
+    MLink link = getClient().createLink(connectorName);
+    link.setName(linkName);
+    saveLink(link);
+    return link;
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProvider.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProvider.java b/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProvider.java
index 4d51ed6..5c8d733 100644
--- a/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProvider.java
+++ b/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProvider.java
@@ -30,10 +30,10 @@ import org.apache.sqoop.test.minicluster.SqoopMiniClusterFactory;
 public class SqoopInfrastructureProvider extends InfrastructureProvider {
   private static final Logger LOG = Logger.getLogger(SqoopInfrastructureProvider.class);
 
-  private SqoopMiniCluster instance;
-  private String rootPath;
-  private Configuration hadoopConf;
-  private KdcRunner kdc;
+  protected SqoopMiniCluster instance;
+  protected String rootPath;
+  protected Configuration hadoopConf;
+  protected KdcRunner kdc;
 
   public SqoopInfrastructureProvider() {}
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProviderForShellTest.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProviderForShellTest.java b/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProviderForShellTest.java
new file mode 100644
index 0000000..3562722
--- /dev/null
+++ b/test/src/main/java/org/apache/sqoop/test/infrastructure/providers/SqoopInfrastructureProviderForShellTest.java
@@ -0,0 +1,37 @@
+/**
+ * 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.test.infrastructure.providers;
+
+import org.apache.log4j.Logger;
+import org.apache.sqoop.test.minicluster.JettySqoopMiniClusterWithExternalConnector;
+import org.apache.sqoop.test.minicluster.SqoopMiniClusterFactory;
+
+public class SqoopInfrastructureProviderForShellTest extends SqoopInfrastructureProvider {
+  private static final Logger LOG = Logger.getLogger(SqoopInfrastructureProviderForShellTest.class);
+
+  @Override
+  public void start() {
+    try {
+      instance = SqoopMiniClusterFactory.getSqoopMiniCluster(System.getProperties(),
+              JettySqoopMiniClusterWithExternalConnector.class, rootPath, hadoopConf, kdc);
+      instance.start();
+    } catch (Exception e) {
+      LOG.error("Could not start Sqoop mini cluster.", e);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/minicluster/JettySqoopMiniClusterWithExternalConnector.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/minicluster/JettySqoopMiniClusterWithExternalConnector.java b/test/src/main/java/org/apache/sqoop/test/minicluster/JettySqoopMiniClusterWithExternalConnector.java
new file mode 100644
index 0000000..1a19e83
--- /dev/null
+++ b/test/src/main/java/org/apache/sqoop/test/minicluster/JettySqoopMiniClusterWithExternalConnector.java
@@ -0,0 +1,82 @@
+/**
+ * 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.test.minicluster;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.sqoop.core.ConfigurationConstants;
+import org.apache.sqoop.test.utils.ConnectorUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class JettySqoopMiniClusterWithExternalConnector extends JettySqoopMiniCluster {
+
+  private String extraClasspath;
+
+  /** {@inheritDoc} */
+  public JettySqoopMiniClusterWithExternalConnector(String temporaryPath,
+      Configuration configuration) throws Exception {
+    super(temporaryPath, configuration);
+    prepareConnector();
+  }
+
+  private void prepareConnector() throws Exception {
+    String[] connectorSourceFiles = {
+            "TestConnectorForShell/TestConnectorForShell.java",
+            "TestConnectorForShell/TestExtractorForShell.java",
+            "TestConnectorForShell/TestFromDestroyerForShell.java",
+            "TestConnectorForShell/TestFromInitializerForShell.java",
+            "TestConnectorForShell/TestFromJobConfigForShell.java",
+            "TestConnectorForShell/TestFromJobConfigurationForShell.java",
+            "TestConnectorForShell/TestLinkConfigForShell.java",
+            "TestConnectorForShell/TestLinkConfigurationForShell.java",
+            "TestConnectorForShell/TestLoaderForShell.java",
+            "TestConnectorForShell/TestPartitionerForShell.java",
+            "TestConnectorForShell/TestPartitionForShell.java",
+            "TestConnectorForShell/TestToDestroyerForShell.java",
+            "TestConnectorForShell/TestToInitializerForShell.java",
+            "TestConnectorForShell/TestToJobConfigForShell.java",
+            "TestConnectorForShell/TestToJobConfigurationForShell.java"
+    };
+    String[] connectorPropertyFiles = {
+            "TestConnectorForShell/sqoopconnector.properties",
+            "TestConnectorForShell/test-connector-for-shell.properties"
+    };
+
+    String testConnectorJarName = "test-connector-for-shell.jar";
+
+    Map<String, String> connectorJarMap = ConnectorUtils.compileTestConnectorAndDependency(
+            connectorSourceFiles,
+            new String[]{},
+            connectorPropertyFiles,
+            testConnectorJarName,
+            "", false);
+    extraClasspath = connectorJarMap.get(testConnectorJarName);
+  }
+
+  @Override
+  protected Map<String, String> getClasspathConfiguration() {
+    Map<String, String> properties = new HashMap<>();
+
+    if (extraClasspath != null) {
+      properties.put(ConfigurationConstants.CLASSPATH, extraClasspath);
+    }
+
+    return properties;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java
deleted file mode 100644
index 6db1db8..0000000
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/**
- * 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.test.testcases;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.jar.Attributes;
-import java.util.jar.JarEntry;
-import java.util.jar.JarOutputStream;
-import java.util.jar.Manifest;
-
-import javax.tools.JavaCompiler;
-import javax.tools.JavaFileObject;
-import javax.tools.StandardJavaFileManager;
-import javax.tools.StandardLocation;
-import javax.tools.ToolProvider;
-
-import org.apache.commons.collections.ListUtils;
-
-public class ConnectorClasspathTestCase extends ConnectorTestCase {
-
-  static class JarContents {
-    private List<File> sourceFiles;
-    private List<File> properitesFiles;
-    private List<String> dependencyJarFiles;
-
-    public JarContents(List<File> sourceFiles, List<File> properitesFiles, List<String> dependencyJarFiles) {
-      this.sourceFiles = sourceFiles;
-      this.properitesFiles = properitesFiles;
-      this.dependencyJarFiles = dependencyJarFiles;
-    }
-
-    public List<File> getSourceFiles() {
-      return sourceFiles;
-    }
-
-    public List<File> getProperitesFiles() {
-      return properitesFiles;
-    }
-
-    public List<String> getDependencyJarFiles() {
-      return dependencyJarFiles;
-    }
-  }
-
-  @SuppressWarnings("unchecked")
-  protected Map<String, String> compileTestConnectorAndDependency(String[] connectorSourceFiles,
-      String[] connectorDependencySourceFiles, String[] connectorPropertyFiles, String connectorJarName,
-      String connectorDependencyJarName, boolean dependencyBuiltInsideConnectorJar) throws Exception {
-    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-    if (compiler == null) {
-      throw new IllegalStateException(
-        "Cannot find the system Java compiler. "
-          + "Check that your class path includes tools.jar");
-    }
-
-    Path outputDir = Files.createTempDirectory(null);
-
-    Map<String, JarContents> sourceFileToJarMap = new LinkedHashMap<>();
-
-    ClassLoader classLoader = getClass().getClassLoader();
-    List<File> sourceFiles = new ArrayList<>();
-
-    for (String connectorDependencySourceFile : connectorDependencySourceFiles) {
-      File file = new File(classLoader.getResource(connectorDependencySourceFile).getFile());
-      sourceFiles.add(file);
-    }
-    sourceFileToJarMap.put(connectorDependencyJarName, new JarContents(sourceFiles, ListUtils.EMPTY_LIST, ListUtils.EMPTY_LIST));
-
-    sourceFiles = new ArrayList<>();
-    for (String connectorSourceFile : connectorSourceFiles) {
-      File file = new File(classLoader.getResource(connectorSourceFile).getFile());
-      sourceFiles.add(file);
-    }
-
-    List<File> propertiesFiles = new ArrayList<>();
-    for (String connectorPropertyFile : connectorPropertyFiles) {
-      File file = new File(classLoader.getResource(connectorPropertyFile).getFile());
-      propertiesFiles.add(file);
-    }
-
-    List<String> dependencyFiles = new ArrayList<>();
-    if (dependencyBuiltInsideConnectorJar) {
-      dependencyFiles.add(connectorDependencyJarName);
-    }
-    sourceFileToJarMap.put(connectorJarName, new JarContents(sourceFiles, propertiesFiles, dependencyFiles));
-
-    buildJar(outputDir.toString(), sourceFileToJarMap);
-
-    Map<String, String> jarMap = new HashMap<>();
-    jarMap.put(connectorJarName, outputDir.toString() + File.separator + connectorJarName);
-    jarMap.put(connectorDependencyJarName, outputDir.toString() + File.separator + connectorDependencyJarName);
-    return jarMap;
-  }
-
-  @edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
-  private void buildJar(String outputDir, Map<String, JarContents> sourceFileToJarMap) throws IOException {
-    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
-    StandardJavaFileManager fileManager = compiler.getStandardFileManager
-      (null, null, null);
-
-    List<File> sourceFiles = new ArrayList<>();
-    for(JarContents jarContents : sourceFileToJarMap.values()) {
-      sourceFiles.addAll(jarContents.sourceFiles);
-    }
-
-    fileManager.setLocation(StandardLocation.CLASS_OUTPUT,
-      Arrays.asList(new File(outputDir)));
-
-    Iterable<? extends JavaFileObject> compilationUnits1 =
-      fileManager.getJavaFileObjectsFromFiles(sourceFiles);
-
-    boolean compiled = compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call();
-    if (!compiled) {
-      throw new RuntimeException("failed to compile");
-    }
-
-    for(Map.Entry<String, JarContents> jarNameAndContents : sourceFileToJarMap.entrySet()) {
-      Manifest manifest = new Manifest();
-      manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
-      manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, ".");
-
-      JarOutputStream target = new JarOutputStream(new FileOutputStream(outputDir + File.separator + jarNameAndContents.getKey()), manifest);
-      List<String> classesForJar = new ArrayList<>();
-      for(File sourceFile : jarNameAndContents.getValue().getSourceFiles()) {
-        //split the file on dot to get the filename from FILENAME.java
-        String fileName = sourceFile.getName().split("\\.")[0];
-        classesForJar.add(fileName);
-      }
-
-      File dir = new File(outputDir);
-      File[] directoryListing = dir.listFiles();
-      if (directoryListing != null) {
-        for (File compiledClass : directoryListing) {
-          String classFileName = compiledClass.getName().split("\\$")[0].split("\\.")[0];
-          if (classesForJar.contains(classFileName)){
-            addFileToJar(compiledClass, target);
-          }
-        }
-      }
-
-      for (File propertiesFile : jarNameAndContents.getValue().getProperitesFiles()) {
-        addFileToJar(propertiesFile, target);
-      }
-
-      for (String dependencyJarFileName : jarNameAndContents.getValue().getDependencyJarFiles()) {
-        File dependencyJarFile = new File(dir, dependencyJarFileName);
-        addFileToJar(dependencyJarFile, target);
-      }
-
-      target.close();
-    }
-    //delete non jar files
-    File dir = new File(outputDir);
-    File[] directoryListing = dir.listFiles();
-    if (directoryListing != null) {
-      for (File file : directoryListing) {
-        String extension = file.getName().split("\\.")[1];
-        if (!extension.equals("jar")) {
-          file.delete();
-        }
-      }
-    }
-  }
-
-  @edu.umd.cs.findbugs.annotations.SuppressWarnings("OS_OPEN_STREAM_EXCEPTION_PATH")
-  private void addFileToJar(File source, JarOutputStream target) throws IOException {
-    String entryName;
-    if (source.getName().endsWith(".jar")) {
-      // put dependency jars into directory "lib"
-      entryName = "lib/" + source.getName();
-    } else {
-      entryName = source.getName();
-    }
-    JarEntry entry = new JarEntry(entryName);
-    entry.setTime(source.lastModified());
-    target.putNextEntry(entry);
-    BufferedInputStream in = null;
-    try {
-      in = new BufferedInputStream(new FileInputStream(source));
-
-      long bufferSize = source.length();
-      if (bufferSize < Integer.MIN_VALUE || bufferSize > Integer.MAX_VALUE) {
-        throw new RuntimeException("file to large to be added to jar");
-      }
-
-      byte[] buffer = new byte[(int) bufferSize];
-      while (true) {
-        int count = in.read(buffer);
-        if (count == -1)
-          break;
-        target.write(buffer, 0, count);
-      }
-    } finally {
-      target.closeEntry();
-      if (in != null) {
-        in.close();
-      }
-    }
-  }
-
-  @edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
-  protected void deleteJars(Map<String, String> jarMap) {
-    for (String jarPath : jarMap.values()) {
-      (new File(jarPath)).delete();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/testcases/ShellTestCase.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ShellTestCase.java b/test/src/main/java/org/apache/sqoop/test/testcases/ShellTestCase.java
new file mode 100644
index 0000000..bfae595
--- /dev/null
+++ b/test/src/main/java/org/apache/sqoop/test/testcases/ShellTestCase.java
@@ -0,0 +1,94 @@
+/**
+ * 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.test.testcases;
+
+import jline.console.ConsoleReader;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.test.infrastructure.SqoopTestCase;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.util.List;
+
+abstract public class ShellTestCase extends SqoopTestCase {
+
+  protected SqoopCommand command = null;
+  protected ConsoleReader reader = null;
+  protected ByteArrayInputStream in = null;
+  protected byte[] data = null;
+  private final static String TEST_CONNECTOR_NAME = "test-connector-for-shell";
+
+  @BeforeMethod
+  public void setup() throws Exception {
+    Groovysh shell = new Groovysh();
+    command = createCommand(shell);
+    ShellEnvironment.setIo(shell.getIo());
+    ShellEnvironment.setClient(getClient());
+
+    data = new byte[1024];
+    in = new ByteArrayInputStream(data);
+    reader = new ConsoleReader(in, System.out);
+    ShellEnvironment.setConsoleReader(reader);
+  }
+
+  @AfterMethod
+  public void cleanup() throws IOException {
+    clearJob();
+    clearLink();
+  }
+
+  protected Object execute(List args) {
+    return command.execute(args);
+  }
+
+  protected void initData(String destData) throws UnsupportedEncodingException {
+    byte[] destDataBytes = destData.getBytes("UTF-8");
+    System.arraycopy(destDataBytes, 0, data, 0, destDataBytes.length);
+    in.reset();
+  }
+
+  protected void initEnv() {
+    in.reset();
+    for (int i = 0; i < data.length; i++) {
+      data[i] = '\0';
+    }
+  }
+
+  protected MLink createLink(String linkName) {
+    return createLink(linkName, TEST_CONNECTOR_NAME);
+  }
+
+  protected void createJob(String fromLinkName, String toLinkName, String jobName) {
+    // create link for test
+    createLink(fromLinkName, TEST_CONNECTOR_NAME);
+    createLink(toLinkName, TEST_CONNECTOR_NAME);
+    MJob mjob = getClient().createJob(fromLinkName, toLinkName);
+    mjob.setName(jobName);
+    saveJob(mjob);
+  }
+
+  // the method should be override by sub class
+  abstract protected SqoopCommand createCommand(Groovysh shell);
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
----------------------------------------------------------------------
diff --git a/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java b/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
new file mode 100644
index 0000000..b63bcf8
--- /dev/null
+++ b/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
@@ -0,0 +1,236 @@
+/**
+ * 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.test.utils;
+
+import org.apache.commons.collections.ListUtils;
+
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.StandardJavaFileManager;
+import javax.tools.StandardLocation;
+import javax.tools.ToolProvider;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.Attributes;
+import java.util.jar.JarEntry;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+public class ConnectorUtils {
+
+  static class JarContents {
+    private List<File> sourceFiles;
+    private List<File> properitesFiles;
+    private List<String> dependencyJarFiles;
+
+    public JarContents(List<File> sourceFiles, List<File> properitesFiles, List<String> dependencyJarFiles) {
+      this.sourceFiles = sourceFiles;
+      this.properitesFiles = properitesFiles;
+      this.dependencyJarFiles = dependencyJarFiles;
+    }
+
+    public List<File> getSourceFiles() {
+      return sourceFiles;
+    }
+
+    public List<File> getProperitesFiles() {
+      return properitesFiles;
+    }
+
+    public List<String> getDependencyJarFiles() {
+      return dependencyJarFiles;
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  public static Map<String, String> compileTestConnectorAndDependency(String[] connectorSourceFiles,
+      String[] connectorDependencySourceFiles, String[] connectorPropertyFiles, String connectorJarName,
+      String connectorDependencyJarName, boolean dependencyBuiltInsideConnectorJar) throws Exception {
+    ClassLoader classLoader = ConnectorUtils.class.getClassLoader();
+    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+    if (compiler == null) {
+      throw new IllegalStateException(
+              "Cannot find the system Java compiler. "
+                      + "Check that your class path includes tools.jar");
+    }
+
+    Path outputDir = Files.createTempDirectory(null);
+
+    Map<String, JarContents> sourceFileToJarMap = new LinkedHashMap<>();
+
+    List<File> sourceFiles = new ArrayList<>();
+
+    for (String connectorDependencySourceFile : connectorDependencySourceFiles) {
+      File file = new File(classLoader.getResource(connectorDependencySourceFile).getFile());
+      sourceFiles.add(file);
+    }
+    if (connectorDependencySourceFiles.length > 0) {
+      sourceFileToJarMap.put(connectorDependencyJarName, new JarContents(sourceFiles, ListUtils.EMPTY_LIST, ListUtils.EMPTY_LIST));
+    }
+
+    sourceFiles = new ArrayList<>();
+    for (String connectorSourceFile : connectorSourceFiles) {
+      File file = new File(classLoader.getResource(connectorSourceFile).getFile());
+      sourceFiles.add(file);
+    }
+
+    List<File> propertiesFiles = new ArrayList<>();
+    for (String connectorPropertyFile : connectorPropertyFiles) {
+      File file = new File(classLoader.getResource(connectorPropertyFile).getFile());
+      propertiesFiles.add(file);
+    }
+
+    List<String> dependencyFiles = new ArrayList<>();
+    if (dependencyBuiltInsideConnectorJar) {
+      dependencyFiles.add(connectorDependencyJarName);
+    }
+    sourceFileToJarMap.put(connectorJarName, new JarContents(sourceFiles, propertiesFiles, dependencyFiles));
+
+    buildJar(outputDir.toString(), sourceFileToJarMap);
+
+    Map<String, String> jarMap = new HashMap<>();
+    jarMap.put(connectorJarName, outputDir.toString() + File.separator + connectorJarName);
+    jarMap.put(connectorDependencyJarName, outputDir.toString() + File.separator + connectorDependencyJarName);
+    return jarMap;
+  }
+
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
+  private static void buildJar(String outputDir, Map<String, JarContents> sourceFileToJarMap) throws IOException {
+    JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
+    StandardJavaFileManager fileManager = compiler.getStandardFileManager
+            (null, null, null);
+
+    List<File> sourceFiles = new ArrayList<>();
+    for(JarContents jarContents : sourceFileToJarMap.values()) {
+      sourceFiles.addAll(jarContents.sourceFiles);
+    }
+
+    fileManager.setLocation(StandardLocation.CLASS_OUTPUT,
+            Arrays.asList(new File(outputDir)));
+
+    Iterable<? extends JavaFileObject> compilationUnits1 =
+            fileManager.getJavaFileObjectsFromFiles(sourceFiles);
+
+    boolean compiled = compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call();
+    if (!compiled) {
+      throw new RuntimeException("failed to compile");
+    }
+
+    for(Map.Entry<String, JarContents> jarNameAndContents : sourceFileToJarMap.entrySet()) {
+      Manifest manifest = new Manifest();
+      manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
+      manifest.getMainAttributes().put(Attributes.Name.CLASS_PATH, ".");
+
+      JarOutputStream target = new JarOutputStream(new FileOutputStream(outputDir + File.separator + jarNameAndContents.getKey()), manifest);
+      List<String> classesForJar = new ArrayList<>();
+      for(File sourceFile : jarNameAndContents.getValue().getSourceFiles()) {
+        //split the file on dot to get the filename from FILENAME.java
+        String fileName = sourceFile.getName().split("\\.")[0];
+        classesForJar.add(fileName);
+      }
+
+      File dir = new File(outputDir);
+      File[] directoryListing = dir.listFiles();
+      if (directoryListing != null) {
+        for (File compiledClass : directoryListing) {
+          String classFileName = compiledClass.getName().split("\\$")[0].split("\\.")[0];
+          if (classesForJar.contains(classFileName)){
+            addFileToJar(compiledClass, target);
+          }
+        }
+      }
+
+      for (File propertiesFile : jarNameAndContents.getValue().getProperitesFiles()) {
+        addFileToJar(propertiesFile, target);
+      }
+
+      for (String dependencyJarFileName : jarNameAndContents.getValue().getDependencyJarFiles()) {
+        File dependencyJarFile = new File(dir, dependencyJarFileName);
+        addFileToJar(dependencyJarFile, target);
+      }
+
+      target.close();
+    }
+    //delete non jar files
+    File dir = new File(outputDir);
+    File[] directoryListing = dir.listFiles();
+    if (directoryListing != null) {
+      for (File file : directoryListing) {
+        String extension = file.getName().split("\\.")[1];
+        if (!extension.equals("jar")) {
+          file.delete();
+        }
+      }
+    }
+  }
+
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings("OS_OPEN_STREAM_EXCEPTION_PATH")
+  private static void addFileToJar(File source, JarOutputStream target) throws IOException {
+    String entryName;
+    if (source.getName().endsWith(".jar")) {
+      // put dependency jars into directory "lib"
+      entryName = "lib/" + source.getName();
+    } else {
+      entryName = source.getName();
+    }
+    JarEntry entry = new JarEntry(entryName);
+    entry.setTime(source.lastModified());
+    target.putNextEntry(entry);
+    BufferedInputStream in = null;
+    try {
+      in = new BufferedInputStream(new FileInputStream(source));
+
+      long bufferSize = source.length();
+      if (bufferSize < Integer.MIN_VALUE || bufferSize > Integer.MAX_VALUE) {
+        throw new RuntimeException("file to large to be added to jar");
+      }
+
+      byte[] buffer = new byte[(int) bufferSize];
+      while (true) {
+        int count = in.read(buffer);
+        if (count == -1)
+          break;
+        target.write(buffer, 0, count);
+      }
+    } finally {
+      target.closeEntry();
+      if (in != null) {
+        in.close();
+      }
+    }
+  }
+
+  @edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
+  public static void deleteJars(Map<String, String> jarMap) {
+    for (String jarPath : jarMap.values()) {
+      (new File(jarPath)).delete();
+    }
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/connectorloading/ClasspathTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connectorloading/ClasspathTest.java b/test/src/test/java/org/apache/sqoop/integration/connectorloading/ClasspathTest.java
index 4bb6aa1..4aed991 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connectorloading/ClasspathTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connectorloading/ClasspathTest.java
@@ -25,7 +25,8 @@ import org.apache.sqoop.model.MDriverConfig;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.test.minicluster.JettySqoopMiniCluster;
-import org.apache.sqoop.test.testcases.ConnectorClasspathTestCase;
+import org.apache.sqoop.test.testcases.ConnectorTestCase;
+import org.apache.sqoop.test.utils.ConnectorUtils;
 import org.apache.sqoop.test.utils.HdfsUtils;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
@@ -37,7 +38,7 @@ import java.util.List;
 import java.util.Map;
 
 @Test(groups = "no-real-cluster")
-public class ClasspathTest extends ConnectorClasspathTestCase {
+public class ClasspathTest extends ConnectorTestCase {
 
   private static final String TEST_CONNECTOR_JAR_NAME = "test-connector.jar";
   private static final String TEST_DEPENDENCY_JAR_NAME = "test-dependency.jar";
@@ -111,13 +112,13 @@ public class ClasspathTest extends ConnectorClasspathTestCase {
 
   @Test
   public void testClasspathSqoopProperties() throws Exception {
-    Map<String, String> jarMap = compileTestConnectorAndDependency(
-        CONNECTOR_SOURCE_FILES,
-        CONNECTOR_DEPENDENCY_SOURCE_FILES,
-        CONNECTOR_PROPERTY_FILES,
-        TEST_CONNECTOR_JAR_NAME,
-        TEST_DEPENDENCY_JAR_NAME,
-        false);
+    Map<String, String> jarMap = ConnectorUtils.compileTestConnectorAndDependency(
+            CONNECTOR_SOURCE_FILES,
+            CONNECTOR_DEPENDENCY_SOURCE_FILES,
+            CONNECTOR_PROPERTY_FILES,
+            TEST_CONNECTOR_JAR_NAME,
+            TEST_DEPENDENCY_JAR_NAME,
+            false);
     startSqoopMiniCluster(jarMap.get(TEST_CONNECTOR_JAR_NAME), jarMap.get
       (TEST_DEPENDENCY_JAR_NAME));
     createAndLoadTableCities();
@@ -131,12 +132,12 @@ public class ClasspathTest extends ConnectorClasspathTestCase {
     executeJob(job);
 
     stopSqoop();
-    deleteJars(jarMap);
+    ConnectorUtils.deleteJars(jarMap);
   }
 
   @Test
   public void testClasspathDriverInput() throws Exception{
-    Map<String, String> jarMap = compileTestConnectorAndDependency(
+    Map<String, String> jarMap = ConnectorUtils.compileTestConnectorAndDependency(
         CONNECTOR_SOURCE_FILES,
         CONNECTOR_DEPENDENCY_SOURCE_FILES,
         CONNECTOR_PROPERTY_FILES,
@@ -159,7 +160,7 @@ public class ClasspathTest extends ConnectorClasspathTestCase {
     executeJob(job);
 
     stopSqoop();
-    deleteJars(jarMap);
+    ConnectorUtils.deleteJars(jarMap);
   }
 
   private MJob prepareJob() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/connectorloading/ConnectorClasspathIsolationTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/connectorloading/ConnectorClasspathIsolationTest.java b/test/src/test/java/org/apache/sqoop/integration/connectorloading/ConnectorClasspathIsolationTest.java
index 5b95631..295e049 100644
--- a/test/src/test/java/org/apache/sqoop/integration/connectorloading/ConnectorClasspathIsolationTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/connectorloading/ConnectorClasspathIsolationTest.java
@@ -30,14 +30,15 @@ import org.apache.sqoop.model.MDriverConfig;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
 import org.apache.sqoop.test.minicluster.JettySqoopMiniCluster;
-import org.apache.sqoop.test.testcases.ConnectorClasspathTestCase;
+import org.apache.sqoop.test.testcases.ConnectorTestCase;
+import org.apache.sqoop.test.utils.ConnectorUtils;
 import org.apache.sqoop.test.utils.HdfsUtils;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 @Test(groups = "no-real-cluster")
-public class ConnectorClasspathIsolationTest extends ConnectorClasspathTestCase {
+public class ConnectorClasspathIsolationTest extends ConnectorTestCase {
 
   private static final String TEST_FROM_CONNECTOR_JAR_NAME = "test-from-connector.jar";
   private static final String TEST_TO_CONNECTOR_JAR_NAME = "test-to-connector.jar";
@@ -126,14 +127,14 @@ public class ConnectorClasspathIsolationTest extends ConnectorClasspathTestCase
 
   @Test
   public void testConnectorClasspathIsolation() throws Exception {
-    Map<String, String> fromConnectorJarMap = compileTestConnectorAndDependency(
+    Map<String, String> fromConnectorJarMap = ConnectorUtils.compileTestConnectorAndDependency(
         FROM_CONNECTOR_SOURCE_FILES,
         FROM_CONNECTOR_DEPENDENCY_SOURCE_FILES,
         FROM_CONNECTOR_PROPERTY_FILES,
         TEST_FROM_CONNECTOR_JAR_NAME,
         TEST_FROM_DEPENDENCY_JAR_NAME,
         true);
-    Map<String, String> toConnectorJarMap = compileTestConnectorAndDependency(
+    Map<String, String> toConnectorJarMap = ConnectorUtils.compileTestConnectorAndDependency(
         TO_CONNECTOR_SOURCE_FILES,
         TO_CONNECTOR_DEPENDENCY_SOURCE_FILES,
         TO_CONNECTOR_PROPERTY_FILES,
@@ -152,7 +153,7 @@ public class ConnectorClasspathIsolationTest extends ConnectorClasspathTestCase
     executeJob(job);
 
     stopSqoop();
-    deleteJars(fromConnectorJarMap);
+    ConnectorUtils.deleteJars(fromConnectorJarMap);
   }
 
   private MJob prepareJob() {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
index 9adebea..83baa22 100644
--- a/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
+++ b/test/src/test/java/org/apache/sqoop/integration/server/SubmissionWithDisabledModelObjectsTest.java
@@ -110,7 +110,7 @@ public class SubmissionWithDisabledModelObjectsTest extends SqoopTestCase {
 
     // Try to execute the job and verify that the it was not executed
     try {
-      executeJob(jobName);
+      executeJob(jobName, true);
       fail("Expected exception as the model classes are disabled.");
     } catch(SqoopException ex) {
       // Top level exception should be CLIENT_0001

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/CloneCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/CloneCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/CloneCommandTest.java
new file mode 100644
index 0000000..bcf6334
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/CloneCommandTest.java
@@ -0,0 +1,125 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.shell.CloneCommand;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.io.UnsupportedEncodingException;
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class CloneCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new CloneCommand(shell);
+  }
+
+  @Test
+  public void testCloneLink() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    // create link
+    createLink("linkName");
+
+    // do the clone test
+    initData("Clone\n" +                 // link name: append to the old link name
+            "linkConfig1\n" +            // link config1
+            "linkConfig2\n");            // link config2
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    assertTrue(status != null && status != Status.ERROR);
+    // the origin link is still there
+    MLink orginLink = getClient().getLink("linkName");
+    assertEquals(orginLink.getName(), "linkName");
+
+    MLink link = getClient().getLink("linkNameClone");
+    assertEquals(link.getName(), "linkNameClone");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig1").getValue(),
+            "linkConfig1");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig2").getValue(),
+            "linkConfig2");
+  }
+
+  @Test
+  public void testCloneNonExistingLink() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-name", "non-exist-link"));
+      fail("Clone Link should fail as link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testCloneJob() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    createJob("fromLink", "toLink", "jobName");
+
+    // create job -f link_from -to link_to
+    initData("Clone\n" +                              // job name
+            "fromJobConfig1\n" +                      // from job config1
+            "fromJobConfig2\n" +                      // from job config2
+            "toJobConfig1\n" +                        // to job config1
+            "toJobConfig2\n\n\n\n\n\n");              // to job config2 and nothing for driver
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    assertTrue(status != null && status != Status.ERROR);
+    // the origin job is still there
+    MJob originJob = getClient().getJob("jobName");
+    assertEquals(originJob.getName(), "jobName");
+
+    MJob job = getClient().getJob("jobNameClone");
+    assertEquals(job.getName(), "jobNameClone");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig1").getValue(), "fromJobConfig1");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig2").getValue(), "fromJobConfig2");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig1").getValue(), "toJobConfig1");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig2").getValue(), "toJobConfig2");
+  }
+
+  @Test
+  public void testCloneNonExistingJob() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-jobName"));
+      fail("Clone Job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/CreateCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/CreateCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/CreateCommandTest.java
new file mode 100644
index 0000000..81b7c8a
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/CreateCommandTest.java
@@ -0,0 +1,117 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.*;
+import org.apache.sqoop.shell.CreateCommand;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.io.UnsupportedEncodingException;
+import java.util.*;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class CreateCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new CreateCommand(shell);
+  }
+
+  @Test
+  public void testCreateLink() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    // create link -c generic-jdbc-connector
+    initData("linkname\n" +              // link name
+            "linkConfig1\n" +            // link config1
+            "linkConfig2\n");            // link config2
+
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-c", "test-connector-for-shell"));
+    MLink link = getClient().getLink("linkname");
+    // the status should be warning because of the validation of jdbc connection string
+    assertTrue(status != null && status != Status.ERROR);
+    assertEquals(link.getName(), "linkname");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig1").getValue(),
+            "linkConfig1");
+    assertEquals(link.getConnectorLinkConfig("testLinkConfigForShell").getInput("testLinkConfigForShell.linkConfig2").getValue(),
+            "linkConfig2");
+  }
+
+  @Test
+  public void testCreateLinkWithNonExistingConnector() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-c", "non-exist-connector"));
+      fail("Create Link should fail as connector doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0003);
+    }
+  }
+
+  @Test
+  public void testCreateJob() throws UnsupportedEncodingException {
+    ShellEnvironment.setInteractive(true);
+    initEnv();
+
+    // create link for test
+    createLink("fromLink");
+    createLink("toLink");
+
+    // create job -f link_from -to link_to
+    initData("jobname\n" +                            // job name
+            "fromJobConfig1\n" +                      // from job config1
+            "fromJobConfig2\n" +                      // from job config2
+            "toJobConfig1\n" +                        // to job config1
+            "toJobConfig2\n\n\n\n\n\n");              // to job config2 and nothing for driver
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-f", "fromLink", "-to", "toLink"));
+
+    assertTrue(status != null && status != Status.ERROR);
+    MJob job = getClient().getJob("jobname");
+    assertEquals(job.getName(), "jobname");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig1").getValue(), "fromJobConfig1");
+    assertEquals(job.getFromJobConfig().getInput("testFromJobConfigForShell.fromJobConfig2").getValue(), "fromJobConfig2");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig1").getValue(), "toJobConfig1");
+    assertEquals(job.getToJobConfig().getInput("testToJobConfigForShell.toJobConfig2").getValue(), "toJobConfig2");
+  }
+
+  @Test
+  public void testCreateJobWithNonExistingLink() {
+    ShellEnvironment.setInteractive(false);
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-f", "link_from", "-to", "link_to"));
+      fail("Create Job should fail as from link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/DeleteCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/DeleteCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/DeleteCommandTest.java
new file mode 100644
index 0000000..8ed8570
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/DeleteCommandTest.java
@@ -0,0 +1,97 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.shell.DeleteCommand;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.fail;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class DeleteCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new DeleteCommand(shell);
+  }
+
+  @Test
+  public void testDeleteLink() {
+    // creaet link
+    createLink("linkName");
+
+    // delete link -name linkName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    Assert.assertTrue(status != null && status == Status.OK);
+
+    // verify the link is deleted
+    try {
+      getClient().getLink("linkName");
+      fail("Link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+
+    // delete the non-exist link
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-name", "non-exist-link"));
+      fail("Delete link should fail as link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testDeleteJob() {
+    // creaet job
+    createJob("fromLink", "toLink", "jobName");
+
+    // delete job -name jobName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    Assert.assertTrue(status != null && status == Status.OK);
+
+    // verify the job is deleted
+    try {
+      getClient().getJob("jobName");
+      fail("Job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+
+    // delete the non-exist job
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Delete job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/DisableCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/DisableCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/DisableCommandTest.java
new file mode 100644
index 0000000..e524312
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/DisableCommandTest.java
@@ -0,0 +1,97 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.shell.DisableCommand;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+import static org.testng.Assert.*;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class DisableCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new DisableCommand(shell);
+  }
+
+  @Test
+  public void testDisableLink() {
+    // creaet link
+    createLink("linkName");
+
+    // the link is enable
+    MLink link = getClient().getLink("linkName");
+    assertTrue(link.getEnabled());
+
+    // disable link -name linkName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    assertTrue(status != null && status == Status.OK);
+
+    // the link is disable
+    link = getClient().getLink("linkName");
+    assertFalse(link.getEnabled());
+
+    // disable the non-exist link
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-name", "non-exist-link"));
+      fail("Disable link should fail as link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testDisableJob() {
+    // creaet job
+    createJob("fromLink", "toLink", "jobName");
+
+    // the job is enable
+    MJob job = getClient().getJob("jobName");
+    assertTrue(job.getEnabled());
+
+    // disable job -name jobName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    assertTrue(status != null && status == Status.OK);
+
+    // the job is disable
+    job = getClient().getJob("jobName");
+    assertFalse(job.getEnabled());
+
+    // disable the non-exist job
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Disable job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/EnableCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/EnableCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/EnableCommandTest.java
new file mode 100644
index 0000000..b104348
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/EnableCommandTest.java
@@ -0,0 +1,99 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.client.ClientError;
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.model.MJob;
+import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.shell.EnableCommand;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+import static org.testng.Assert.*;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class EnableCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new EnableCommand(shell);
+  }
+
+  @Test
+  public void testEnableLink() {
+    // creaet link
+    createLink("linkName");
+    getClient().enableLink("linkName", false);
+
+    // the link is disable
+    MLink link = getClient().getLink("linkName");
+    assertFalse(link.getEnabled());
+
+    // enable link -name linkName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
+    assertTrue(status != null && status == Status.OK);
+
+    // the link is enable
+    link = getClient().getLink("linkName");
+    assertTrue(link.getEnabled());
+
+    // enable the non-exist link
+    try {
+      execute(Arrays.asList(Constants.FN_LINK, "-name", "non-exist-link"));
+      fail("Enable link should fail as link doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+
+  @Test
+  public void testEnableJob() {
+    // creaet job
+    createJob("fromLink", "toLink", "jobName");
+    getClient().enableJob("jobName", false);
+
+    // the job is disable
+    MJob job = getClient().getJob("jobName");
+    assertFalse(job.getEnabled());
+
+    // enable job -name jobName
+    Status status = (Status) execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
+    assertTrue(status != null && status == Status.OK);
+
+    // the job is disable
+    job = getClient().getJob("jobName");
+    assertTrue(job.getEnabled());
+
+    // enable the non-exist job
+    try {
+      execute(Arrays.asList(Constants.FN_JOB, "-name", "non-exist-job"));
+      fail("Enable job should fail as job doesn't exist!");
+    } catch (SqoopException e) {
+      assertEquals(e.getErrorCode(), ClientError.CLIENT_0001);
+    }
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/67214a48/test/src/test/java/org/apache/sqoop/integration/shell/SetCommandTest.java
----------------------------------------------------------------------
diff --git a/test/src/test/java/org/apache/sqoop/integration/shell/SetCommandTest.java b/test/src/test/java/org/apache/sqoop/integration/shell/SetCommandTest.java
new file mode 100644
index 0000000..f673a58
--- /dev/null
+++ b/test/src/test/java/org/apache/sqoop/integration/shell/SetCommandTest.java
@@ -0,0 +1,152 @@
+/**
+ * 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.integration.shell;
+
+import org.apache.sqoop.common.SqoopException;
+import org.apache.sqoop.shell.SetCommand;
+import org.apache.sqoop.shell.ShellEnvironment;
+import org.apache.sqoop.shell.SqoopCommand;
+import org.apache.sqoop.shell.core.Constants;
+import org.apache.sqoop.shell.core.ShellError;
+import org.apache.sqoop.test.infrastructure.Infrastructure;
+import org.apache.sqoop.test.infrastructure.providers.DatabaseInfrastructureProvider;
+import org.apache.sqoop.test.infrastructure.providers.SqoopInfrastructureProviderForShellTest;
+import org.apache.sqoop.test.testcases.ShellTestCase;
+import org.apache.sqoop.validation.Status;
+import org.codehaus.groovy.tools.shell.Groovysh;
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+import java.util.Arrays;
+
+@Infrastructure(dependencies = {SqoopInfrastructureProviderForShellTest.class, DatabaseInfrastructureProvider.class})
+public class SetCommandTest extends ShellTestCase {
+
+  protected SqoopCommand createCommand(Groovysh shell) {
+    return new SetCommand(shell);
+  }
+
+  @Test
+  public void testSetServer() {
+    ShellEnvironment.cleanup();
+    // set server -url http://host-test:7070/sqoop-test
+    Status status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://host-test:7070/sqoop-test/");
+
+    // use the default webapp path if not specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertTrue(getClient().getServerUrl().equals("http://host-test:7070/sqoop/"));
+
+    // use the default webapp and port if not specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test/"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertTrue(getClient().getServerUrl().equals("http://host-test:12000/sqoop/"));
+
+    // option host is ignored when option url is specified
+    status = (Status) 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(getClient().getServerUrl(), "http://host-test:7070/sqoop-test/");
+
+    // option port is ignored when option url is specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-port", "12000"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://host-test:7070/sqoop-test/");
+
+    // option webapp is ignored when option url is specified
+    status = (Status) 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(getClient().getServerUrl(), "http://host-test:7070/sqoop-test/");
+
+    // Missing argument for option url
+    try {
+      execute(Arrays.asList(Constants.FN_SERVER, "-url"));
+      Assert.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"));
+    }
+  }
+
+  @Test
+  public void testSetServerWithoutOptionURL() {
+    ShellEnvironment.cleanup();
+    // use option host, port, webapp when option url is not specified
+    Status status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070", "-webapp", "sqoop2-test"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://host2-test:7070/sqoop2-test/");
+
+    ShellEnvironment.cleanup();
+    // use default host if option host is not specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-port", "7070", "-webapp", "sqoop2-test"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://localhost:7070/sqoop2-test/");
+
+    ShellEnvironment.cleanup();
+    // use default port if option port is not specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-webapp", "sqoop2-test"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://host2-test:12000/sqoop2-test/");
+
+    ShellEnvironment.cleanup();
+    // use default webapp if option webapp is not specified
+    status = (Status) execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(getClient().getServerUrl(), "http://host2-test:7070/sqoop/");
+  }
+
+  @Test
+  public void testSetOption() {
+    // set option -name verbose -value true
+    Status status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "true"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertTrue(ShellEnvironment.isVerbose());
+
+    // set option -name verbose -value 1
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "1"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertTrue(ShellEnvironment.isVerbose());
+
+    // set option -name verbose -value 0
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "0"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertFalse(ShellEnvironment.isVerbose());
+
+    // set option -name poll-timeout -value 12345
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "12345"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+
+    // when value of poll-timeout is not number, poll-timeout should stay the old value
+    status = (Status) execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "abc"));
+    Assert.assertTrue(status != null && status == Status.OK);
+    Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
+
+    // skip non exist options, options already set should stay the old value
+    status = (Status) 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);
+  }
+
+  @Override
+  public void cleanup() {
+    // this test don't need to cleanup the repository
+  }
+}