mirror of
https://github.com/apache/sqoop.git
synced 2025-05-04 02:39:53 +08:00
SQOOP-2763: Sqoop2: Sqoop shell is accepting non existing arguments
(Dian Fu via Jarek Jarcec Cecho)
This commit is contained in:
parent
073da06dd4
commit
c40c23c9e6
@ -54,6 +54,11 @@ limitations under the License.
|
||||
<artifactId>commons-lang</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
|
@ -0,0 +1,41 @@
|
||||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.apache.sqoop.cli;
|
||||
|
||||
import java.util.ListIterator;
|
||||
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
|
||||
public class SqoopGnuParser extends GnuParser {
|
||||
public SqoopGnuParser() {
|
||||
super();
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
protected void processOption(final String arg, final ListIterator iter) throws ParseException {
|
||||
boolean hasOption = getOptions().hasOption(arg);
|
||||
|
||||
if (hasOption) {
|
||||
super.processOption(arg, iter);
|
||||
} else {
|
||||
throw new ParseException("Unknown option encountered: " + arg);
|
||||
}
|
||||
}
|
||||
}
|
@ -45,16 +45,6 @@ limitations under the License.
|
||||
<groupId>org.apache.sqoop</groupId>
|
||||
<artifactId>sqoop-client</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-cli</groupId>
|
||||
<artifactId>commons-cli</artifactId>
|
||||
<version>${commons-cli.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-lang</groupId>
|
||||
<artifactId>commons-lang</artifactId>
|
||||
<version>${commons-lang.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>jline</groupId>
|
||||
<artifactId>jline</artifactId>
|
||||
|
@ -44,7 +44,7 @@ public boolean validateArgs(CommandLine line) {
|
||||
}
|
||||
|
||||
public Object execute(List<String> args) {
|
||||
CommandLine line = ConfigOptions.parseOptions(this, 1, args, true);
|
||||
CommandLine line = ConfigOptions.parseOptions(this, 1, args, false);
|
||||
|
||||
try {
|
||||
if (validateArgs(line)) {
|
||||
|
@ -22,11 +22,11 @@
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.Option;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.sqoop.cli.SqoopGnuParser;
|
||||
import org.apache.sqoop.common.SqoopException;
|
||||
import org.apache.sqoop.model.MConfig;
|
||||
import org.apache.sqoop.model.MInput;
|
||||
@ -105,7 +105,7 @@ public static List<Option> getConfigOptions(String prefix, MConfig config) {
|
||||
public static CommandLine parseOptions(Options options, int start, List<String> arglist, boolean stopAtNonOption) {
|
||||
String[] args = arglist.subList(start, arglist.size()).toArray(new String[arglist.size() - start]);
|
||||
|
||||
CommandLineParser parser = new GnuParser();
|
||||
CommandLineParser parser = new SqoopGnuParser();
|
||||
CommandLine line;
|
||||
try {
|
||||
line = parser.parse(options, args, stopAtNonOption);
|
||||
|
@ -274,6 +274,16 @@ public void testCloneJobInteractive() {
|
||||
assertEquals(job.getDriverConfig().getDateTimeInput("driverConfig.DateTime").getValue().getMillis(), 7654321);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
cloneCmd.execute(Arrays.asList(Constants.FN_JOB, "-unknownOption"));
|
||||
fail("Clone command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<MConfig> getConfig(String configName) {
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
|
@ -301,6 +301,16 @@ public void testCreateRole() {
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
createCmd.execute(Arrays.asList(Constants.FN_ROLE, "-unknownOption"));
|
||||
fail("Create command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<MConfig> getConfig(String configName) {
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
|
@ -22,6 +22,9 @@
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -32,7 +35,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -56,15 +58,15 @@ public void testDeleteLink() {
|
||||
|
||||
// delete link -name link_test
|
||||
Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
|
||||
Assert.fail("Delete link should fail as link name is missing!");
|
||||
fail("Delete link should fail as link name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -74,9 +76,9 @@ public void testDeleteLinkWithNonExistingLink() {
|
||||
|
||||
try {
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.fail("Delete link should fail as requested link doesn't exist!");
|
||||
fail("Delete link should fail as requested link doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -86,15 +88,15 @@ public void testDeleteJob() {
|
||||
|
||||
// delete job -name job_test
|
||||
Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Delete job should fail as job name is missing!");
|
||||
fail("Delete job should fail as job name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -104,9 +106,9 @@ public void testDeleteJobWithNonExistingJob() {
|
||||
|
||||
try {
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Delete job should fail as requested job doesn't exist!");
|
||||
fail("Delete job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -116,15 +118,15 @@ public void testDeleteRole() {
|
||||
|
||||
// delete role -r role_test
|
||||
Status status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-r", "role_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option role
|
||||
try {
|
||||
status = (Status) deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
|
||||
Assert.fail("Delete role should fail as role name is missing!");
|
||||
fail("Delete role should fail as role name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,9 +136,19 @@ public void testDeleteRoleWithNonExistingRole() {
|
||||
|
||||
try {
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test"));
|
||||
Assert.fail("Delete role should fail as requested role doesn't exist!");
|
||||
fail("Delete role should fail as requested role doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
deleteCmd.execute(Arrays.asList(Constants.FN_ROLE, "-unknownOption"));
|
||||
fail("Delete command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -55,15 +57,15 @@ public void testDisableLink() {
|
||||
|
||||
// disable link -name link_test
|
||||
Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
|
||||
Assert.fail("Disable link should fail as link name is missing!");
|
||||
fail("Disable link should fail as link name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +75,9 @@ public void testDisableLinkWithNonExistingLink() {
|
||||
|
||||
try {
|
||||
disableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.fail("Disable link should fail as requested link doesn't exist!");
|
||||
fail("Disable link should fail as requested link doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,15 +87,15 @@ public void testDisableJob() {
|
||||
|
||||
// disable job -j job_test
|
||||
Status status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Disable job should fail as job name is missing!");
|
||||
fail("Disable job should fail as job name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +105,19 @@ public void testDisableJobWithNonExistingJob() {
|
||||
|
||||
try {
|
||||
disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Disable job should fail as requested job doesn't exist!");
|
||||
fail("Disable job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
disableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Disable command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,9 @@
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.mockito.Mockito.doThrow;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -55,15 +57,15 @@ public void testEnableLink() {
|
||||
|
||||
// enable link -name link_test
|
||||
Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name"));
|
||||
Assert.fail("Enable link should fail as link name is missing!");
|
||||
fail("Enable link should fail as link name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,9 +75,9 @@ public void testEnableLinkWithNonExistingLink() {
|
||||
|
||||
try {
|
||||
enableCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "link_test"));
|
||||
Assert.fail("Enable link should fail as requested link doesn't exist!");
|
||||
fail("Enable link should fail as requested link doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,15 +87,15 @@ public void testEnableJob() {
|
||||
|
||||
// enable job -j job_test
|
||||
Status status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for option name
|
||||
try {
|
||||
status = (Status) enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Enable job should fail as job id/name is missing!");
|
||||
fail("Enable job should fail as job id/name is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,9 +105,19 @@ public void testEnableJobWithNonExistingJob() {
|
||||
|
||||
try {
|
||||
enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.fail("Enable job should fail as requested job doesn't exist!");
|
||||
fail("Enable job should fail as requested job doesn't exist!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
assertEquals(TestShellError.TEST_SHELL_0000, e.getErrorCode());
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
enableCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Enable command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -56,86 +58,86 @@ public void testGrantRole() {
|
||||
|
||||
// grant role -principal_type user -principal principal_test -role role_test
|
||||
Status status = (Status) grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_test", "-role", "role_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// principal_type is not correct
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "non_existing_principal_type", "-principal", "principal_test", "-role", "role_test"));
|
||||
Assert.fail("Grant role should fail as principal-type is not among user/group/role!");
|
||||
fail("Grant role should fail as principal-type is not among user/group/role!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// Missing argument for principal_type
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type"));
|
||||
Assert.fail("Grant role should fail as parameters aren't complete!");
|
||||
fail("Grant role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing argument for principal
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal"));
|
||||
Assert.fail("Grant role should fail as parameters aren't complete!");
|
||||
fail("Grant role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing argument for role name
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
|
||||
Assert.fail("Grant role should fail as parameters aren't complete!");
|
||||
fail("Grant role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing options principal-type and principal
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test"));
|
||||
Assert.fail("Grant role should fail as of missing required options!");
|
||||
fail("Grant role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing options principal-type and role name
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal", "principal_test"));
|
||||
Assert.fail("Grant role should fail as of missing required options!");
|
||||
fail("Grant role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing options principal and role name
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "role"));
|
||||
Assert.fail("Grant role should fail as of missing required options!");
|
||||
fail("Grant role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option principal-type
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_test", "-principal", "principal_test"));
|
||||
Assert.fail("Grant role should fail as of missing required options!");
|
||||
fail("Grant role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option role
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "group", "-principal", "principal_test"));
|
||||
Assert.fail("Grant role should fail as of missing required options!");
|
||||
fail("Grant role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,57 +148,67 @@ public void testGrantPrivilege() {
|
||||
|
||||
// grant privilege -resource-type connector -resource resource_test -action read -principal principal_test -principal_type group -with-grant
|
||||
Status status = (Status) grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// resource-type is not correct
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "non_existing_resource_type", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as resource-type is not among server/connector/link/job!");
|
||||
fail("Grant privilege should fail as resource-type is not among server/connector/link/job!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// action is not correct
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "non_existing_action", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as action is not among read/write/all!");
|
||||
fail("Grant privilege should fail as action is not among read/write/all!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// principal-type is not correct
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as principal-type is not among user/group/role!");
|
||||
fail("Grant privilege should fail as principal-type is not among user/group/role!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// Missing argument for option resource-type
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as parameters aren't complete!");
|
||||
fail("Grant privilege should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing option principal-type
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as of missing required options!");
|
||||
fail("Grant privilege should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option action
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Grant privilege should fail as of missing required options!");
|
||||
fail("Grant privilege should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
grantCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-unknownOption"));
|
||||
fail("Grant command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -56,86 +58,86 @@ public void testRevokeRole() {
|
||||
|
||||
// revoke role -principal_type user -principal principal_test -role role_1
|
||||
Status status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_test", "-role", "role_1"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// principal_type is not correct
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "non_existing_principal_type", "-principal", "principal_test", "-role", "role_1"));
|
||||
Assert.fail("Revoke role should fail as principal-type is not among user/group/role!");
|
||||
fail("Revoke role should fail as principal-type is not among user/group/role!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// Missing argument for principal_type
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type"));
|
||||
Assert.fail("Revoke role should fail as parameters aren't complete!");
|
||||
fail("Revoke role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing argument for principal
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal"));
|
||||
Assert.fail("Revoke role should fail as parameters aren't complete!");
|
||||
fail("Revoke role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing argument for role name
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role"));
|
||||
Assert.fail("Revoke role should fail as parameters aren't complete!");
|
||||
fail("Revoke role should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Missing options principal-type and principal
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_1"));
|
||||
Assert.fail("Revoke role should fail as of missing required options!");
|
||||
fail("Revoke role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing options principal-type and role name
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal", "principal_test"));
|
||||
Assert.fail("Revoke role should fail as of missing required options!");
|
||||
fail("Revoke role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing options principal and role name
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "role"));
|
||||
Assert.fail("Revoke role should fail as of missing required options!");
|
||||
fail("Revoke role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option principal-type
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-role", "role_1", "-principal", "principal_test"));
|
||||
Assert.fail("Revoke role should fail as of missing required options!");
|
||||
fail("Revoke role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option role
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "group", "-principal", "principal_test"));
|
||||
Assert.fail("Revoke role should fail as of missing required options!");
|
||||
fail("Revoke role should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -146,73 +148,83 @@ public void testRevokePrivilege() {
|
||||
|
||||
// revoke privilege -resource-type connector -resource resource_test -action read -principal principal_test -principal_type group -with-grant
|
||||
Status status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// resource-type is not correct
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "non_existing_resource_type", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as resource-type is not among server/connector/link/job!");
|
||||
fail("Revoke privilege should fail as resource-type is not among server/connector/link/job!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// action is not correct
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "non_existing_action", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as action is not among read/write/all!");
|
||||
fail("Revoke privilege should fail as action is not among read/write/all!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// principal-type is not correct
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as principal-type is not among user/group/role!");
|
||||
fail("Revoke privilege should fail as principal-type is not among user/group/role!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("No enum constant"));
|
||||
assertTrue(e.getMessage().contains("No enum constant"));
|
||||
}
|
||||
|
||||
// Missing argument for option resource-type
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-principal-type", "non_existing_principal_type", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as parameters aren't complete!");
|
||||
fail("Revoke privilege should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
|
||||
// Revoke all privileges for principal: revoke privilege -principal principal_test -principal_type group -with-grant
|
||||
status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing option principal-type
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal", "principal_test", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as of missing required options!");
|
||||
fail("Revoke privilege should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option principal
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "write", "-principal-type", "group", "-with-grant"));
|
||||
Assert.fail("Revoke privilege should fail as of missing required options!");
|
||||
fail("Revoke privilege should fail as of missing required options!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// option resource, resource-type and action must be used together: missing option action
|
||||
status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.ERROR);
|
||||
assertTrue(status != null && status == Status.ERROR);
|
||||
|
||||
// option resource, resource-type and action must be used together: missing option resource
|
||||
status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.ERROR);
|
||||
assertTrue(status != null && status == Status.ERROR);
|
||||
|
||||
// option resource, resource-type and action must be used together: missing option resource-type
|
||||
status = (Status) revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-with-grant"));
|
||||
Assert.assertTrue(status != null && status == Status.ERROR);
|
||||
assertTrue(status != null && status == Status.ERROR);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
revokeCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-resource-type", "connector", "-resource", "resource_test", "-action", "read", "-principal", "principal_test", "-principal-type", "group", "-unknownOption"));
|
||||
fail("Revoke command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,11 @@
|
||||
|
||||
package org.apache.sqoop.shell;
|
||||
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@ -27,7 +32,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -50,41 +54,41 @@ public void testSetServer() {
|
||||
ShellEnvironment.cleanup();
|
||||
// set server -url http://host-test:7070/sqoop-test
|
||||
Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
|
||||
// use the default webapp path if not specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertTrue(client.getServerUrl().equals("http://host-test:7070/sqoop/"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(client.getServerUrl().equals("http://host-test:7070/sqoop/"));
|
||||
|
||||
// use the default webapp and port if not specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test/"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertTrue(client.getServerUrl().equals("http://host-test:12000/sqoop/"));
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(client.getServerUrl().equals("http://host-test:12000/sqoop/"));
|
||||
|
||||
// option host is ignored when option url is specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-host", "host2-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
|
||||
// option port is ignored when option url is specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-port", "12000"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
|
||||
// option webapp is ignored when option url is specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url", "http://host-test:7070/sqoop-test", "-webapp", "sqoop2-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host-test:7070/sqoop-test/");
|
||||
|
||||
// Missing argument for option url
|
||||
try {
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-url"));
|
||||
Assert.fail("Set server should fail as url is missing!");
|
||||
fail("Set server should fail as url is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -93,59 +97,69 @@ public void testSetServerWithoutOptionURL() {
|
||||
ShellEnvironment.cleanup();
|
||||
// use option host, port, webapp when option url is not specified
|
||||
Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070", "-webapp", "sqoop2-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop2-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop2-test/");
|
||||
|
||||
ShellEnvironment.cleanup();
|
||||
// use default host if option host is not specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-port", "7070", "-webapp", "sqoop2-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://localhost:7070/sqoop2-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://localhost:7070/sqoop2-test/");
|
||||
|
||||
ShellEnvironment.cleanup();
|
||||
// use default port if option port is not specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-webapp", "sqoop2-test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host2-test:12000/sqoop2-test/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host2-test:12000/sqoop2-test/");
|
||||
|
||||
ShellEnvironment.cleanup();
|
||||
// use default webapp if option webapp is not specified
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "host2-test", "-port", "7070"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop/");
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(client.getServerUrl(), "http://host2-test:7070/sqoop/");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSetOption() {
|
||||
// set option -name verbose -value true
|
||||
Status status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "true"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertTrue(ShellEnvironment.isVerbose());
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(ShellEnvironment.isVerbose());
|
||||
|
||||
// set option -name verbose -value 1
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "1"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertTrue(ShellEnvironment.isVerbose());
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(ShellEnvironment.isVerbose());
|
||||
|
||||
// set option -name verbose -value 0
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "0"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertFalse(ShellEnvironment.isVerbose());
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertFalse(ShellEnvironment.isVerbose());
|
||||
|
||||
// set option -name poll-timeout -value 12345
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "12345"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
|
||||
// when value of poll-timeout is not number, poll-timeout should stay the old value
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout", "-value", "abc"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
|
||||
// skip non exist options, options already set should stay the old value
|
||||
status = (Status) setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "non-exist-option", "-value", "opt-value"));
|
||||
Assert.assertTrue(status == null);
|
||||
Assert.assertFalse(ShellEnvironment.isVerbose());
|
||||
Assert.assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
assertTrue(status == null);
|
||||
assertFalse(ShellEnvironment.isVerbose());
|
||||
assertEquals(ShellEnvironment.getPollTimeout(), 12345);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
setCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose", "-value", "true", "-unknownOption"));
|
||||
fail("Set command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,10 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertFalse;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
@ -50,7 +54,6 @@
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.codehaus.groovy.tools.shell.IO;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -75,47 +78,47 @@ public void testShowServer() throws IOException {
|
||||
// show server -host -port -webapp
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host", "-port", "-webapp"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Server host:"));
|
||||
Assert.assertTrue(str.contains("Server port:"));
|
||||
Assert.assertTrue(str.contains("Server webapp:"));
|
||||
assertTrue(str.contains("Server host:"));
|
||||
assertTrue(str.contains("Server port:"));
|
||||
assertTrue(str.contains("Server webapp:"));
|
||||
|
||||
// show server -all
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-all"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Server host:"));
|
||||
Assert.assertTrue(str.contains("Server port:"));
|
||||
Assert.assertTrue(str.contains("Server webapp:"));
|
||||
assertTrue(str.contains("Server host:"));
|
||||
assertTrue(str.contains("Server port:"));
|
||||
assertTrue(str.contains("Server webapp:"));
|
||||
|
||||
// show server -host
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-host"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Server host:"));
|
||||
Assert.assertFalse(str.contains("Server port:"));
|
||||
Assert.assertFalse(str.contains("Server webapp:"));
|
||||
assertTrue(str.contains("Server host:"));
|
||||
assertFalse(str.contains("Server port:"));
|
||||
assertFalse(str.contains("Server webapp:"));
|
||||
|
||||
// show server -port
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-port"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertFalse(str.contains("Server host:"));
|
||||
Assert.assertTrue(str.contains("Server port:"));
|
||||
Assert.assertFalse(str.contains("Server webapp:"));
|
||||
assertFalse(str.contains("Server host:"));
|
||||
assertTrue(str.contains("Server port:"));
|
||||
assertFalse(str.contains("Server webapp:"));
|
||||
|
||||
// show server -webapp
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SERVER, "-webapp"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertFalse(str.contains("Server host:"));
|
||||
Assert.assertFalse(str.contains("Server port:"));
|
||||
Assert.assertTrue(str.contains("Server webapp:"));
|
||||
assertFalse(str.contains("Server host:"));
|
||||
assertFalse(str.contains("Server port:"));
|
||||
assertTrue(str.contains("Server webapp:"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -125,29 +128,29 @@ public void testShowVersion() {
|
||||
// show version -server -client -api
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION, "-server", "-client", "-api"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("server version:"));
|
||||
Assert.assertTrue(str.contains("client version:"));
|
||||
Assert.assertTrue(str.contains("API versions:"));
|
||||
assertTrue(str.contains("server version:"));
|
||||
assertTrue(str.contains("client version:"));
|
||||
assertTrue(str.contains("API versions:"));
|
||||
|
||||
// show version -all
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION, "-all"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("server version:"));
|
||||
Assert.assertTrue(str.contains("client version:"));
|
||||
Assert.assertTrue(str.contains("API versions:"));
|
||||
assertTrue(str.contains("server version:"));
|
||||
assertTrue(str.contains("client version:"));
|
||||
assertTrue(str.contains("API versions:"));
|
||||
|
||||
// show client version when no option is specified
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_VERSION));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertFalse(str.contains("server version:"));
|
||||
Assert.assertTrue(str.contains("client version:"));
|
||||
Assert.assertFalse(str.contains("API versions:"));
|
||||
assertFalse(str.contains("server version:"));
|
||||
assertTrue(str.contains("client version:"));
|
||||
assertFalse(str.contains("API versions:"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -162,26 +165,26 @@ public void testShowConnector() {
|
||||
// show connector summary
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Name"));
|
||||
Assert.assertTrue(str.contains("Version"));
|
||||
Assert.assertTrue(str.contains("Class"));
|
||||
Assert.assertTrue(str.contains("Supported Directions"));
|
||||
assertTrue(str.contains("Name"));
|
||||
assertTrue(str.contains("Version"));
|
||||
assertTrue(str.contains("Class"));
|
||||
assertTrue(str.contains("Supported Directions"));
|
||||
|
||||
// show connector -all
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR, "-all"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("connector(s) to show:"));
|
||||
assertTrue(str.contains("connector(s) to show:"));
|
||||
|
||||
// show connector -name test_connector
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_CONNECTOR, "-name", "test_connector"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Connector with Name: test_connector"));
|
||||
assertTrue(str.contains("Connector with Name: test_connector"));
|
||||
}
|
||||
|
||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||
@ -194,9 +197,9 @@ public void testShowDriver() {
|
||||
// show driver
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_DRIVER_CONFIG));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Driver specific options:"));
|
||||
assertTrue(str.contains("Driver specific options:"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -209,25 +212,25 @@ public void testShowLink() {
|
||||
// show link summary
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Name"));
|
||||
Assert.assertTrue(str.contains("Connector Name"));
|
||||
Assert.assertTrue(str.contains("Enabled"));
|
||||
assertTrue(str.contains("Name"));
|
||||
assertTrue(str.contains("Connector Name"));
|
||||
assertTrue(str.contains("Enabled"));
|
||||
|
||||
// show link -all
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK, "-all"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("link(s) to show:"));
|
||||
assertTrue(str.contains("link(s) to show:"));
|
||||
|
||||
// show link -name linkName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_LINK, "-name", "linkName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("link with name"));
|
||||
assertTrue(str.contains("link with name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -246,34 +249,34 @@ public void testShowJob() {
|
||||
// show job summary
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Id"));
|
||||
Assert.assertTrue(str.contains("Name"));
|
||||
Assert.assertTrue(str.contains("From Connector"));
|
||||
Assert.assertTrue(str.contains("To Connector"));
|
||||
Assert.assertTrue(str.contains("Enabled"));
|
||||
assertTrue(str.contains("Id"));
|
||||
assertTrue(str.contains("Name"));
|
||||
assertTrue(str.contains("From Connector"));
|
||||
assertTrue(str.contains("To Connector"));
|
||||
assertTrue(str.contains("Enabled"));
|
||||
|
||||
// show job -all
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-all"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("job(s) to show:"));
|
||||
assertTrue(str.contains("job(s) to show:"));
|
||||
|
||||
// show job -name jobName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Job with name"));
|
||||
assertTrue(str.contains("Job with name"));
|
||||
|
||||
// show job -connector fromConnectorName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_JOB, "-connector", "fromConnectorName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("job(s) to show:"));
|
||||
assertTrue(str.contains("job(s) to show:"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -284,36 +287,36 @@ public void testShowSubmission() {
|
||||
// show submission -details -job jobName
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail", "-job", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Submission details"));
|
||||
assertTrue(str.contains("Submission details"));
|
||||
|
||||
// show submission -details
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-detail"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Submission details"));
|
||||
assertTrue(str.contains("Submission details"));
|
||||
|
||||
// show submission -job jobName
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION, "-job", "jobName"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Job Name"));
|
||||
Assert.assertTrue(str.contains("External Id"));
|
||||
Assert.assertTrue(str.contains("Status"));
|
||||
Assert.assertTrue(str.contains("Last Update Date"));
|
||||
assertTrue(str.contains("Job Name"));
|
||||
assertTrue(str.contains("External Id"));
|
||||
assertTrue(str.contains("Status"));
|
||||
assertTrue(str.contains("Last Update Date"));
|
||||
|
||||
// show submission
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_SUBMISSION));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Job Name"));
|
||||
Assert.assertTrue(str.contains("External Id"));
|
||||
Assert.assertTrue(str.contains("Status"));
|
||||
Assert.assertTrue(str.contains("Last Update Date"));
|
||||
assertTrue(str.contains("Job Name"));
|
||||
assertTrue(str.contains("External Id"));
|
||||
assertTrue(str.contains("Status"));
|
||||
assertTrue(str.contains("Last Update Date"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -321,24 +324,24 @@ public void testShowOption() {
|
||||
// show option -name verbose
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "verbose"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Verbose ="));
|
||||
assertTrue(str.contains("Verbose ="));
|
||||
|
||||
// show option -name poll-timeout
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION, "-name", "poll-timeout"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Poll-timeout ="));
|
||||
assertTrue(str.contains("Poll-timeout ="));
|
||||
|
||||
// show all options
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_OPTION));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Verbose ="));
|
||||
Assert.assertTrue(str.contains("Poll-timeout ="));
|
||||
assertTrue(str.contains("Verbose ="));
|
||||
assertTrue(str.contains("Poll-timeout ="));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -347,17 +350,17 @@ public void testShowRole() {
|
||||
// show role -principal-type user -principal principal_1
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_ROLE, "-principal-type", "user", "-principal", "principal_1"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Role Name"));
|
||||
assertTrue(str.contains("Role Name"));
|
||||
|
||||
when(client.getRoles()).thenReturn(new ArrayList<MRole>());
|
||||
// show role
|
||||
out.reset();
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_ROLE));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Role Name"));
|
||||
assertTrue(str.contains("Role Name"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -366,17 +369,17 @@ public void testShowPrincipal() {
|
||||
// show principal -role role_test
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL, "-role", "role_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Principal Name"));
|
||||
Assert.assertTrue(str.contains("Principal Type"));
|
||||
assertTrue(str.contains("Principal Name"));
|
||||
assertTrue(str.contains("Principal Type"));
|
||||
|
||||
// Missing option role name
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL));
|
||||
Assert.fail("Show principal should fail as role name is missing!");
|
||||
fail("Show principal should fail as role name is missing!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -387,52 +390,62 @@ public void testShowPrivilege() {
|
||||
out.reset();
|
||||
Status status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE,
|
||||
"-principal-type", "user", "-principal", "principal_test", "-resource-type", "connector", "-resource", "resource_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
String str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Action"));
|
||||
Assert.assertTrue(str.contains("Resource Name"));
|
||||
Assert.assertTrue(str.contains("Resource Type"));
|
||||
Assert.assertTrue(str.contains("With Grant"));
|
||||
assertTrue(str.contains("Action"));
|
||||
assertTrue(str.contains("Resource Name"));
|
||||
assertTrue(str.contains("Resource Type"));
|
||||
assertTrue(str.contains("With Grant"));
|
||||
|
||||
// show privilege -principal-type user -principal principal_test
|
||||
status = (Status) showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
str = new String(out.toByteArray());
|
||||
Assert.assertTrue(str.contains("Action"));
|
||||
Assert.assertTrue(str.contains("Resource Name"));
|
||||
Assert.assertTrue(str.contains("Resource Type"));
|
||||
Assert.assertTrue(str.contains("With Grant"));
|
||||
assertTrue(str.contains("Action"));
|
||||
assertTrue(str.contains("Resource Name"));
|
||||
assertTrue(str.contains("Resource Type"));
|
||||
assertTrue(str.contains("With Grant"));
|
||||
|
||||
// options resource-type and resource must be used together: missing option resource
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test", "-resource-type", "connector"));
|
||||
Assert.fail("Show principal should fail as option resource is missing!");
|
||||
fail("Show principal should fail as option resource is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
|
||||
assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
|
||||
}
|
||||
|
||||
// options resource-type and resource must be used together: missing option resource-type
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "user", "-principal", "principal_test", "-resource", "resource_test"));
|
||||
Assert.fail("Show principal should fail as option resource-type is missing!");
|
||||
fail("Show principal should fail as option resource-type is missing!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
|
||||
assertEquals(e.getErrorCode(), ShellError.SHELL_0003);
|
||||
}
|
||||
|
||||
// Missing option principal-type
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal", "principal_test", "-resource-type", "connector", "-resource", "resource_test"));
|
||||
Assert.fail("Show privilege should fail as option principal-type is missing!");
|
||||
fail("Show privilege should fail as option principal-type is missing!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
|
||||
// Missing option principal
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRINCIPAL, "-principal-type", "group", "-resource-type", "connector", "-resource", "resource_test"));
|
||||
Assert.fail("Show privilege should fail as option principal is missing!");
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-principal-type", "group", "-resource-type", "connector", "-resource", "resource_test"));
|
||||
fail("Show privilege should fail as option principal is missing!");
|
||||
} catch (Exception e) {
|
||||
Assert.assertTrue(e.getMessage().contains("Missing required option"));
|
||||
assertTrue(e.getMessage().contains("Missing required option"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
showCmd.execute(Arrays.asList(Constants.FN_PRIVILEGE, "-unknownOption"));
|
||||
fail("Show principal should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -32,7 +35,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -57,15 +59,15 @@ public void testStartJobSynchronousDisabled() throws InterruptedException {
|
||||
|
||||
// start job -name job_test
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for name
|
||||
try {
|
||||
startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Start job should fail as parameters aren't complete!");
|
||||
fail("Start job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@ -75,6 +77,16 @@ public void testStartJobSynchronousEnabled() throws InterruptedException {
|
||||
|
||||
// start job -name job_test -synchronous
|
||||
Status status = (Status) startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-synchronous"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
startCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Start command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -56,15 +58,25 @@ public void testGetJobStatus() {
|
||||
|
||||
// status job -name job_test
|
||||
Status status = (Status) statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for name
|
||||
try {
|
||||
statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Get job status should fail as parameters aren't complete!");
|
||||
fail("Get job status should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
statusCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Status command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,9 @@
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
import static org.testng.Assert.fail;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -31,7 +34,6 @@
|
||||
import org.apache.sqoop.shell.core.ShellError;
|
||||
import org.apache.sqoop.validation.Status;
|
||||
import org.codehaus.groovy.tools.shell.Groovysh;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.BeforeTest;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
@ -56,15 +58,25 @@ public void testStopJob() {
|
||||
|
||||
// stop job -name job_test
|
||||
Status status = (Status) stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test"));
|
||||
Assert.assertTrue(status != null && status == Status.OK);
|
||||
assertTrue(status != null && status == Status.OK);
|
||||
|
||||
// Missing argument for name
|
||||
try {
|
||||
stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-name"));
|
||||
Assert.fail("Stop job should fail as parameters aren't complete!");
|
||||
fail("Stop job should fail as parameters aren't complete!");
|
||||
} catch (SqoopException e) {
|
||||
Assert.assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
Assert.assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
assertEquals(ShellError.SHELL_0003, e.getErrorCode());
|
||||
assertTrue(e.getMessage().contains("Missing argument for option"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
stopCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Stop command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -295,6 +295,16 @@ public void testUpdateJobInteractive() {
|
||||
assertEquals(job.getDriverConfig().getDateTimeInput("driverConfig.DateTime").getValue().getMillis(), 7654321);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testUnknowOption() {
|
||||
try {
|
||||
updateCmd.execute(Arrays.asList(Constants.FN_JOB, "-name", "job_test", "-unknownOption"));
|
||||
fail("Update command should fail as unknown option encountered!");
|
||||
} catch (Exception e) {
|
||||
assertTrue(e.getMessage().contains("Unknown option encountered"));
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<MConfig> getConfig(String configName) {
|
||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||
|
@ -22,16 +22,15 @@
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.sqoop.cli.SqoopGnuParser;
|
||||
import org.apache.sqoop.common.VersionInfo;
|
||||
import org.apache.sqoop.connector.ConnectorManager;
|
||||
import org.apache.sqoop.json.JobsBean;
|
||||
@ -41,7 +40,6 @@
|
||||
import org.apache.sqoop.repository.Repository;
|
||||
import org.apache.sqoop.repository.RepositoryManager;
|
||||
import org.apache.sqoop.tools.ConfiguredTool;
|
||||
import org.json.simple.JSONArray;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
/**
|
||||
@ -66,7 +64,7 @@ public boolean runToolWithConfiguration(String[] arguments) {
|
||||
.withLongOpt("output")
|
||||
.create('o'));
|
||||
|
||||
CommandLineParser parser = new GnuParser();
|
||||
CommandLineParser parser = new SqoopGnuParser();
|
||||
|
||||
try {
|
||||
CommandLine line = parser.parse(options, arguments);
|
||||
|
@ -26,13 +26,13 @@
|
||||
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.CommandLineParser;
|
||||
import org.apache.commons.cli.GnuParser;
|
||||
import org.apache.commons.cli.OptionBuilder;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.apache.commons.cli.ParseException;
|
||||
import org.apache.commons.io.Charsets;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.apache.sqoop.cli.SqoopGnuParser;
|
||||
import org.apache.sqoop.common.Direction;
|
||||
import org.apache.sqoop.common.VersionInfo;
|
||||
import org.apache.sqoop.connector.ConnectorManager;
|
||||
@ -84,7 +84,7 @@ public boolean runToolWithConfiguration(String[] arguments) {
|
||||
options.addOption(OptionBuilder.isRequired().hasArg().withArgName("filename")
|
||||
.withLongOpt("input").create('i'));
|
||||
|
||||
CommandLineParser parser = new GnuParser();
|
||||
CommandLineParser parser = new SqoopGnuParser();
|
||||
|
||||
try {
|
||||
CommandLine line = parser.parse(options, arguments);
|
||||
|
Loading…
Reference in New Issue
Block a user