diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java index 842802ba7b7e..bf22854ddd66 100644 --- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java +++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateAlterDestroyRegionCommands.java @@ -14,7 +14,28 @@ */ package org.apache.geode.management.internal.cli.commands; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; +import java.util.TreeSet; +import java.util.concurrent.atomic.AtomicReference; +import java.util.regex.Pattern; + +import javax.management.MBeanServer; +import javax.management.MalformedObjectNameException; +import javax.management.ObjectName; + import org.apache.commons.lang.StringUtils; +import org.springframework.shell.core.annotation.CliCommand; +import org.springframework.shell.core.annotation.CliOption; + import org.apache.geode.LogWriter; import org.apache.geode.cache.DataPolicy; import org.apache.geode.cache.ExpirationAttributes; @@ -58,26 +79,6 @@ import org.apache.geode.management.internal.security.ResourceOperation; import org.apache.geode.security.ResourcePermission.Operation; import org.apache.geode.security.ResourcePermission.Resource; -import org.springframework.shell.core.annotation.CliAvailabilityIndicator; -import org.springframework.shell.core.annotation.CliCommand; -import org.springframework.shell.core.annotation.CliOption; - -import java.text.MessageFormat; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; -import java.util.TreeSet; -import java.util.concurrent.atomic.AtomicReference; -import java.util.regex.Pattern; -import javax.management.MBeanServer; -import javax.management.MalformedObjectNameException; -import javax.management.ObjectName; /** * @since GemFire 7.0 @@ -408,9 +409,9 @@ public Result alterRegion( help = CliStrings.ALTER_REGION__REGIONEXPIRATIONTTLACTION__HELP) String regionExpirationTTLAction, @CliOption(key = CliStrings.ALTER_REGION__CACHELISTENER, specifiedDefaultValue = "", help = CliStrings.ALTER_REGION__CACHELISTENER__HELP) String[] cacheListeners, - @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "null", + @CliOption(key = CliStrings.ALTER_REGION__CACHELOADER, specifiedDefaultValue = "", help = CliStrings.ALTER_REGION__CACHELOADER__HELP) String cacheLoader, - @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "null", + @CliOption(key = CliStrings.ALTER_REGION__CACHEWRITER, specifiedDefaultValue = "", help = CliStrings.ALTER_REGION__CACHEWRITER__HELP) String cacheWriter, @CliOption(key = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID, specifiedDefaultValue = "", help = CliStrings.ALTER_REGION__ASYNCEVENTQUEUEID__HELP) String[] asyncEventQueueIds, diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java index 47d150d180da..961cdf87f883 100644 --- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java +++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/GfshParserParsingTest.java @@ -17,15 +17,16 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.junit.Assert.assertEquals; -import org.apache.geode.management.internal.cli.i18n.CliStrings; -import org.apache.geode.test.dunit.rules.GfshParserRule; -import org.apache.geode.test.junit.categories.IntegrationTest; +import java.util.Map; + import org.junit.ClassRule; import org.junit.Test; import org.junit.experimental.categories.Category; import org.springframework.shell.event.ParseResult; -import java.util.Map; +import org.apache.geode.management.internal.cli.i18n.CliStrings; +import org.apache.geode.test.dunit.rules.GfshParserRule; +import org.apache.geode.test.junit.categories.IntegrationTest; @Category(IntegrationTest.class) public class GfshParserParsingTest { @@ -290,4 +291,14 @@ public void testCommandWithBackSlashFour() throws Exception { GfshParseResult result = parser.parse(command); assertThat(result.getParamValue("name")).isEqualTo("\\u0005Name"); } + + @Test + public void testAlterRegion() throws Exception { + String command = + "alter region --name=/Person --cache-writer='' --cache-listener='' --cache-loader=''"; + GfshParseResult result = parser.parse(command); + assertThat(result.getParamValue("cache-writer")).isNotNull().isEmpty(); + assertThat(result.getParamValue("cache-listener")).isNotNull().isEmpty(); + assertThat(result.getParamValue("cache-loader")).isNotNull().isEmpty(); + } }