Repository: incubator-geode Updated Branches: refs/heads/feature/GEODE-1912 [created] 809d64d71
http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/809d64d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java deleted file mode 100644 index 1483aad..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/HelpCommandsIntegrationTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli.commands; - -import org.apache.geode.cache.CacheFactory; -import org.apache.geode.distributed.internal.InternalDistributedSystem; -import org.apache.geode.internal.AvailablePortHelper; -import org.apache.geode.management.internal.cli.CommandManager; -import org.apache.geode.management.internal.cli.parser.CommandTarget; -import org.apache.geode.management.internal.cli.result.CommandResult; -import org.apache.geode.management.internal.cli.shell.Gfsh; -import org.apache.geode.management.internal.cli.shell.GfshConfig; -import org.apache.geode.test.junit.categories.IntegrationTest; -import org.junit.After; -import org.junit.Before; -import org.junit.ClassRule; -import org.junit.Test; -import org.junit.contrib.java.lang.system.ProvideSystemProperty; -import org.junit.experimental.categories.Category; - -import java.util.Map; -import java.util.Properties; - -import static org.apache.geode.distributed.ConfigurationProperties.*; -import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.commandResultToString; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - -@Category(IntegrationTest.class) -public class HelpCommandsIntegrationTest { - - private int jmxPort; - - private Gfsh gfsh; - - @ClassRule - public static final ProvideSystemProperty isGfsh = new ProvideSystemProperty("gfsh", "true"); - - @Before - public void setup() throws Exception { - jmxPort = AvailablePortHelper.getRandomAvailableTCPPort(); - - Properties localProps = new Properties(); - localProps.setProperty(LOCATORS, ""); - localProps.setProperty(MCAST_PORT, "0"); - localProps.setProperty(JMX_MANAGER, "true"); - localProps.setProperty(JMX_MANAGER_START, "true"); - localProps.setProperty(JMX_MANAGER_PORT, String.valueOf(jmxPort)); - - new CacheFactory(localProps).create(); - - gfsh = Gfsh.getInstance(false, new String[0], new GfshConfig()); - } - - @After - public void teardown() { - InternalDistributedSystem ids = InternalDistributedSystem.getConnectedInstance(); - if (ids != null) { - ids.disconnect(); - } - } - - /** - * TODO:GEODE-1466: update golden file to geode.properties TODO:GEODE-1566: update golden file to - * GeodeRedisServer - */ - @Test - public void testOfflineHelp() throws Exception { - Properties helpProps = new Properties(); - helpProps.load( - HelpCommandsIntegrationTest.class.getResourceAsStream("golden-help-offline.properties")); - - CommandManager cm = CommandManager.getInstance(); - for (Map.Entry<String, CommandTarget> e : cm.getCommands().entrySet()) { - // Mock commands may have been produced in the VM by other tests - // 'quit' is an alias for 'exit' and doesn't produce help - if (e.getKey().contains("mock") || e.getKey().contains("quit")) { - continue; - } - - CommandResult cr = (CommandResult) gfsh.executeCommand("help " + e.getKey()).getResult(); - String gfshResult = commandResultToString(cr); - - String goldParam = e.getKey().replace(" ", "-") + ".help"; - String goldResult = helpProps.getProperty(goldParam); - assertNotNull("No golden text for: " + goldParam, goldResult); - assertEquals(goldResult.trim(), gfshResult.trim()); - - helpProps.remove(goldParam); - } - - // No help should remain unchecked - assertEquals(0, helpProps.size()); - } - - @Test - public void testOnlineHelp() throws Exception { - Properties helpProps = new Properties(); - helpProps.load( - HelpCommandsIntegrationTest.class.getResourceAsStream("golden-help-online.properties")); - - gfsh.executeCommand("connect --jmx-manager=localhost[" + jmxPort + "]"); - - CommandManager cm = CommandManager.getInstance(); - for (Map.Entry<String, CommandTarget> e : cm.getCommands().entrySet()) { - // Mock commands may have been produced in the VM by other tests - // 'quit' is an alias for 'exit' and doesn't produce help - if (e.getKey().contains("mock") || e.getKey().contains("quit")) { - continue; - } - - CommandResult cr = (CommandResult) gfsh.executeCommand("help " + e.getKey()).getResult(); - String gfshResult = commandResultToString(cr); - - String goldParam = e.getKey().replace(" ", "-") + ".help"; - String goldResult = helpProps.getProperty(goldParam); - assertNotNull("No golden text for: " + goldParam, goldResult); - - String[] lines = gfshResult.split("\n"); - gfshResult = String.join("\n", lines[0], lines[1], lines[2], lines[3]); - - assertEquals(goldResult.trim(), gfshResult.trim()); - - helpProps.remove(goldParam); - } - - // No help should remain unchecked - assertEquals(0, helpProps.size()); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/809d64d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/ParserUtilsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/ParserUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/ParserUtilsJUnitTest.java deleted file mode 100644 index 9b22e64..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/ParserUtilsJUnitTest.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli.parser; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import org.apache.geode.test.junit.categories.UnitTest; - -/** - * Includes tests for all utility methods in {@link ParserUtils} - */ -@Category(UnitTest.class) -public class ParserUtilsJUnitTest { - - /** - * Test for {@link ParserUtils#split(String, String)} - */ - @Test - public void testSplit() { - String input = "something::{::}::nothing"; - String[] split = ParserUtils.split(input, "::"); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "something", split[0]); - assertEquals("Second string", "{::}", split[1]); - assertEquals("Third string", "nothing", split[2]); - } - - /** - * Test for {@link ParserUtils#splitValues(String, String)} - */ - @Test - public void testSplitValues() { - String input = "something::{::}::nothing::"; - String[] split = ParserUtils.splitValues(input, "::"); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "something", split[0]); - assertEquals("Second string", "{::}", split[1]); - assertEquals("Third string", "nothing", split[2]); - assertEquals("Fourth string", "", split[3]); - } - - /** - * Test for {@link ParserUtils#contains(String, String)} - */ - @Test - public void testContains() { - String input = "something::{::}::nothing::"; - assertTrue("Check Boolean", ParserUtils.contains(input, "::")); - input = "{something::{::}::nothing::}"; - assertFalse("Check Boolean", ParserUtils.contains(input, "::")); - } - - /** - * Test for {@link ParserUtils#lastIndexOf(String, String)} - */ - @Test - public void testLastIndexOf() { - String input = "something::{::}::nothing::"; - assertEquals("lastIndex", 24, ParserUtils.lastIndexOf(input, "::")); - input = "something::{::}::\"nothing::\""; - assertEquals("lastIndex", 15, ParserUtils.lastIndexOf(input, "::")); - input = "{something::{::}::\"nothing::\"}"; - assertEquals("lastIndex", -1, ParserUtils.lastIndexOf(input, "::")); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/809d64d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorJUnitTest.java deleted file mode 100644 index 97325cb..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorJUnitTest.java +++ /dev/null @@ -1,296 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli.parser.preprocessor; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import org.apache.geode.test.junit.categories.UnitTest; - -/** - * Test for Preprocessor - */ -@Category(UnitTest.class) -public class PreprocessorJUnitTest { - - @Test - public void test1Arg() { - String input = "arg1"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 1, split.length); - assertEquals("First string", "arg1", split[0]); - } - - @Test - public void test2Args() { - String input = "arg1?arg2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "arg1", split[0]); - assertEquals("Second string", "arg2", split[1]); - } - - @Test - public void test1SpacedArg() { - String input = "arg1-1 arg1-2 "; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 1, split.length); - assertEquals("First string", "arg1-1 arg1-2", split[0]); - } - - @Test - public void test1SpacedArg1Option() { - String input = "arg1-1 arg1-2 --option1=value1"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "arg1-1 arg1-2", split[0]); - assertEquals("Second string", "--option1", split[1]); - assertEquals("Third string", "value1", split[2]); - } - - @Test - public void test1OptionNoValue() { - String input = "--option1"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 1, split.length); - assertEquals("First string", "--option1", split[0]); - } - - @Test - public void test2OptionsNoValue() { - String input = "--option1 --option2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "--option2", split[1]); - } - - @Test - public void test2Options1Value() { - String input = "--option1=value1 --option2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - assertEquals("Third string", "--option2", split[2]); - } - - @Test - public void test1OptionHasValue() { - String input = "--option1=value1"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - } - - @Test - public void test1Arg1OptionHasValue() { - String input = "arg1 --option1=value1"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "arg1", split[0]); - assertEquals("Second string", "--option1", split[1]); - assertEquals("Third string", "value1", split[2]); - } - - @Test - public void test1OptionMissingValue() { - String input = "--option1="; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "__NULL__", split[1]); - } - - @Test - public void test2OptionsMissingFirstValue() { - String input = "--option1= --option2=value2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "__NULL__", split[1]); - assertEquals("Third string", "--option2", split[2]); - assertEquals("Fourth string", "value2", split[3]); - } - - @Test - public void testSingleQuotedArg() { - String input = "\'arg1-1= arg1-2\'?arg2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "\'arg1-1= arg1-2\'", split[0]); - assertEquals("Second string", "arg2", split[1]); - } - - @Test - public void testDoubleQuotedArg() { - String input = "\" \'arg1-1 =arg1-2 \"?arg2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "\" \'arg1-1 =arg1-2 \"", split[0]); - assertEquals("Second string", "arg2", split[1]); - } - - @Test - public void testSingleQuotedOption() { - String input = "--option1=\'value1-1 =value1-2\"\' --option2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "\'value1-1 =value1-2\"\'", split[1]); - assertEquals("Third string", "--option2", split[2]); - } - - @Test - public void testDoubleQuotedOption() { - String input = "--option1= --option2=\"value2\""; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "__NULL__", split[1]); - assertEquals("Third string", "--option2", split[2]); - assertEquals("Fourth string", "\"value2\"", split[3]); - } - - @Test - public void testSingleQuoteInsideDoubleQuote() { - String input = "--option1=\" \' value1 \' \""; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "\" \' value1 \' \"", split[1]); - } - - @Test - public void testQuotedStringWithAdditonalData() { - String input = "--option1=\" \' value1 \' \",moreData,\" even more data\""; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "\" \' value1 \' \",moreData,\" even more data\"", - split[1]); - } - - @Test - public void testBadOption() { - String input = "--option1=value1 -option2=value2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - assertEquals("Third string", "-option2", split[2]); - assertEquals("Third string", "value2", split[3]); - } - - @Test - public void testBadOptions() { - String input = "--option1=value1 -option3 -option4"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - assertEquals("Third string", "-option3", split[2]); - assertEquals("Third string", "-option4", split[3]); - } - - @Test - public void testExtraArgSpaces() { - String input = " arg1? arg2 "; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "arg1", split[0]); - assertEquals("Second string", "arg2", split[1]); - } - - @Test - public void testExtraOptionSpaces() { - String input = " --option1=value1 --option2=value2 "; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 4, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - assertEquals("Third string", "--option2", split[2]); - assertEquals("Fourth string", "value2", split[3]); - } - - @Test - public void testExtraArgAndOptionSpaces() { - String input = " arg1 --option1=value1 "; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "arg1", split[0]); - assertEquals("Second string", "--option1", split[1]); - assertEquals("Third string", "value1", split[2]); - } - - @Test - public void testValueSpecifierAsPartOfValue() { - String input = "--option1=-Dprop1=value1 --option2=-Dprop2=value2 --option3"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 5, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "-Dprop1=value1", split[1]); - assertEquals("Third string", "--option2", split[2]); - assertEquals("Fourth string", "-Dprop2=value2", split[3]); - assertEquals("Fifth string", "--option3", split[4]); - } - - @Test - public void testMissingOption() { - String input = "--option1=value1 value2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 3, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "value1", split[1]); - assertEquals("Third string", "value2", split[2]); - } - - @Test - public void testUnclosedQuoteArg() { - String input = "\"arg1-1 arg1-2 --option1=value1 --option2=value2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 1, split.length); - assertEquals("First string", "\"arg1-1 arg1-2 --option1=value1 --option2=value2", split[0]); - } - - @Test - public void testUnclosedQuoteOption() { - String input = "--option1=\"value1 --option2=value2"; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second string", "\"value1 --option2=value2", split[1]); - } - - @Test - public void testArgWithQuotedLongOptionSpec() { - String input = "\"--arg=value\""; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 1, split.length); - assertEquals("First string", "\"--arg=value\"", split[0]); - } - - @Test - public void testOptionWithQuotedLongOptionSpec() { - String input = "--option1=\"--arg=value\""; - String[] split = Preprocessor.split(input); - assertEquals("Size of the split", 2, split.length); - assertEquals("First string", "--option1", split[0]); - assertEquals("Second", "\"--arg=value\"", split[1]); - } -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/809d64d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorUtilsJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorUtilsJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorUtilsJUnitTest.java deleted file mode 100644 index b56cff2..0000000 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/parser/preprocessor/PreprocessorUtilsJUnitTest.java +++ /dev/null @@ -1,121 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more contributor license - * agreements. See the NOTICE file distributed with this work for additional information regarding - * copyright ownership. The ASF licenses this file to You under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance with the License. You may obtain a - * copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License - * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express - * or implied. See the License for the specific language governing permissions and limitations under - * the License. - */ -package org.apache.geode.management.internal.cli.parser.preprocessor; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.experimental.categories.Category; - -import org.apache.geode.internal.lang.SystemUtils; -import org.apache.geode.test.junit.categories.UnitTest; - -/** - * Includes tests for all utility methods in {@link PreprocessorUtils} - */ -@Category(UnitTest.class) -public class PreprocessorUtilsJUnitTest { - - /** - * Test for {@link PreprocessorUtils#simpleTrim(String)} - */ - @Test - public void testSimpleTrim() { - String input = " 1 2 3 "; - TrimmedInput simpleTrim = PreprocessorUtils.simpleTrim(input); - assertEquals("No of spaces removed", 1, simpleTrim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "1 2 3", simpleTrim.getString()); - - input = " 1 2 3 "; - simpleTrim = PreprocessorUtils.simpleTrim(input); - assertEquals("No of spaces removed", 1, simpleTrim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "1 2 3", simpleTrim.getString()); - } - - /** - * Test for {@link PreprocessorUtils#trim(String)} - */ - @Test - public void testTrim() { - String input = " command argument1 argument2 "; - TrimmedInput trim = PreprocessorUtils.trim(input); - assertEquals("No of spaces removed", 1, trim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "command argument1 argument2", trim.getString()); - - input = " command argument1 argument2 "; - trim = PreprocessorUtils.trim(input); - assertEquals("No of spaces removed", 7, trim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "command argument1 argument2", trim.getString()); - - input = "command argument1 argument2 -- -- - - - -- -- -- -- -- --- --------- - - - --- --"; - trim = PreprocessorUtils.trim(input); - assertEquals("No of spaces removed", 0, trim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "command argument1 argument2", trim.getString()); - - input = "command argument1 argument2 --"; - trim = PreprocessorUtils.trim(input); - assertEquals("No of spaces removed", 0, trim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "command argument1 argument2", trim.getString()); - - input = "command argument1 argument2 -"; - trim = PreprocessorUtils.trim(input); - assertEquals("No of spaces removed", 0, trim.getNoOfSpacesRemoved()); - assertEquals("input after trimming", "command argument1 argument2", trim.getString()); - } - - /** - * Test for {@link PreprocessorUtils#removeWhiteSpaces(String)} - */ - @Test - public void testRemoveWhiteSpaces() { - String input = "1 2 3 "; - String output = PreprocessorUtils.removeWhiteSpaces(input); - assertEquals("Output after removing white spaces", "123", output); - } - - /** - * Test for {@link PreprocessorUtils#isSyntaxValid(String)} - */ - @Test - public void testIsSyntaxValid() { - assertTrue(PreprocessorUtils.isSyntaxValid("{}")); - assertFalse(PreprocessorUtils.isSyntaxValid("{{]}")); - assertTrue(PreprocessorUtils.isSyntaxValid("\"\"")); - assertTrue(PreprocessorUtils.isSyntaxValid("\"{\'[]\'}\"")); - assertFalse(PreprocessorUtils.isSyntaxValid("{\"}\"")); - } - - /** - * Test for {@link PreprocessorUtils#containsOnlyWhiteSpaces(String)} - */ - @Test - public void testContainsOnlyWhiteSpaces() { - assertTrue(PreprocessorUtils - .containsOnlyWhiteSpaces(" ")); - assertFalse(PreprocessorUtils.containsOnlyWhiteSpaces(" d ")); - } - - /** - * Test for {@link PreprocessorUtils#isWhitespace(char)} - */ - @Test - public void testIsWhitespace() { - assertTrue(PreprocessorUtils.isWhitespace(' ')); - assertTrue(PreprocessorUtils.isWhitespace('\t')); - assertTrue(PreprocessorUtils.isWhitespace('\n')); - assertEquals(SystemUtils.isWindows(), PreprocessorUtils.isWhitespace('\r')); - } - -} http://git-wip-us.apache.org/repos/asf/incubator-geode/blob/809d64d7/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java index 54c7cf7..aede3fc 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshExecutionStrategyJUnitTest.java @@ -14,22 +14,19 @@ */ package org.apache.geode.management.internal.cli.shell; -import static org.junit.Assert.*; - -import java.util.List; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertTrue; import org.apache.geode.management.cli.CliMetaData; import org.apache.geode.management.cli.ConverterHint; import org.apache.geode.management.cli.Result; import org.apache.geode.management.internal.cli.CommandManager; import org.apache.geode.management.internal.cli.GfshParser; -import org.apache.geode.management.internal.cli.annotation.CliArgument; import org.apache.geode.management.internal.cli.result.ResultBuilder; import org.apache.geode.management.internal.security.ResourceOperation; import org.apache.geode.security.ResourcePermission.Operation; import org.apache.geode.security.ResourcePermission.Resource; import org.apache.geode.test.junit.categories.UnitTest; - import org.junit.After; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -38,6 +35,8 @@ import org.springframework.shell.core.annotation.CliCommand; import org.springframework.shell.core.annotation.CliOption; import org.springframework.shell.event.ParseResult; +import java.util.List; + /** * GfshExecutionStrategyTest - Includes tests to for GfshExecutionStrategyTest */ @@ -66,7 +65,7 @@ public class GfshExecutionStrategyJUnitTest { commandManager.add(Commands.class.newInstance()); GfshParser parser = new GfshParser(commandManager); String[] command1Names = - ((CliCommand) Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class)) + Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class) .value(); String input = command1Names[0]; ParseResult parseResult = null; @@ -89,7 +88,7 @@ public class GfshExecutionStrategyJUnitTest { assertNotNull("CommandManager should not be null.", commandManager); commandManager.add(Commands.class.newInstance()); String[] command1Names = - ((CliCommand) Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class)) + Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class) .value(); String[] args = new String[] {command1Names[0]}; Gfsh gfsh = Gfsh.getInstance(false, args, new GfshConfig()); @@ -130,8 +129,8 @@ public class GfshExecutionStrategyJUnitTest { @CliCommand(value = {"testMultiWordArg"}) @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ) - public static Result testMultiWordArg(@CliArgument(name = "arg1") String arg1, - @CliArgument(name = "arg2") String arg2) { + public static Result testMultiWordArg(@CliOption(key = "arg1") String arg1, + @CliOption(key = "arg2") String arg2) { return null; } }
