You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by kl...@apache.org on 2016/06/15 18:26:00 UTC
incubator-geode git commit: Fix precheckin failures
Repository: incubator-geode
Updated Branches:
refs/heads/feature/GEODE-835 33ed9d647 -> a3cc50912
Fix precheckin failures
Project: http://git-wip-us.apache.org/repos/asf/incubator-geode/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-geode/commit/a3cc5091
Tree: http://git-wip-us.apache.org/repos/asf/incubator-geode/tree/a3cc5091
Diff: http://git-wip-us.apache.org/repos/asf/incubator-geode/diff/a3cc5091
Branch: refs/heads/feature/GEODE-835
Commit: a3cc50912fe94141f15e6b07f66adc171bc8c31b
Parents: 33ed9d6
Author: Kirk Lund <kl...@apache.org>
Authored: Wed Jun 15 11:25:48 2016 -0700
Committer: Kirk Lund <kl...@apache.org>
Committed: Wed Jun 15 11:25:48 2016 -0700
----------------------------------------------------------------------
.../cli/parser/jopt/JoptOptionParser.java | 11 +-
.../internal/cli/GfshParserJUnitTest.java | 140 -------------------
.../internal/cli/JoptOptionParserTest.java | 11 +-
3 files changed, 11 insertions(+), 151 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a3cc5091/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/jopt/JoptOptionParser.java
----------------------------------------------------------------------
diff --git a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/jopt/JoptOptionParser.java b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/jopt/JoptOptionParser.java
index 777e705..bbda3e6 100644
--- a/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/jopt/JoptOptionParser.java
+++ b/geode-core/src/main/java/com/gemstone/gemfire/management/internal/cli/parser/jopt/JoptOptionParser.java
@@ -115,7 +115,7 @@ public class JoptOptionParser implements GfshOptionParser {
optionSet.setUserInput(userInput!=null?userInput.trim():"");
if (userInput != null) {
TrimmedInput input = PreprocessorUtils.trim(userInput);
- String[] preProcessedInput = preProcess(new OptionJFormatter().formatCommand(input.getString()));
+ String[] preProcessedInput = preProcess(new OptionJFormatter().formatCommand(input.getString())); // TODO: use OptionJFormatter
joptsimple.OptionSet joptOptionSet = null;
CliCommandOptionException ce = null;
// int factor = 0;
@@ -123,22 +123,21 @@ public class JoptOptionParser implements GfshOptionParser {
joptOptionSet = parser.parse(preProcessedInput);
} catch (OptionException e) {
ce = processException(e);
- // KIRK: joptOptionSet = e.getDetected();
+ // TODO:KIRK: joptOptionSet = e.getDetected(); // TODO: removed when geode-joptsimple was removed
}
if (joptOptionSet != null) {
// Make sure there are no miscellaneous, unknown strings that cannot be identified as
// either options or arguments.
if (joptOptionSet.nonOptionArguments().size() > arguments.size()) {
- // KIRK: String unknownString = joptOptionSet.nonOptionArguments().get(arguments.size());
- String unknownString = (String)joptOptionSet.nonOptionArguments().get(arguments.size());
+ String unknownString = (String)joptOptionSet.nonOptionArguments().get(arguments.size()); // TODO: added cast when geode-joptsimple was removed
// If the first option is un-parseable then it will be returned as "<option>=<value>" since it's
// been interpreted as an argument. However, all subsequent options will be returned as "<option>".
// This hack splits off the string before the "=" sign if it's the first case.
if (unknownString.matches("^-*\\w+=.*$")) {
unknownString = unknownString.substring(0, unknownString.indexOf('='));
}
- // KIRK: ce = processException(OptionException.createUnrecognizedOptionException(unknownString, joptOptionSet));
+ // TODO:KIRK: ce = processException(OptionException.createUnrecognizedOptionException(unknownString, joptOptionSet)); // TODO: removed when geode-joptsimple was removed
}
// First process the arguments
@@ -200,7 +199,7 @@ public class JoptOptionParser implements GfshOptionParser {
if (arguments.size() > 1 && !(option.getConverter() instanceof MultipleValueConverter) && option.getValueSeparator() == null) {
List<String> optionList = new ArrayList<String>(1);
optionList.add(string);
- // KIRK: ce = processException(new MultipleArgumentsForOptionException(optionList, joptOptionSet));
+ // TODO:KIRK: ce = processException(new MultipleArgumentsForOptionException(optionList, joptOptionSet)); // TODO: removed when geode-joptsimple was removed
} else if ((arguments.size() == 1 && !(option.getConverter() instanceof MultipleValueConverter)) || option.getValueSeparator() == null) {
optionSet.put(option, arguments.get(0).toString().trim());
} else {
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a3cc5091/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java
index d6ad647..95e4943 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/GfshParserJUnitTest.java
@@ -136,13 +136,6 @@ public class GfshParserJUnitTest {
CommandManager.clearInstance();
}
- @Test
- public void testStartLocator() throws Exception {
- //String input = "start locator --name=loc1 --J=-Dgemfire.http-service-port=8080";
- String input = "start locator --name=loc1";
- ParseResult parse = parser.parse(input);
- }
-
/**
* Tests the auto-completion capability of {@link GfshParser} with the method
* {@link GfshParser#complete(String, int, List)}
@@ -200,54 +193,6 @@ public class GfshParserJUnitTest {
}
assertSimpleCompletionValues(completionValues, completionCandidates);
- // Input contains command name and first argument
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue();
- clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
-
- // Here we expect the completions for argument2
- for (Completion completion : ARGUMENT2_COMPLETIONS) {
- completionValues.add(SyntaxConstants.ARGUMENT_SEPARATOR + completion.getValue());
- }
- assertSimpleCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument and the prefix of second
- // argument
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue()
- .substring(0, 2);
- clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
- // Here we expect the completions for argument2
- for (Completion completion : ARGUMENT2_COMPLETIONS) {
- if (completion.getValue().startsWith(ARGUMENT2_COMPLETIONS[0].getValue().substring(0, 2))) {
- completionValues.add(SyntaxConstants.ARGUMENT_SEPARATOR + completion.getValue());
- }
- }
- assertSimpleCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument and second argument
- input = COMMAND1_NAME + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue();
- clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
- // Here we expect all the mandatory options
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME);
- assertSimpleCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name (synonym), first argument, second argument,
- // prefix of first option
- input = command1Names[1] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME.substring(0, 3);
- clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
- // Here we expect the names for all the options
- // whose prefix matches with the provided prefix
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME);
- if (OPTION2_NAME.startsWith(OPTION1_NAME.substring(0, 3))) {
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME);
- }
- if (OPTION3_NAME.startsWith(OPTION1_NAME.substring(0, 3))) {
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION3_NAME);
- }
- assertSimpleCompletionValues(completionValues, completionCandidates);
-
// Input contains command name, first argument, second argument
// and first option
input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
@@ -322,23 +267,6 @@ public class GfshParserJUnitTest {
clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
// Here we expect nothing for completion
assertSimpleCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument, second argument,
- // first option and multiple values assigned to it. It also contains
- // start of the second option
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + " " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME + SyntaxConstants.OPTION_VALUE_SPECIFIER + OPTION1_COMPLETIONS[0]
- .getValue() + SyntaxConstants.VALUE_SEPARATOR + OPTION1_COMPLETIONS[1].getValue() + " " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME
- .substring(0, 3);
- clearAndSimpleComplete(completionCandidates, completionValues, input, parser);
- // Here we expect those options which have not been specified
- // before and which have the prefix specified herein as their
- // prefix
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME);
- if (OPTION3_NAME.startsWith(OPTION2_NAME.substring(0, 3))) {
- completionValues.add(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION3_NAME);
- }
- assertSimpleCompletionValues(completionValues, completionCandidates);
}
private void clearAndSimpleComplete(List<String> completionCandidates,
@@ -353,10 +281,6 @@ public class GfshParserJUnitTest {
private void assertSimpleCompletionValues(List<String> expected, List<String> actual) {
assertEquals("Check size", expected.size(), actual.size());
assertEquals(expected, actual);
-// for (int i = 0; i < expected.size(); i++) {
-// assertEquals("Check completion value no." + i + ". Expected(" + expected.get(i) + ") & Actual(" + actual.get(i) + ").",
-// expected.get(i), actual.get(i));
-// }
}
/**
@@ -416,53 +340,6 @@ public class GfshParserJUnitTest {
}
assertAdvancedCompletionValues(completionValues, completionCandidates);
- // Input contains command name and first argument
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue();
- clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
- // Here we expect the completions for argument2
- for (Completion completion : ARGUMENT2_COMPLETIONS) {
- completionValues.add(new Completion(SyntaxConstants.ARGUMENT_SEPARATOR + completion.getValue(), completion.getFormattedValue(), null, 0));
- }
- assertAdvancedCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument and the prefix of second
- // argument
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue()
- .substring(0, 2);
- clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
- // Here we expect the completions for argument2
- for (Completion completion : ARGUMENT2_COMPLETIONS) {
- if (completion.getValue().startsWith(ARGUMENT2_COMPLETIONS[0].getValue().substring(0, 2))) {
- completionValues.add(new Completion(SyntaxConstants.ARGUMENT_SEPARATOR + completion.getValue(), completion.getFormattedValue(), null, 0));
- }
- }
- assertAdvancedCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument and second argument
- input = COMMAND1_NAME + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue();
- clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
- // Here we expect all the mandatory options
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME, OPTION1_NAME, null, 0));
- assertAdvancedCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name (synonym), first argument, second argument,
- // prefix of first option
- input = command1Names[1] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME.substring(0, 3);
- clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
- // Here we expect the names for all the options
- // whose prefix matches with the provided prefix
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME, OPTION1_NAME, null, 0));
- if (OPTION2_NAME.startsWith(OPTION1_NAME.substring(0, 3))) {
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME, OPTION2_NAME, null, 0));
- }
- if (OPTION3_NAME.startsWith(OPTION1_NAME.substring(0, 3))) {
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION3_NAME, OPTION3_NAME, null, 0));
- }
- assertAdvancedCompletionValues(completionValues, completionCandidates);
-
// Input contains command name, first argument, second argument
// and first option
input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
@@ -538,23 +415,6 @@ public class GfshParserJUnitTest {
clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
// Here we expect nothing for completion
assertAdvancedCompletionValues(completionValues, completionCandidates);
-
- // Input contains command name, first argument, second argument,
- // first option and multiple values assigned to it. It also contains
- // start of the second option
- input = command1Names[0] + " " + ARGUMENT1_COMPLETIONS[0].getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + ARGUMENT2_COMPLETIONS[0]
- .getValue() + SyntaxConstants.ARGUMENT_SEPARATOR + " " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION1_NAME + SyntaxConstants.OPTION_VALUE_SPECIFIER + OPTION1_COMPLETIONS[0]
- .getValue() + SyntaxConstants.VALUE_SEPARATOR + OPTION1_COMPLETIONS[1].getValue() + " " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME
- .substring(0, 3);
- clearAndAdvancedComplete(completionCandidates, completionValues, input, parser);
- // Here we expect those options which have not been specified
- // before and which have the prefix specified herein as their
- // prefix
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION2_NAME, OPTION2_NAME, null, 0));
- if (OPTION3_NAME.startsWith(OPTION2_NAME.substring(0, 3))) {
- completionValues.add(new Completion(" " + SyntaxConstants.LONG_OPTION_SPECIFIER + OPTION3_NAME, OPTION3_NAME, null, 0));
- }
- assertAdvancedCompletionValues(completionValues, completionCandidates);
}
private void clearAndAdvancedComplete(List<Completion> completionCandidates,
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/a3cc5091/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/JoptOptionParserTest.java
----------------------------------------------------------------------
diff --git a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/JoptOptionParserTest.java b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/JoptOptionParserTest.java
index bbe6228..01a2b74 100644
--- a/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/JoptOptionParserTest.java
+++ b/geode-core/src/test/java/com/gemstone/gemfire/management/internal/cli/JoptOptionParserTest.java
@@ -39,7 +39,7 @@ import com.gemstone.gemfire.management.internal.cli.parser.jopt.JoptOptionParser
import com.gemstone.gemfire.test.junit.categories.UnitTest;
@Category(UnitTest.class)
-//@RunWith(JUnitParamsRunner.class)
+@RunWith(JUnitParamsRunner.class)
public class JoptOptionParserTest {
private JoptOptionParser emptyOptionParser;
@@ -223,7 +223,7 @@ public class JoptOptionParserTest {
}
@Test
- public void parseInputWithUndefinedArgumentShouldThrow() throws Exception {
+ public void parseInputWithUndefinedArgumentShouldNotThrow() throws Exception {
LinkedList<Argument> arguments = new LinkedList<>();
LinkedList<Option> options = new LinkedList<>();
@@ -233,7 +233,8 @@ public class JoptOptionParserTest {
optionParser.setArguments(arguments);
optionParser.setOptions(options);
- assertThatThrownBy(() -> optionParser.parse("command1 argument1_value? argument2_value")).isOfAnyClassIn(CliCommandOptionNotApplicableException.class);
+ OptionSet optionSet = optionParser.parse("command1 argument1_value? argument2_value");
+ assertThat(optionSet.getUserInput()).isEqualTo("command1 argument1_value? argument2_value");
}
@Test
@@ -287,8 +288,8 @@ public class JoptOptionParserTest {
assertThat(optionSet.hasOption(this.requiredOption)).isFalse();
}
-// @Test
-// @Parameters(method = "exampleInputParameters")
+ @Test
+ @Parameters(method = "exampleInputParameters")
public void parseInputWithExampleInputParametesr(String command, boolean expectException, boolean hasArguments, boolean hasOptions) throws Exception {
if (expectException) {
assertThatThrownBy(() -> this.exampleOptionParser.parse(command)).isExactlyInstanceOf(CliCommandOptionMissingException.class);