http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/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..ece0c7e 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,125 +14,94 @@ */ package org.apache.geode.management.internal.cli.shell; -import static org.junit.Assert.*; - -import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.Matchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; 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.CommandRequest; +import org.apache.geode.management.internal.cli.CommandResponseBuilder; +import org.apache.geode.management.internal.cli.GfshParseResult; +import org.apache.geode.management.internal.cli.result.CommandResult; 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.Before; import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.shell.core.CommandMarker; -import org.springframework.shell.core.annotation.CliCommand; -import org.springframework.shell.core.annotation.CliOption; -import org.springframework.shell.event.ParseResult; /** * GfshExecutionStrategyTest - Includes tests to for GfshExecutionStrategyTest */ @Category(UnitTest.class) public class GfshExecutionStrategyJUnitTest { - - private static final String COMMAND1_NAME = "command1"; - private static final String COMMAND1_NAME_ALIAS = "command1_alias"; - private static final String COMMAND2_NAME = "command2"; private static final String COMMAND1_SUCESS = "Command1 Executed successfully"; private static final String COMMAND2_SUCESS = "Command2 Executed successfully"; - private static final String COMMAND1_HELP = "help for " + COMMAND1_NAME; - @After - public void tearDown() { - CommandManager.clearInstance(); + private Gfsh gfsh; + private GfshParseResult parsedCommand; + private GfshExecutionStrategy gfshExecutionStrategy; + + @Before + public void before() { + gfsh = mock(Gfsh.class); + parsedCommand = mock(GfshParseResult.class); + gfshExecutionStrategy = new GfshExecutionStrategy(gfsh); } /** - * tests execute method by executing dummy method command1 + * tests execute offline command */ @Test - public void testGfshExecutionStartegyExecute() throws Exception { - CommandManager commandManager = CommandManager.getInstance(); - assertNotNull("CommandManager should not be null.", commandManager); - commandManager.add(Commands.class.newInstance()); - GfshParser parser = new GfshParser(commandManager); - String[] command1Names = - ((CliCommand) Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class)) - .value(); - String input = command1Names[0]; - ParseResult parseResult = null; - parseResult = parser.parse(input); - String[] args = new String[] {command1Names[0]}; - Gfsh gfsh = Gfsh.getInstance(false, args, new GfshConfig()); - GfshExecutionStrategy gfshExecutionStrategy = new GfshExecutionStrategy(gfsh); - Result resultObject = (Result) gfshExecutionStrategy.execute(parseResult); - String str = resultObject.nextLine(); - assertTrue(str.trim().equals(COMMAND1_SUCESS)); + public void testOfflineCommand() throws Exception { + when(parsedCommand.getMethod()).thenReturn(Commands.class.getDeclaredMethod("offlineCommand")); + when(parsedCommand.getInstance()).thenReturn(new Commands()); + Result result = (Result) gfshExecutionStrategy.execute(parsedCommand); + assertThat(result.nextLine().trim()).isEqualTo(COMMAND1_SUCESS); } /** - * tests isReadyForCommnads method by executing dummy method command1. TODO: this method is hard - * coded in source which may change in future. So this test should also be accordingly changed + * tests execute online command */ @Test - public void testGfshExecutionStartegyIsReadyForCommands() throws Exception { - CommandManager commandManager = CommandManager.getInstance(); - assertNotNull("CommandManager should not be null.", commandManager); - commandManager.add(Commands.class.newInstance()); - String[] command1Names = - ((CliCommand) Commands.class.getMethod(COMMAND1_NAME).getAnnotation(CliCommand.class)) - .value(); - String[] args = new String[] {command1Names[0]}; - Gfsh gfsh = Gfsh.getInstance(false, args, new GfshConfig()); - GfshExecutionStrategy gfshExecutionStrategy = new GfshExecutionStrategy(gfsh); - boolean ready = gfshExecutionStrategy.isReadyForCommands(); - assertTrue(ready); + public void testOnLineCommandWhenGfshisOffLine() throws Exception { + when(parsedCommand.getMethod()).thenReturn(Commands.class.getDeclaredMethod("onlineCommand")); + when(parsedCommand.getInstance()).thenReturn(new Commands()); + when(gfsh.isConnectedAndReady()).thenReturn(false); + Result result = (Result) gfshExecutionStrategy.execute(parsedCommand); + assertThat(result).isNull(); + } + + @Test + public void testOnLineCommandWhenGfshisOnLine() throws Exception { + when(parsedCommand.getMethod()).thenReturn(Commands.class.getDeclaredMethod("onlineCommand")); + when(parsedCommand.getInstance()).thenReturn(new Commands()); + when(gfsh.isConnectedAndReady()).thenReturn(true); + OperationInvoker invoker = mock(OperationInvoker.class); + + Result offLineResult = new Commands().onlineCommand(); + String jsonResult = CommandResponseBuilder.createCommandResponseJson("memberName", + (CommandResult) offLineResult); + when(invoker.processCommand(any(CommandRequest.class))).thenReturn(jsonResult); + when(gfsh.getOperationInvoker()).thenReturn(invoker); + Result result = (Result) gfshExecutionStrategy.execute(parsedCommand); + assertThat(result.nextLine().trim()).isEqualTo(COMMAND2_SUCESS); } /** * represents class for dummy methods */ public static class Commands implements CommandMarker { - - @CliCommand(value = {COMMAND1_NAME, COMMAND1_NAME_ALIAS}, help = COMMAND1_HELP) @CliMetaData(shellOnly = true) - @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ) - public static Result command1() { + public Result offlineCommand() { return ResultBuilder.createInfoResult(COMMAND1_SUCESS); } - @CliCommand(value = {COMMAND2_NAME}) @CliMetaData(shellOnly = false) - @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ) - public static Result command2() { + public Result onlineCommand() { return ResultBuilder.createInfoResult(COMMAND2_SUCESS); } - - @CliCommand(value = {"testParamConcat"}) - @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ) - public static Result testParamConcat(@CliOption(key = {"string"}) String string, - @CliOption(key = {"stringArray"}) @CliMetaData(valueSeparator = ",") String[] stringArray, - @CliOption(key = {"stringList"}, optionContext = ConverterHint.STRING_LIST) @CliMetaData( - valueSeparator = ",") List<String> stringList, - @CliOption(key = {"integer"}) Integer integer, - @CliOption(key = {"colonArray"}) @CliMetaData(valueSeparator = ":") String[] colonArray) { - return null; - } - - @CliCommand(value = {"testMultiWordArg"}) - @ResourceOperation(resource = Resource.CLUSTER, operation = Operation.READ) - public static Result testMultiWordArg(@CliArgument(name = "arg1") String arg1, - @CliArgument(name = "arg2") String arg2) { - return null; - } } }
http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java index 58453b7..a563c65 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshHistoryJUnitTest.java @@ -14,13 +14,10 @@ */ package org.apache.geode.management.internal.cli.shell; -import static org.junit.Assert.*; - -import java.io.File; -import java.lang.reflect.Field; -import java.nio.file.Files; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import org.apache.geode.test.junit.categories.IntegrationTest; import org.junit.After; import org.junit.Before; import org.junit.Rule; @@ -28,7 +25,10 @@ import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.rules.TemporaryFolder; -import org.apache.geode.test.junit.categories.IntegrationTest; +import java.io.File; +import java.lang.reflect.Field; +import java.nio.file.Files; +import java.util.List; @Category(IntegrationTest.class) public class GfshHistoryJUnitTest { @@ -65,29 +65,26 @@ public class GfshHistoryJUnitTest { @Test public void testHistoryFileIsCreated() throws Exception { Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); - gfsh.executeScriptLine("connect --fake-param=foo"); + gfsh.executeScriptLine("connect"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); assertEquals(2, lines.size()); - assertEquals(lines.get(1), "connect --fake-param=foo"); + assertEquals(lines.get(1), "connect"); } @Test public void testHistoryFileDoesNotContainPasswords() throws Exception { Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); - gfsh.executeScriptLine( - "connect --password=foo --password = foo --password= goo --password =goo --password-param=blah --other-password-param= gah"); + gfsh.executeScriptLine("connect --password=foo"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); - assertEquals( - "connect --password=***** --password = ***** --password= ***** --password =***** --password-param=***** --other-password-param= *****", - lines.get(1)); + assertEquals("connect --password=*****", lines.get(1)); } @Test public void testClearHistory() throws Exception { Gfsh gfsh = Gfsh.getInstance(false, new String[] {}, gfshConfig); - gfsh.executeScriptLine("connect --fake-param=foo"); + gfsh.executeScriptLine("connect"); List<String> lines = Files.readAllLines(gfshHistoryFile.toPath()); assertEquals(2, lines.size()); http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshJunitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshJunitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshJunitTest.java new file mode 100644 index 0000000..2a9c0d0 --- /dev/null +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshJunitTest.java @@ -0,0 +1,45 @@ +/* + * 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.shell; + +import static org.assertj.core.api.Assertions.assertThat; + +import org.apache.geode.test.junit.categories.UnitTest; +import org.junit.Before; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +@Category(UnitTest.class) +public class GfshJunitTest { + private String testString; + + @Before + public void before() { + testString = "This is a test string."; + } + + @Test + public void testWrapTest() { + assertThat(Gfsh.wrapText(testString, 0, -1)).isEqualTo(testString); + assertThat(Gfsh.wrapText(testString, 0, 0)).isEqualTo(testString); + assertThat(Gfsh.wrapText(testString, 0, 1)).isEqualTo(testString); + assertThat(Gfsh.wrapText(testString, 0, 10)).isEqualTo("This is a\ntest\nstring."); + assertThat(Gfsh.wrapText(testString, 1, 100)).isEqualTo(Gfsh.LINE_INDENT + testString); + assertThat(Gfsh.wrapText(testString, 2, 100)) + .isEqualTo(Gfsh.LINE_INDENT + Gfsh.LINE_INDENT + testString); + } + +} http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java index abbc5c0..5dc77aa 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDistributionDUnitTest.java @@ -86,7 +86,7 @@ public class ClusterConfigDistributionDUnitTest { String asyncEventQueueJarPath = createAsyncEventQueueJar(); - gfshConnector.executeAndVerifyCommand("deploy jar --jar=" + asyncEventQueueJarPath); + gfshConnector.executeAndVerifyCommand("deploy --jar=" + asyncEventQueueJarPath); CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE); @@ -166,7 +166,6 @@ public class ClusterConfigDistributionDUnitTest { CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CONFIGURE_PDX); csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__AUTO__SERIALIZER__CLASSES, "com.foo.*"); csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, "true"); - csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__PERSISTENT, "true"); csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, "true"); String message = gfshConnector.execute(csb.getCommandString()); http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java ---------------------------------------------------------------------- diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java index ffe6a28..3f8f4d9 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/TestCommand.java @@ -14,12 +14,12 @@ */ package org.apache.geode.management.internal.security; -import java.util.ArrayList; -import java.util.List; - import org.apache.geode.security.ResourcePermission; import org.apache.shiro.authz.Permission; +import java.util.ArrayList; +import java.util.List; + public class TestCommand { public static ResourcePermission none = null; @@ -142,7 +142,7 @@ public class TestCommand { // FunctionCommands // createTestCommand("destroy function --id=InterestCalculations", dataManage); - createTestCommand("execute function --id=InterestCalculations --group=Group1", dataWrite); + createTestCommand("execute function --id=InterestCalculations --groups=Group1", dataWrite); createTestCommand("list functions", clusterRead); // GfshHelpCommands @@ -178,7 +178,7 @@ public class TestCommand { createTestCommand("list members", clusterRead); // Misc Commands - createTestCommand("change loglevel --loglevel=severe --member=server1", clusterWrite); + createTestCommand("change loglevel --loglevel=severe --members=server1", clusterWrite); createTestCommand("export logs --dir=data/logs", clusterRead); createTestCommand("export stack-traces --file=stack.txt", clusterRead); createTestCommand("gc", clusterManage); http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java index 4bfa868..3756b81 100755 --- a/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java +++ b/geode-lucene/src/main/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommands.java @@ -17,12 +17,18 @@ package org.apache.geode.cache.lucene.internal.cli; import org.apache.geode.SystemFailure; import org.apache.geode.cache.Cache; import org.apache.geode.cache.Region; -import org.apache.geode.cache.execute.*; -import org.apache.geode.cache.lucene.internal.cli.functions.*; +import org.apache.geode.cache.execute.Execution; +import org.apache.geode.cache.execute.Function; +import org.apache.geode.cache.execute.FunctionInvocationTargetException; +import org.apache.geode.cache.execute.ResultCollector; +import org.apache.geode.cache.lucene.internal.cli.functions.LuceneCreateIndexFunction; +import org.apache.geode.cache.lucene.internal.cli.functions.LuceneDescribeIndexFunction; +import org.apache.geode.cache.lucene.internal.cli.functions.LuceneDestroyIndexFunction; +import org.apache.geode.cache.lucene.internal.cli.functions.LuceneListIndexFunction; +import org.apache.geode.cache.lucene.internal.cli.functions.LuceneSearchIndexFunction; import org.apache.geode.distributed.DistributedMember; import org.apache.geode.internal.cache.execute.AbstractExecution; import org.apache.geode.internal.lang.StringUtils; -import org.apache.geode.internal.logging.LogService; import org.apache.geode.internal.security.IntegratedSecurityService; import org.apache.geode.internal.security.SecurityService; import org.apache.geode.management.cli.CliMetaData; @@ -170,13 +176,11 @@ public class LuceneIndexCommands extends AbstractCommandsSupport { help = LuceneCliStrings.LUCENE_CREATE_INDEX__REGION_HELP) final String regionPath, @CliOption(key = LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, mandatory = true, - help = LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD_HELP) @CliMetaData( - valueSeparator = ",") final String[] fields, + help = LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD_HELP) final String[] fields, @CliOption(key = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, mandatory = false, unspecifiedDefaultValue = CliMetaData.ANNOTATION_NULL_VALUE, - help = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER_HELP) @CliMetaData( - valueSeparator = ",") final String[] analyzers) { + help = LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER_HELP) final String[] analyzers) { Result result = null; XmlEntity xmlEntity = null; http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java index ad734e8..423fc59 100644 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/LuceneCommandsSecurityDUnitTest.java @@ -14,20 +14,21 @@ */ package org.apache.geode.cache.lucene; -import junitparams.JUnitParamsRunner; -import junitparams.Parameters; +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME; +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME; +import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings; -import org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands; import org.apache.geode.management.cli.Result; -import org.apache.geode.management.internal.cli.CommandManager; import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.result.ErrorResultData; import org.apache.geode.management.internal.cli.result.ResultBuilder; import org.apache.geode.management.internal.cli.util.CommandStringBuilder; import org.apache.geode.security.SimpleTestSecurityManager; -import org.apache.geode.test.dunit.cache.internal.JUnit4CacheTestCase; import org.apache.geode.test.dunit.rules.GfshShellConnectionRule; import org.apache.geode.test.dunit.rules.LocatorServerStartupRule; import org.apache.geode.test.dunit.rules.MemberVM; @@ -41,16 +42,12 @@ import org.junit.runner.RunWith; import java.io.Serializable; import java.util.Properties; - -import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME; -import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME; -import static org.apache.geode.distributed.ConfigurationProperties.SECURITY_MANAGER; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import junitparams.JUnitParamsRunner; +import junitparams.Parameters; @Category({DistributedTest.class, SecurityTest.class}) @RunWith(JUnitParamsRunner.class) -public class LuceneCommandsSecurityDUnitTest extends JUnit4CacheTestCase { +public class LuceneCommandsSecurityDUnitTest { @Rule public LocatorServerStartupRule locatorServer = new LocatorServerStartupRule(); @@ -190,7 +187,6 @@ public class LuceneCommandsSecurityDUnitTest extends JUnit4CacheTestCase { } private String getCreateIndexCommand() throws Exception { - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -207,7 +203,6 @@ public class LuceneCommandsSecurityDUnitTest extends JUnit4CacheTestCase { } private String getSearchIndexCommand() throws Exception { - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -229,7 +224,6 @@ public class LuceneCommandsSecurityDUnitTest extends JUnit4CacheTestCase { } private String getDestroyIndexCommand() throws Exception { - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java index 7f203ce..9e7b152 100755 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/cli/LuceneIndexCommandsDUnitTest.java @@ -14,8 +14,16 @@ */ package org.apache.geode.cache.lucene.internal.cli; -import junitparams.Parameters; -import org.apache.geode.cache.*; +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.INDEX_NAME; +import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.REGION_NAME; +import static org.apache.geode.test.dunit.Assert.assertArrayEquals; +import static org.apache.geode.test.dunit.Assert.assertEquals; +import static org.apache.geode.test.dunit.Assert.assertFalse; +import static org.apache.geode.test.dunit.Assert.assertTrue; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.Region; +import org.apache.geode.cache.RegionShortcut; import org.apache.geode.cache.lucene.LuceneIndex; import org.apache.geode.cache.lucene.LuceneQuery; import org.apache.geode.cache.lucene.LuceneService; @@ -25,28 +33,23 @@ import org.apache.geode.cache.lucene.internal.LuceneIndexImpl; import org.apache.geode.cache.lucene.internal.LuceneServiceImpl; import org.apache.geode.internal.i18n.LocalizedStrings; import org.apache.geode.management.cli.Result.Status; -import org.apache.geode.management.internal.cli.CommandManager; import org.apache.geode.management.internal.cli.commands.CliCommandTestBase; import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.result.TabularResultData; import org.apache.geode.management.internal.cli.util.CommandStringBuilder; -import org.apache.geode.test.dunit.*; +import org.apache.geode.test.dunit.Host; +import org.apache.geode.test.dunit.VM; import org.apache.geode.test.junit.categories.DistributedTest; -import org.awaitility.Awaitility; - import org.apache.lucene.analysis.Analyzer; import org.apache.lucene.analysis.core.KeywordAnalyzer; import org.apache.lucene.analysis.standard.StandardAnalyzer; +import org.awaitility.Awaitility; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.experimental.categories.Category; import org.junit.runner.RunWith; -import static org.apache.geode.cache.lucene.test.LuceneTestUtilities.*; -import static org.apache.geode.test.dunit.Assert.*; - import java.io.Serializable; import java.util.ArrayList; import java.util.Collections; @@ -54,8 +57,8 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.TimeUnit; - import junitparams.JUnitParamsRunner; +import junitparams.Parameters; @Category(DistributedTest.class) @RunWith(JUnitParamsRunner.class) @@ -73,7 +76,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { final VM vm1 = Host.getHost(0).getVM(1); createIndex(vm1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX); csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true"); @@ -87,7 +89,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { final VM vm1 = Host.getHost(0).getVM(1); createIndex(vm1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX); String resultAsString = executeCommandAndLogResult(csb); @@ -99,8 +100,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { public void listIndexWhenNoExistingIndexShouldReturnNoIndex() throws Exception { final VM vm1 = Host.getHost(0).getVM(1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); - CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX); String resultAsString = executeCommandAndLogResult(csb); assertTrue(resultAsString.contains("No lucene indexes found")); @@ -111,7 +110,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { final VM vm1 = Host.getHost(0).getVM(1); createIndexWithoutRegion(vm1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX); csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true"); @@ -152,8 +150,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { getCache(); }); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); - CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -176,8 +172,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { getCache(); }); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); - List<String> analyzerNames = new ArrayList<>(); analyzerNames.add(StandardAnalyzer.class.getCanonicalName()); analyzerNames.add(KeywordAnalyzer.class.getCanonicalName()); @@ -210,8 +204,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { getCache(); }); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); - CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -235,7 +227,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { getCache(); }); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); String analyzerList = StandardAnalyzer.class.getCanonicalName() + ",null," + KeywordAnalyzer.class.getCanonicalName(); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); @@ -265,7 +256,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { final VM vm1 = Host.getHost(0).getVM(1); createIndex(vm1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); @@ -279,7 +269,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { final VM vm1 = Host.getHost(0).getVM(1); createIndex(vm1); - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "notAnIndex"); @@ -560,7 +549,6 @@ public class LuceneIndexCommandsDUnitTest extends CliCommandTestBase { private CommandResult createAndExecuteDestroyIndexCommand(String indexName, String regionPath) throws Exception { - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX); if (indexName != null) { csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName); http://git-wip-us.apache.org/repos/asf/geode/blob/1fc0f0ca/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java ---------------------------------------------------------------------- diff --git a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java index a0ac52f..7acff1b 100755 --- a/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java +++ b/geode-lucene/src/test/java/org/apache/geode/cache/lucene/internal/configuration/LuceneClusterConfigurationDUnitTest.java @@ -21,7 +21,6 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; import org.apache.geode.cache.RegionShortcut; @@ -29,11 +28,9 @@ import org.apache.geode.cache.lucene.LuceneIndex; import org.apache.geode.cache.lucene.LuceneService; import org.apache.geode.cache.lucene.LuceneServiceProvider; import org.apache.geode.cache.lucene.internal.cli.LuceneCliStrings; -import org.apache.geode.cache.lucene.internal.cli.LuceneIndexCommands; import org.apache.geode.cache.lucene.internal.xml.LuceneXmlConstants; import org.apache.geode.distributed.internal.ClusterConfigurationService; import org.apache.geode.distributed.internal.InternalLocator; -import org.apache.geode.management.internal.cli.CommandManager; import org.apache.geode.management.internal.cli.i18n.CliStrings; import org.apache.geode.management.internal.cli.result.CommandResult; import org.apache.geode.management.internal.cli.result.TabularResultData; @@ -259,7 +256,6 @@ public class LuceneClusterConfigurationDUnitTest { private void createLuceneIndexUsingGfsh(String indexName) throws Exception { // Execute Gfsh command to create lucene index. - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -269,7 +265,6 @@ public class LuceneClusterConfigurationDUnitTest { private void createLuceneIndexWithAnalyzerUsingGfsh(boolean addGroup) throws Exception { // Gfsh command to create lucene index. - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX); csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME); csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME); @@ -285,7 +280,6 @@ public class LuceneClusterConfigurationDUnitTest { private void destroyLuceneIndexUsingGfsh(String indexName) throws Exception { // Execute Gfsh command to destroy lucene index. - CommandManager.getInstance().add(LuceneIndexCommands.class.newInstance()); CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESTROY_INDEX); if (indexName != null) { csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName);
