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 0a04e3de..3feaac30 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 @@
public class SetCommand extends SqoopCommand {
- protected SetCommand(Groovysh shell) {
+ public SetCommand(Groovysh shell) {
super(shell,
Constants.CMD_SET,
Constants.CMD_SET_SC,
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 c148eeba..eb8522aa 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 @@
public class ShowCommand extends SqoopCommand {
- protected ShowCommand(Groovysh shell) {
+ public ShowCommand(Groovysh shell) {
super(shell,
Constants.CMD_SHOW,
Constants.CMD_SHOW_SC,
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 679c1f7a..28abc3d8 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 @@
public class StartCommand extends SqoopCommand {
- protected StartCommand(Groovysh shell) {
+ public StartCommand(Groovysh shell) {
super(shell,
Constants.CMD_START,
Constants.CMD_START_SC,
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 6082799a..618b79d8 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 @@
public class StatusCommand extends SqoopCommand {
- protected StatusCommand(Groovysh shell) {
+ public StatusCommand(Groovysh shell) {
super(shell,
Constants.CMD_STATUS,
Constants.CMD_STATUS_SC,
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 83c571a4..0afba26d 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 @@
public class StopCommand extends SqoopCommand {
- protected StopCommand(Groovysh shell) {
+ public StopCommand(Groovysh shell) {
super(shell,
Constants.CMD_STOP,
Constants.CMD_STOP_SC,
diff --git a/test/pom.xml b/test/pom.xml
index bd1680f7..644a9c7d 100644
--- a/test/pom.xml
+++ b/test/pom.xml
@@ -40,6 +40,11 @@ limitations under the License.
sqoop-common-test
+
+ org.apache.sqoop
+ sqoop-shell
+
+
org.apache.sqoop
sqoop-core
@@ -272,6 +277,21 @@ limitations under the License.
+
+ shell-test
+
+ test
+
+ integration-test
+
+
+ src/test/resources/shell-tests-suite.xml
+
+
+ shell-tests
+
+
+
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 becfa6be..74fe29b7 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 @@ protected static T startInfrastructureProvide
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 void saveJob(MJob job) {
* @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 void executeJob(String jobName) throws Exception {
* @throws Exception
*/
protected void executeJob(MJob job) throws Exception {
- executeJob(job.getName());
+ executeJob(job.getName(), true);
}
/**
@@ -651,4 +661,12 @@ protected Configuration getHadoopConf() {
}
return hadoopConf;
}
+
+ protected MLink createLink(String linkName, String connectorName) {
+ MLink link = getClient().createLink(connectorName);
+ link.setName(linkName);
+ saveLink(link);
+ return link;
+ }
+
}
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 4d51ed63..5c8d7332 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 @@
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() {}
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 00000000..35627228
--- /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);
+ }
+ }
+}
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 00000000..1a19e83f
--- /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 connectorJarMap = ConnectorUtils.compileTestConnectorAndDependency(
+ connectorSourceFiles,
+ new String[]{},
+ connectorPropertyFiles,
+ testConnectorJarName,
+ "", false);
+ extraClasspath = connectorJarMap.get(testConnectorJarName);
+ }
+
+ @Override
+ protected Map getClasspathConfiguration() {
+ Map properties = new HashMap<>();
+
+ if (extraClasspath != null) {
+ properties.put(ConfigurationConstants.CLASSPATH, extraClasspath);
+ }
+
+ return properties;
+ }
+}
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 00000000..bfae5955
--- /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);
+}
diff --git a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java b/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
similarity index 88%
rename from test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java
rename to test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
index 6db1db81..b63bcf84 100644
--- a/test/src/main/java/org/apache/sqoop/test/testcases/ConnectorClasspathTestCase.java
+++ b/test/src/main/java/org/apache/sqoop/test/utils/ConnectorUtils.java
@@ -15,9 +15,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.sqoop.test.utils;
-package org.apache.sqoop.test.testcases;
+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;
@@ -36,15 +42,7 @@
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 {
+public class ConnectorUtils {
static class JarContents {
private List sourceFiles;
@@ -71,28 +69,30 @@ public List getDependencyJarFiles() {
}
@SuppressWarnings("unchecked")
- protected Map compileTestConnectorAndDependency(String[] connectorSourceFiles,
+ public static Map 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");
+ "Cannot find the system Java compiler. "
+ + "Check that your class path includes tools.jar");
}
Path outputDir = Files.createTempDirectory(null);
Map sourceFileToJarMap = new LinkedHashMap<>();
- ClassLoader classLoader = getClass().getClassLoader();
List 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));
+ if (connectorDependencySourceFiles.length > 0) {
+ sourceFileToJarMap.put(connectorDependencyJarName, new JarContents(sourceFiles, ListUtils.EMPTY_LIST, ListUtils.EMPTY_LIST));
+ }
sourceFiles = new ArrayList<>();
for (String connectorSourceFile : connectorSourceFiles) {
@@ -121,10 +121,10 @@ protected Map compileTestConnectorAndDependency(String[] connect
}
@edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
- private void buildJar(String outputDir, Map sourceFileToJarMap) throws IOException {
+ private static void buildJar(String outputDir, Map sourceFileToJarMap) throws IOException {
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
StandardJavaFileManager fileManager = compiler.getStandardFileManager
- (null, null, null);
+ (null, null, null);
List sourceFiles = new ArrayList<>();
for(JarContents jarContents : sourceFileToJarMap.values()) {
@@ -132,10 +132,10 @@ private void buildJar(String outputDir, Map sourceFileToJar
}
fileManager.setLocation(StandardLocation.CLASS_OUTPUT,
- Arrays.asList(new File(outputDir)));
+ Arrays.asList(new File(outputDir)));
Iterable extends JavaFileObject> compilationUnits1 =
- fileManager.getJavaFileObjectsFromFiles(sourceFiles);
+ fileManager.getJavaFileObjectsFromFiles(sourceFiles);
boolean compiled = compiler.getTask(null, fileManager, null, null, null, compilationUnits1).call();
if (!compiled) {
@@ -191,7 +191,7 @@ private void buildJar(String outputDir, Map sourceFileToJar
}
@edu.umd.cs.findbugs.annotations.SuppressWarnings("OS_OPEN_STREAM_EXCEPTION_PATH")
- private void addFileToJar(File source, JarOutputStream target) throws IOException {
+ private static void addFileToJar(File source, JarOutputStream target) throws IOException {
String entryName;
if (source.getName().endsWith(".jar")) {
// put dependency jars into directory "lib"
@@ -227,9 +227,10 @@ private void addFileToJar(File source, JarOutputStream target) throws IOExceptio
}
@edu.umd.cs.findbugs.annotations.SuppressWarnings("RV_RETURN_VALUE_IGNORED_BAD_PRACTICE")
- protected void deleteJars(Map jarMap) {
+ public static void deleteJars(Map jarMap) {
for (String jarPath : jarMap.values()) {
(new File(jarPath)).delete();
}
}
+
}
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 4bb6aa1c..4aed9912 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.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.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 void restoreClasspath(){
@Test
public void testClasspathSqoopProperties() throws Exception {
- Map jarMap = compileTestConnectorAndDependency(
- CONNECTOR_SOURCE_FILES,
- CONNECTOR_DEPENDENCY_SOURCE_FILES,
- CONNECTOR_PROPERTY_FILES,
- TEST_CONNECTOR_JAR_NAME,
- TEST_DEPENDENCY_JAR_NAME,
- false);
+ Map 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 void testClasspathSqoopProperties() throws Exception {
executeJob(job);
stopSqoop();
- deleteJars(jarMap);
+ ConnectorUtils.deleteJars(jarMap);
}
@Test
public void testClasspathDriverInput() throws Exception{
- Map jarMap = compileTestConnectorAndDependency(
+ Map jarMap = ConnectorUtils.compileTestConnectorAndDependency(
CONNECTOR_SOURCE_FILES,
CONNECTOR_DEPENDENCY_SOURCE_FILES,
CONNECTOR_PROPERTY_FILES,
@@ -159,7 +160,7 @@ public void testClasspathDriverInput() throws Exception{
executeJob(job);
stopSqoop();
- deleteJars(jarMap);
+ ConnectorUtils.deleteJars(jarMap);
}
private MJob prepareJob() {
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 5b956314..295e0496 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.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 void restoreClasspath(){
@Test
public void testConnectorClasspathIsolation() throws Exception {
- Map fromConnectorJarMap = compileTestConnectorAndDependency(
+ Map 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 toConnectorJarMap = compileTestConnectorAndDependency(
+ Map toConnectorJarMap = ConnectorUtils.compileTestConnectorAndDependency(
TO_CONNECTOR_SOURCE_FILES,
TO_CONNECTOR_DEPENDENCY_SOURCE_FILES,
TO_CONNECTOR_PROPERTY_FILES,
@@ -152,7 +153,7 @@ public void testConnectorClasspathIsolation() throws Exception {
executeJob(job);
stopSqoop();
- deleteJars(fromConnectorJarMap);
+ ConnectorUtils.deleteJars(fromConnectorJarMap);
}
private MJob prepareJob() {
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 9adebea1..83baa228 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 void testWithDisabledObjects() throws Exception {
// 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
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 00000000..bcf6334a
--- /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);
+ }
+ }
+}
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 00000000..81b7c8a1
--- /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);
+ }
+ }
+}
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 00000000..8ed8570d
--- /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);
+ }
+ }
+}
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 00000000..e5243128
--- /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);
+ }
+ }
+}
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 00000000..b104348b
--- /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);
+ }
+ }
+}
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 00000000..f673a58b
--- /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
+ }
+}
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 00000000..9fd4811c
--- /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));
+ }
+}
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 00000000..55045869
--- /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 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 submissions = getClient().getSubmissionsForJob("jobForTestStartJob2");
+ assertEquals(submissions.size(), 1);
+ assertTrue(submissions.get(0).getStatus() == SubmissionStatus.FAILED);
+ }
+}
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 00000000..7294b05c
--- /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));
+ }
+}
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 00000000..69110b24
--- /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);
+ }
+ }
+}
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 00000000..f9a35fed
--- /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);
+ }
+ }
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java b/test/src/test/resources/TestConnectorForShell/TestConnectorForShell.java
new file mode 100644
index 00000000..4191d979
--- /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
diff --git a/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java b/test/src/test/resources/TestConnectorForShell/TestExtractorForShell.java
new file mode 100644
index 00000000..cfb832fa
--- /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 {
+
+ @Override
+ public void extract(ExtractorContext context,
+ TestLinkConfigurationForShell linkConfiguration,
+ TestFromJobConfigurationForShell jobConfiguration,
+ TestPartitionForShell partition) {
+ }
+
+ @Override
+ public long getRowsRead() {
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromDestroyerForShell.java
new file mode 100644
index 00000000..4520c39e
--- /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 {
+ @Override
+ public void destroy(DestroyerContext context, TestLinkConfigurationForShell linkConfig,
+ TestFromJobConfigurationForShell jobConfig) {
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromInitializerForShell.java
new file mode 100644
index 00000000..82f0d474
--- /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 {
+ @Override
+ public void initialize(InitializerContext context, TestLinkConfigurationForShell linkConfig,
+ TestFromJobConfigurationForShell jobConfig) {
+ }
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigForShell.java
new file mode 100644
index 00000000..aa8d5c0c
--- /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;
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestFromJobConfigurationForShell.java
new file mode 100644
index 00000000..9fc9bbd5
--- /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();
+ }
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestLinkConfigForShell.java
new file mode 100644
index 00000000..ebb4f94a
--- /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;
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestLinkConfigurationForShell.java
new file mode 100644
index 00000000..d512d77f
--- /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
diff --git a/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java b/test/src/test/resources/TestConnectorForShell/TestLoaderForShell.java
new file mode 100644
index 00000000..8f440f26
--- /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 {
+
+ @Override
+ public void load(LoaderContext context, TestLinkConfigurationForShell linkConfiguration,
+ TestToJobConfigurationForShell toJobConfig) throws Exception {
+ }
+
+ @Override
+ public long getRowsWritten() {
+ return 0;
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java b/test/src/test/resources/TestConnectorForShell/TestPartitionForShell.java
new file mode 100644
index 00000000..5f5b9a52
--- /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 "";}
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java b/test/src/test/resources/TestConnectorForShell/TestPartitionerForShell.java
new file mode 100644
index 00000000..fa21a522
--- /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 {
+ public TestPartitionerForShell() {
+ }
+
+ @Override
+ public List getPartitions(PartitionerContext context,
+ TestLinkConfigurationForShell linkConfiguration, TestFromJobConfigurationForShell fromJobConfiguration) {
+ List partitionList = new ArrayList();
+ partitionList.add(new TestPartitionForShell());
+ return partitionList;
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java b/test/src/test/resources/TestConnectorForShell/TestToDestroyerForShell.java
new file mode 100644
index 00000000..e172204a
--- /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 {
+ @Override
+ public void destroy(DestroyerContext context, TestLinkConfigurationForShell linkConfig,
+ TestToJobConfigurationForShell jobConfig) {
+ }
+}
\ No newline at end of file
diff --git a/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java b/test/src/test/resources/TestConnectorForShell/TestToInitializerForShell.java
new file mode 100644
index 00000000..950ef7e2
--- /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 {
+ @Override
+ public void initialize(InitializerContext context, TestLinkConfigurationForShell linkConfig,
+ TestToJobConfigurationForShell jobConfig) {
+ }
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java b/test/src/test/resources/TestConnectorForShell/TestToJobConfigForShell.java
new file mode 100644
index 00000000..08fa7159
--- /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;
+
+}
diff --git a/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java b/test/src/test/resources/TestConnectorForShell/TestToJobConfigurationForShell.java
new file mode 100644
index 00000000..22664de1
--- /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
diff --git a/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties b/test/src/test/resources/TestConnectorForShell/sqoopconnector.properties
new file mode 100644
index 00000000..24dfcadc
--- /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
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 00000000..c0a4d2fd
--- /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
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 00000000..e2c0b099
--- /dev/null
+++ b/test/src/test/resources/shell-tests-suite.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file