BenjaminPerryRoss commented on a change in pull request #4818: URL: https://github.com/apache/geode/pull/4818#discussion_r412487003
########## File path: geode-gfsh/src/distributedTest/java/org/apache/geode/management/internal/cli/commands/ClearCommandDUnitTest.java ########## @@ -0,0 +1,130 @@ +/* + * 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 static org.apache.geode.management.internal.cli.commands.RemoveCommand.REGION_NOT_FOUND; +import static org.apache.geode.management.internal.i18n.CliStrings.REMOVE__MSG__CLEARED_ALL_KEYS; +import static org.assertj.core.api.Assertions.assertThat; + +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; + +import org.apache.geode.cache.Cache; +import org.apache.geode.cache.CacheFactory; +import org.apache.geode.cache.Region; +import org.apache.geode.management.internal.cli.util.CommandStringBuilder; +import org.apache.geode.management.internal.i18n.CliStrings; +import org.apache.geode.test.dunit.rules.ClusterStartupRule; +import org.apache.geode.test.dunit.rules.MemberVM; +import org.apache.geode.test.junit.rules.GfshCommandRule; +import org.apache.geode.test.junit.rules.VMProvider; + + +public class ClearCommandDUnitTest { + private static final String REPLICATE_REGION_NAME = "replicateRegion"; + private static final String PARTITIONED_REGION_NAME = "partitionedRegion"; + private static final String EMPTY_STRING = ""; + private static final int NUM_ENTRIES = 200; + + @Rule + public ClusterStartupRule clusterStartupRule = new ClusterStartupRule(); + + @Rule + public GfshCommandRule gfsh = new GfshCommandRule(); + + private MemberVM locator; + private MemberVM server1; + private MemberVM server2; + + @Before + public void setup() throws Exception { + locator = clusterStartupRule.startLocatorVM(0); + server1 = clusterStartupRule.startServerVM(1, locator.getPort()); + server2 = clusterStartupRule.startServerVM(2, locator.getPort()); + + gfsh.connectAndVerify(locator); + gfsh.executeAndAssertThat("create region --name=" + REPLICATE_REGION_NAME + " --type=REPLICATE") + .statusIsSuccess(); + gfsh.executeAndAssertThat( + "create region --name=" + PARTITIONED_REGION_NAME + " --type=PARTITION").statusIsSuccess(); + + locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + REPLICATE_REGION_NAME, 2); + locator.waitUntilRegionIsReadyOnExactlyThisManyServers("/" + PARTITIONED_REGION_NAME, 2); + + VMProvider.invokeInEveryMember(ClearCommandDUnitTest::populateTestRegions, server1, server2); + } + + private static void populateTestRegions() { + Cache cache = CacheFactory.getAnyInstance(); + + Region<String, String> replicateRegion = cache.getRegion(REPLICATE_REGION_NAME); + replicateRegion.put(EMPTY_STRING, "valueForEmptyKey"); Review comment: I was following the pattern set up by the Remove command (since they're very similar) for a lot of these choices and this is the pattern that was used in the DUnit tests for that command. With the value specifically I'm not sure it matters whether it's empty or not but it's easy to change if we think there's value. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org