You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by js...@apache.org on 2017/10/27 21:21:14 UTC
[geode] branch develop updated: GEODE-3872: Consolidate
GfshShellConnectionRule Assertions
This is an automated email from the ASF dual-hosted git repository.
jstewart pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push:
new 529f6c5 GEODE-3872: Consolidate GfshShellConnectionRule Assertions
529f6c5 is described below
commit 529f6c5b46dccda8d8925eeb8c373a08cd6ce7db
Author: Jared Stewart <js...@pivotal.io>
AuthorDate: Fri Oct 27 14:20:10 2017 -0700
GEODE-3872: Consolidate GfshShellConnectionRule Assertions
This closes #978.
---
.../session/tests/TomcatClientServerTest.java | 4 +-
.../TomcatSessionBackwardsCompatibilityTest.java | 8 +-
.../internal/cli/commands/CreateRegionCommand.java | 3 +-
.../ExtensionClusterConfigurationDUnitTest.java | 14 +-
.../management/internal/cli/NetstatDUnitTest.java | 12 +-
.../AlterRegionCommandIntegrationTest.java | 20 +-
.../commands/ChangeLogLevelCommandDUnitTest.java | 8 +-
.../cli/commands/ConcurrentDeployDUnitTest.java | 6 +-
.../cli/commands/CreateRegionCommandDUnitTest.java | 39 ++--
.../CreateRegionCommandIntegrationTest.java | 220 +++++++++----------
...DeployCommandFunctionRegistrationDUnitTest.java | 6 +-
.../commands/DeployCommandRedeployDUnitTest.java | 18 +-
.../cli/commands/DeployWithGroupsDUnitTest.java | 62 +++---
.../commands/DescribeConfigCommandJUnitTest.java | 31 ++-
.../commands/DescribeMembersCommandDUnitTest.java | 25 +--
.../commands/DestroyRegionCommandDUnitTest.java | 32 +--
.../ExecuteFunctionCommandSecurityTest.java | 44 ++--
.../cli/commands/ExportDataIntegrationTest.java | 4 +-
.../internal/cli/commands/ExportLogsDUnitTest.java | 14 +-
.../commands/ExportLogsOnServerManagerDUnit.java | 4 +-
.../cli/commands/ExportLogsStatsDUnitTest.java | 10 +-
.../ExportLogsWithMemberGroupDUnitTest.java | 6 +-
.../cli/commands/FunctionCommandsDUnitTest.java | 118 ++++++-----
.../internal/cli/commands/GcCommandDUnitTest.java | 6 +-
.../cli/commands/GetCommandIntegrationTest.java | 14 +-
.../cli/commands/GfshCommandIntegrationTest.java | 6 +-
.../cli/commands/ImportDataIntegrationTest.java | 12 +-
.../cli/commands/IndexCommandsIntegrationTest.java | 32 +--
.../IndexCommandsShareConfigurationDUnitTest.java | 6 +-
.../commands/ListAndDescribeRegionDUnitTest.java | 71 ++-----
.../cli/commands/ListIndexCommandDUnitTest.java | 20 +-
.../cli/commands/ListMembersCommandDUnitTest.java | 14 +-
.../cli/commands/PutCommandIntegrationTest.java | 6 +-
.../internal/cli/commands/QueryCommandTest.java | 105 ++++------
.../cli/commands/RemoveCommandDUnitTest.java | 24 +--
.../cli/commands/RemoveCommandJsonDUnitTest.java | 6 +-
.../cli/commands/ShowDeadlockDUnitTest.java | 4 +-
.../cli/commands/ShowLogCommandDUnitTest.java | 4 +-
.../cli/commands/ShowMetricsDUnitTest.java | 27 +--
.../commands/ShowMissingDiskStoresDUnitTest.java | 6 +-
.../cli/commands/ShutdownCommandDUnitTest.java | 6 +-
.../cli/shell/GfshMultilineCommandTest.java | 4 +-
.../ClusterConfigDeployJarDUnitTest.java | 32 +--
.../ClusterConfigDistributionDUnitTest.java | 39 ++--
.../ClusterConfigImportDUnitTest.java | 18 +-
.../ClusterConfigWithSecurityDUnitTest.java | 6 +-
.../ImportClusterConfigDistributedTest.java | 15 +-
.../ImportOldClusterConfigDUnitTest.java | 6 +-
.../security/GfshCommandsPostProcessorTest.java | 12 +-
.../security/GfshCommandsSecurityTest.java | 4 +-
.../PDXGfshPostProcessorOnRemoteServerTest.java | 7 +-
.../geode/security/PDXPostProcessorDUnitTest.java | 9 +-
.../assertions/GfshShellConnectionRuleAssert.java | 232 +++++++++++++++++++++
.../GfshShellConnectionRuleExecution.java | 33 ++-
.../test/junit/rules/GfshShellConnectionRule.java | 28 +--
.../lucene/LuceneCommandsSecurityDUnitTest.java | 4 +-
.../internal/cli/LuceneIndexCommandsDUnitTest.java | 153 +++++++-------
.../LuceneClusterConfigurationDUnitTest.java | 52 ++---
...rConfigurationIndexWithFromClauseDUnitTest.java | 8 +-
.../WANClusterConfigurationDUnitTest.java | 4 +-
.../cli/commands/AlterRuntimeCommandDUnitTest.java | 42 ++--
.../commands/ClusterConfigurationDUnitTest.java | 19 +-
.../internal/cli/commands/CommandOverHttpTest.java | 13 +-
.../commands/ConnectCommandWithSecurityTest.java | 6 +-
.../commands/DescribeConfigCommandDUnitTest.java | 9 +-
...xecuteFunctionCommandWithSecurityDUnitTest.java | 6 +-
.../cli/commands/ExportConfigCommandDUnitTest.java | 9 +-
.../FunctionCommandsOverHttpDUnitTest.java | 3 +-
.../internal/security/LogNoPasswordTest.java | 2 +-
69 files changed, 1016 insertions(+), 836 deletions(-)
diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatClientServerTest.java b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatClientServerTest.java
index 326922a..5a2c4b0 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatClientServerTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatClientServerTest.java
@@ -69,7 +69,7 @@ public abstract class TomcatClientServerTest extends CargoTestBase {
command.addOption(CliStrings.START_SERVER__J, "-Dgemfire.member-timeout=60000");
// Start server
- gfsh.executeAndVerifyCommand(command.toString());
+ gfsh.executeAndAssertThat(command.toString()).statusIsSuccess();
}
/**
@@ -79,6 +79,6 @@ public abstract class TomcatClientServerTest extends CargoTestBase {
public void stopServer() throws Exception {
CommandStringBuilder command = new CommandStringBuilder(CliStrings.STOP_SERVER);
command.addOption(CliStrings.STOP_SERVER__DIR, serverName);
- gfsh.executeAndVerifyCommand(command.toString());
+ gfsh.executeAndAssertThat(command.toString()).statusIsSuccess();
}
}
diff --git a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
index 950e9fd..7aa50c0 100644
--- a/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
+++ b/geode-assembly/src/test/java/org/apache/geode/session/tests/TomcatSessionBackwardsCompatibilityTest.java
@@ -97,7 +97,7 @@ public class TomcatSessionBackwardsCompatibilityTest {
command.addOption(CliStrings.START_SERVER__SERVER_PORT, "0");
command.addOption(CliStrings.START_SERVER__CLASSPATH, classPath);
command.addOption(CliStrings.START_SERVER__LOCATORS, "localhost[" + locatorPort + "]");
- gfsh.executeAndVerifyCommand(command.toString());
+ gfsh.executeAndAssertThat(command.toString()).statusIsSuccess();
}
protected void startLocator(String name, String classPath, int port) throws Exception {
@@ -105,7 +105,7 @@ public class TomcatSessionBackwardsCompatibilityTest {
locStarter.addOption(CliStrings.START_LOCATOR__MEMBER_NAME, name);
locStarter.addOption(CliStrings.START_LOCATOR__CLASSPATH, classPath);
locStarter.addOption(CliStrings.START_LOCATOR__PORT, Integer.toString(port));
- gfsh.executeAndVerifyCommand(locStarter.toString());
+ gfsh.executeAndAssertThat(locStarter.toString()).statusIsSuccess();
}
@@ -165,11 +165,11 @@ public class TomcatSessionBackwardsCompatibilityTest {
CommandStringBuilder locStop = new CommandStringBuilder(CliStrings.STOP_LOCATOR);
locStop.addOption(CliStrings.STOP_LOCATOR__DIR, "loc");
- gfsh.executeAndVerifyCommand(locStop.toString());
+ gfsh.executeAndAssertThat(locStop.toString()).statusIsSuccess();
CommandStringBuilder command = new CommandStringBuilder(CliStrings.STOP_SERVER);
command.addOption(CliStrings.STOP_SERVER__DIR, "server");
- gfsh.executeAndVerifyCommand(command.toString());
+ gfsh.executeAndAssertThat(command.toString()).statusIsSuccess();
}
private void doPutAndGetSessionOnAllClients() throws IOException, URISyntaxException {
diff --git a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
index 58a6f97..0555ad5 100644
--- a/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
+++ b/geode-core/src/main/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommand.java
@@ -329,8 +329,7 @@ public class CreateRegionCommand implements GfshCommand {
return ResultBuilder.createUserErrorResult(CliStrings.NO_MEMBERS_FOUND_MESSAGE);
} else {
return ResultBuilder.createUserErrorResult(
- CliStrings.format(CliStrings.CREATE_REGION__MSG__GROUPS_0_ARE_INVALID,
- new Object[] {String.valueOf(groups)}));
+ CliStrings.format(CliStrings.CREATE_REGION__MSG__GROUPS_0_ARE_INVALID, groups));
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/internal/cache/extension/ExtensionClusterConfigurationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/cache/extension/ExtensionClusterConfigurationDUnitTest.java
index 5bcf04f..02ac966 100644
--- a/geode-core/src/test/java/org/apache/geode/internal/cache/extension/ExtensionClusterConfigurationDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/internal/cache/extension/ExtensionClusterConfigurationDUnitTest.java
@@ -169,7 +169,7 @@ public class ExtensionClusterConfigurationDUnitTest {
csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
csb.addOptionWithValueCheck(CliStrings.GROUP, group);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createMockRegionExtension(final String regionName, final String value) {
@@ -177,7 +177,7 @@ public class ExtensionClusterConfigurationDUnitTest {
new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_REGION_EXTENSION);
csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName);
csb.addOption(MockExtensionCommands.OPTION_VALUE, value);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void alterMockRegionExtension(final String regionName, final String value) {
@@ -185,33 +185,33 @@ public class ExtensionClusterConfigurationDUnitTest {
new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_REGION_EXTENSION);
csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName);
csb.addOption(MockExtensionCommands.OPTION_VALUE, value);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void destroyMockRegionExtension(final String regionName) {
CommandStringBuilder csb =
new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_REGION_EXTENSION);
csb.addOption(MockExtensionCommands.OPTION_REGION_NAME, regionName);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createMockCacheExtension(final String value) {
CommandStringBuilder csb =
new CommandStringBuilder(MockExtensionCommands.CREATE_MOCK_CACHE_EXTENSION);
csb.addOption(MockExtensionCommands.OPTION_VALUE, value);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void alterMockCacheExtension(final String value) {
CommandStringBuilder csb =
new CommandStringBuilder(MockExtensionCommands.ALTER_MOCK_CACHE_EXTENSION);
csb.addOption(MockExtensionCommands.OPTION_VALUE, value);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void destroyMockCacheExtension() {
CommandStringBuilder csb =
new CommandStringBuilder(MockExtensionCommands.DESTROY_MOCK_CACHE_EXTENSION);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
index 80d92e9..20ef3be 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/NetstatDUnitTest.java
@@ -76,40 +76,40 @@ public class NetstatDUnitTest {
@Test
public void testConnectToLocator() throws Exception {
gfshConnector.connect(ports[0], GfshShellConnectionRule.PortType.locator);
- gfshConnector.executeAndVerifyCommand(netStatCommand);
+ gfshConnector.executeAndAssertThat(netStatCommand).statusIsSuccess();
}
@Test
public void testConnectToJmxManagerOne() throws Exception {
gfshConnector.connect(ports[1], GfshShellConnectionRule.PortType.jmxManager);
- gfshConnector.executeAndVerifyCommand(netStatCommand);
+ gfshConnector.executeAndAssertThat(netStatCommand).statusIsSuccess();
}
@Test
public void testConnectToJmxManagerTwo() throws Exception {
gfshConnector.connect(ports[2], GfshShellConnectionRule.PortType.jmxManager);
- gfshConnector.executeAndVerifyCommand(netStatCommand);
+ gfshConnector.executeAndAssertThat(netStatCommand).statusIsSuccess();
}
@Ignore("GEODE-2488")
@Test
public void testConnectToLocatorWithLargeCommandResponse() throws Exception {
gfshConnector.connect(ports[0], GfshShellConnectionRule.PortType.locator);
- gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+ gfshConnector.executeAndAssertThat(netStatLsofCommand).statusIsSuccess();
}
@Ignore("GEODE-2488")
@Test
public void testConnectToJmxManagerOneWithLargeCommandResponse() throws Exception {
gfshConnector.connect(ports[1], GfshShellConnectionRule.PortType.jmxManager);
- gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+ gfshConnector.executeAndAssertThat(netStatLsofCommand).statusIsSuccess();
}
@Ignore("GEODE-2488")
@Test
public void testConnectToJmxManagerTwoWithLargeCommandResponse() throws Exception {
gfshConnector.connect(ports[2], GfshShellConnectionRule.PortType.jmxManager);
- gfshConnector.executeAndVerifyCommand(netStatLsofCommand);
+ gfshConnector.executeAndAssertThat(netStatLsofCommand).statusIsSuccess();
}
@After
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandIntegrationTest.java
index d312c26..44aa4e1 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRegionCommandIntegrationTest.java
@@ -41,31 +41,31 @@ public class AlterRegionCommandIntegrationTest {
@Test
public void validateGroup() throws Exception {
- gfsh.executeAndVerifyCommandError("alter region --name=/REPLICATED --group=unknown",
- "Group\\(s\\) \"\\[unknown\\]\" are invalid.");
+ gfsh.executeAndAssertThat("alter region --name=/REPLICATED --group=unknown").statusIsError()
+ .containsOutput("Group(s) \"[unknown]\" are invalid.");
}
@Test
public void invalidCacheListener() throws Exception {
- gfsh.executeAndVerifyCommandError("alter region --name=/REPLICATED --cache-listener=abc-def",
- "Specify a valid class name for cache-listener");
+ gfsh.executeAndAssertThat("alter region --name=/REPLICATED --cache-listener=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-listener");
}
@Test
public void invalidCacheLoader() throws Exception {
- gfsh.executeAndVerifyCommandError("alter region --name=/REPLICATED --cache-loader=abc-def",
- "Specify a valid class name for cache-loader");
+ gfsh.executeAndAssertThat("alter region --name=/REPLICATED --cache-loader=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-loader");
}
@Test
public void invalidCacheWriter() throws Exception {
- gfsh.executeAndVerifyCommandError("alter region --name=/REPLICATED --cache-writer=abc-def",
- "Specify a valid class name for cache-writer");
+ gfsh.executeAndAssertThat("alter region --name=/REPLICATED --cache-writer=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-writer");
}
@Test
public void invalidEvictionMax() throws Exception {
- gfsh.executeAndVerifyCommandError("alter region --name=/REPLICATED --eviction-max=-1",
- "Specify 0 or a positive integer value for eviction-max");
+ gfsh.executeAndAssertThat("alter region --name=/REPLICATED --eviction-max=-1").statusIsError()
+ .containsOutput("Specify 0 or a positive integer value for eviction-max");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
index 91381bd..caed02c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ChangeLogLevelCommandDUnitTest.java
@@ -81,7 +81,7 @@ public class ChangeLogLevelCommandDUnitTest {
public void testChangeLogLevelForGroups() {
String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1 + "," + GROUP2;
- gfsh.executeAndVerifyCommand(commandString);
+ gfsh.executeAndAssertThat(commandString).statusIsSuccess();
String output = gfsh.getGfshOutput();
@@ -94,7 +94,7 @@ public class ChangeLogLevelCommandDUnitTest {
public void testChangeLogLevelForGroup() {
String commandString = "change loglevel --loglevel=finer --groups=" + GROUP1;
- gfsh.executeAndVerifyCommand(commandString);
+ gfsh.executeAndAssertThat(commandString).statusIsSuccess();
String output = gfsh.getGfshOutput();
@@ -108,7 +108,7 @@ public class ChangeLogLevelCommandDUnitTest {
String commandString =
"change loglevel --loglevel=finer --members=" + SERVER1_NAME + "," + SERVER2_NAME;
- gfsh.executeAndVerifyCommand(commandString);
+ gfsh.executeAndAssertThat(commandString).statusIsSuccess();
String output = gfsh.getGfshOutput();
@@ -121,7 +121,7 @@ public class ChangeLogLevelCommandDUnitTest {
public void testChangeLogLevelForMember() {
String commandString = "change loglevel --loglevel=finer --members=" + SERVER1_NAME;
- gfsh.executeAndVerifyCommand(commandString);
+ gfsh.executeAndAssertThat(commandString).statusIsSuccess();
String output = gfsh.getGfshOutput();
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConcurrentDeployDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConcurrentDeployDUnitTest.java
index 6b100f7..7bf5f99 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConcurrentDeployDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ConcurrentDeployDUnitTest.java
@@ -88,13 +88,13 @@ public class ConcurrentDeployDUnitTest {
for (int i = 1; i <= numTimesToExecute; i++) {
command = "deploy --jar=" + jar1.getAbsolutePath();
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
command = "list deployed";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
command = "undeploy --jar=" + jar1.getName();
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
index d6d8ac6..eb49db0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandDUnitTest.java
@@ -30,6 +30,7 @@ import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
+
import org.json.JSONArray;
import org.junit.Before;
import org.junit.Rule;
@@ -72,8 +73,9 @@ public class CreateRegionCommandDUnitTest {
@Test
public void testCreateRegionWithGoodCompressor() throws Exception {
String regionName = testName.getMethodName();
- gfsh.executeAndVerifyCommand("create region --name=" + regionName
- + " --type=REPLICATE --compressor=" + RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER);
+ gfsh.executeAndAssertThat("create region --name=" + regionName
+ + " --type=REPLICATE --compressor=" + RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER)
+ .statusIsSuccess();
server.invoke(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -87,8 +89,9 @@ public class CreateRegionCommandDUnitTest {
@Test
public void testCreateRegionWithBadCompressor() throws Exception {
String regionName = testName.getMethodName();
- gfsh.executeAndVerifyCommandError(
- "create region --name=" + regionName + " --type=REPLICATE --compressor=BAD_COMPRESSOR");
+ gfsh.executeAndAssertThat(
+ "create region --name=" + regionName + " --type=REPLICATE --compressor=BAD_COMPRESSOR")
+ .statusIsError();
server.invoke(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -100,7 +103,8 @@ public class CreateRegionCommandDUnitTest {
@Test
public void testCreateRegionWithNoCompressor() throws Exception {
String regionName = testName.getMethodName();
- gfsh.executeAndVerifyCommand("create region --name=" + regionName + " --type=REPLICATE");
+ gfsh.executeAndAssertThat("create region --name=" + regionName + " --type=REPLICATE")
+ .statusIsSuccess();
server.invoke(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -122,10 +126,11 @@ public class CreateRegionCommandDUnitTest {
final File prJarFile = new File(tmpDir.getRoot(), "myPartitionResolver.jar");
new JarBuilder().buildJar(prJarFile, PR_STRING);
- gfsh.executeAndVerifyCommand("deploy --jar=" + prJarFile.getAbsolutePath());
+ gfsh.executeAndAssertThat("deploy --jar=" + prJarFile.getAbsolutePath()).statusIsSuccess();
- gfsh.executeAndVerifyCommand("create region --name=" + regionName
- + " --type=PARTITION --partition-resolver=io.pivotal.TestPartitionResolver");
+ gfsh.executeAndAssertThat("create region --name=" + regionName
+ + " --type=PARTITION --partition-resolver=io.pivotal.TestPartitionResolver")
+ .statusIsSuccess();
server.invoke(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -138,23 +143,15 @@ public class CreateRegionCommandDUnitTest {
@Test
public void testCreateRegionWithInvalidPartitionResolver() throws Exception {
- gfsh.executeAndVerifyCommandError("create region --name=" + testName.getMethodName()
- + " --type=PARTITION --partition-resolver=InvalidPartitionResolver");
+ gfsh.executeAndAssertThat("create region --name=" + testName.getMethodName()
+ + " --type=PARTITION --partition-resolver=InvalidPartitionResolver").statusIsError();
}
@Test
public void testCreateRegionForReplicatedRegionWithPartitionResolver() {
String regionName = testName.getMethodName();
- CommandResult result = gfsh.executeAndVerifyCommandError("create region --name=" + regionName
- + " --type=REPLICATE --partition-resolver=InvalidPartitionResolver");
-
- assertThat(((String) ((JSONArray) result.getContent().get("message")).get(0)))
- .contains("\"/" + regionName + "\" is not a Partitioned Region");
- }
-
- private void writeJarBytesToFile(File jarFile, byte[] jarBytes) throws IOException {
- try (OutputStream os = new FileOutputStream(jarFile)) {
- os.write(jarBytes);
- }
+ gfsh.executeAndAssertThat("create region --name=" + regionName
+ + " --type=REPLICATE --partition-resolver=InvalidPartitionResolver")
+ .containsOutput("\"/" + regionName + "\" is not a Partitioned Region").statusIsError();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
index 391fd91..13a4b89 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/CreateRegionCommandIntegrationTest.java
@@ -61,183 +61,178 @@ public class CreateRegionCommandIntegrationTest {
@Test
public void parentRegionDoesNotExist() throws Exception {
- gfsh.executeAndVerifyCommandError(CREATE_REGION + "--name=/A/B",
- "Parent region for \"/A/B\" doesnt exist");
+ gfsh.executeAndAssertThat(CREATE_REGION + "--name=/A/B").statusIsError()
+ .containsOutput("Parent region for \"/A/B\" doesnt exist");
}
@Test
public void groupDoesNotExist() throws Exception {
- gfsh.executeAndVerifyCommandError(CREATE_REGION + "--name=/FOO --groups=unknown",
- "Group\\(s\\) .* are invalid");
+ gfsh.executeAndAssertThat(CREATE_REGION + "--name=/FOO --groups=unknown").statusIsError()
+ .containsOutput("Group(s) \"unknown\" are invalid");
}
@Test
public void templateRegionDoesNotExist() throws Exception {
- gfsh.executeAndVerifyCommandError("create region --name=/FOO --template-region=/BAR",
- "Specify a valid region path for template-region");
+ gfsh.executeAndAssertThat("create region --name=/FOO --template-region=/BAR").statusIsError()
+ .containsOutput("Specify a valid region path for template-region");
}
@Test
public void conflictingPartitionAttributesWithTemplate() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --template-region=REPLICATED --redundant-copies=2",
- "Parameter\\(s\\) \"\\[redundant-copies\\]\" can be used only for creating a Partitioned Region");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --template-region=REPLICATED --redundant-copies=2")
+ .statusIsError().containsOutput(
+ "Parameter(s) \"[redundant-copies]\" can be used only for creating a Partitioned Region");
}
@Test
public void conflictingPartitionAttributesWithShortCut() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --redundant-copies=2",
- "Parameter\\(s\\) \"\\[redundant-copies\\]\" can be used only for creating a Partitioned Region");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --redundant-copies=2")
+ .statusIsError().containsOutput(
+ "Parameter(s) \"[redundant-copies]\" can be used only for creating a Partitioned Region");
}
@Test
public void colocatedWithRegionDoesNotExist() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --type=PARTITION --name=/FOO --colocated-with=/BAR",
- "Specify a valid region path for colocated-with");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --name=/FOO --colocated-with=/BAR")
+ .statusIsError().containsOutput("Specify a valid region path for colocated-with");
}
@Test
public void colocatedWithRegionIsNotPartitioned() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --type=PARTITION --name=/FOO --colocated-with=/REPLICATED",
- "colocated-with \"/REPLICATED\" is not a Partitioned Region");
+ gfsh.executeAndAssertThat(
+ "create region --type=PARTITION --name=/FOO --colocated-with=/REPLICATED").statusIsError()
+ .containsOutput("colocated-with \"/REPLICATED\" is not a Partitioned Region");
}
@Test
public void negativeLocalMaxMemory() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --type=PARTITION --name=/FOO --local-max-memory=-1",
- "PartitionAttributes localMaxMemory must not be negative");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --name=/FOO --local-max-memory=-1")
+ .statusIsError().containsOutput("PartitionAttributes localMaxMemory must not be negative");
}
@Test
public void zeroLocalMaxMemoryIsOK() throws Exception {
- gfsh.executeAndVerifyCommand("create region --type=PARTITION --name=/FOO --local-max-memory=0",
- "Region \"/FOO\" created");
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --name=/FOO --local-max-memory=0")
+ .statusIsSuccess().containsOutput("Region \"/FOO\" created");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void negativeTotalMaxMemory() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --type=PARTITION --name=/FOO --total-max-memory=-1",
- "Total size of partition region must be > 0");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --name=/FOO --total-max-memory=-1")
+ .statusIsError().containsOutput("Total size of partition region must be > 0");
}
@Test
public void zeroTotalMaxMemory() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --type=PARTITION --name=/FOO --total-max-memory=0",
- "Total size of partition region must be > 0");
+ gfsh.executeAndAssertThat("create region --type=PARTITION --name=/FOO --total-max-memory=0")
+ .statusIsError().containsOutput("Total size of partition region must be > 0");
}
@Test
public void redundantCopies() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=PARTITION --redundant-copies=2",
- "Region \"/FOO\" created");
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=PARTITION --redundant-copies=2")
+ .statusIsSuccess().containsOutput("Region \"/FOO\" created");
+
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void tooManyredundantCopies() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=PARTITION --redundant-copies=4",
- "redundant-copies \"4\" is not valid");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=PARTITION --redundant-copies=4")
+ .statusIsError().containsOutput("redundant-copies \"4\" is not valid");
}
@Test
public void keyConstraint() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --key-constraint=abc-def",
- "Specify a valid class name for key-constraint");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --key-constraint=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for key-constraint");
}
@Test
public void valueConstraint() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --value-constraint=abc-def",
- "Specify a valid class name for value-constraint");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE --value-constraint=abc-def").statusIsError()
+ .containsOutput("Specify a valid class name for value-constraint");
}
@Test
public void invalidCacheListener() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --cache-listener=abc-def",
- "Specify a valid class name for cache-listener");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --cache-listener=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-listener");
}
@Test
public void invalidCacheLoader() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --cache-loader=abc-def",
- "Specify a valid class name for cache-loader");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --cache-loader=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-loader");
}
@Test
public void invalidCacheWriter() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --cache-writer=abc-def",
- "Specify a valid class name for cache-writer");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --cache-writer=abc-def")
+ .statusIsError().containsOutput("Specify a valid class name for cache-writer");
}
@Test
public void invalidGatewaySenders() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --gateway-sender-id=unknown",
- "There are no GatewaySenders defined currently in the system");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE --gateway-sender-id=unknown").statusIsError()
+ .containsOutput("There are no GatewaySenders defined currently in the system");
}
// TODO: Write test for invalid gateway name (gateways already need to exist).
@Test
public void invalidConcurrencyLevel() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --template-region=/REPLICATED --concurrency-level=-1",
- "Specify positive integer value for concurrency-level");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --template-region=/REPLICATED --concurrency-level=-1")
+ .statusIsError().containsOutput("Specify positive integer value for concurrency-level");
}
@Test
public void nonPersistentRegionWithdiskStore() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --disk-store=unknown",
- "Only regions with persistence or overflow to disk can specify DiskStore");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE --disk-store=unknown")
+ .statusIsError()
+ .containsOutput("Only regions with persistence or overflow to disk can specify DiskStore");
}
@Test
public void nonPersistentTemplateWithdiskStore() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --template-region=/REPLICATED --disk-store=unknown",
- "Only regions with persistence or overflow to disk can specify DiskStore",
- "template-region region \"/REPLICATED\" is not persistent");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --template-region=/REPLICATED --disk-store=unknown")
+ .statusIsError().containsOutput("template-region region \"/REPLICATED\" is not persistent")
+ .containsOutput("Only regions with persistence or overflow to disk can specify DiskStore");
}
@Test
public void invalidDiskStore() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE_PERSISTENT --disk-store=unknown",
- "Specify valid disk-store. Unknown Disk Store : \"unknown\"");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE_PERSISTENT --disk-store=unknown")
+ .statusIsError()
+ .containsOutput("Specify valid disk-store. Unknown Disk Store : \"unknown\"");
}
@Test
public void entryIdleTimeWithoutStatisticsEnabled() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --entry-idle-time-expiration=1",
- "Statistics must be enabled for expiration");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE --entry-idle-time-expiration=1").statusIsError()
+ .containsOutput("Statistics must be enabled for expiration");
}
@Test
public void invalidCompressor() throws Exception {
- gfsh.executeAndVerifyCommandError(
- "create region --name=/FOO --type=REPLICATE --compressor=java.lang.String",
- "java.lang.String cannot be cast to org.apache.geode.compression.Compressor");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE --compressor=java.lang.String").statusIsError()
+ .containsOutput(
+ "java.lang.String cannot be cast to org.apache.geode.compression.Compressor");
}
@Test
public void validateDefaultExpirationAttributes() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/A --type=REPLICATE");
+ gfsh.executeAndAssertThat("create region --name=/A --type=REPLICATE").statusIsSuccess();
Region region = server.getCache().getRegion("/A");
RegionAttributes attributes = region.getAttributes();
@@ -259,15 +254,15 @@ public class CreateRegionCommandIntegrationTest {
assertThat(regionTTL.getTimeout()).isEqualTo(0);
assertThat(regionTTL.getAction()).isEqualTo(ExpirationAction.INVALIDATE);
- gfsh.executeAndVerifyCommand("destroy region --name=/A");
+ gfsh.executeAndAssertThat("destroy region --name=/A").statusIsSuccess();
}
@Test
public void validateNonDefaultBinaryOptions() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=REPLICATE"
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE"
+ " --enable-async-conflation" + " --enable-cloning" + " --enable-concurrency-checks=false"
+ " --enable-multicast" + " --enable-statistics" + " --enable-subscription-conflation"
- + " --enable-synchronous-disk=false");
+ + " --enable-synchronous-disk=false").statusIsSuccess();
Region foo = server.getCache().getRegion("/FOO");
@@ -279,17 +274,17 @@ public class CreateRegionCommandIntegrationTest {
assertThat(foo.getAttributes().getEnableSubscriptionConflation()).isTrue();
assertThat(foo.getAttributes().isDiskSynchronous()).isFalse();
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validateExpirationOptions() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=REPLICATE"
- + " --enable-statistics" + " --entry-idle-time-expiration=3"
- + " --entry-idle-time-expiration-action=DESTROY" + " --entry-time-to-live-expiration=5"
- + " --entry-time-to-live-expiration-action=DESTROY" + " --region-idle-time-expiration=7"
- + " --region-idle-time-expiration-action=DESTROY" + " --region-time-to-live-expiration=11"
- + " --region-time-to-live-expiration-action=DESTROY");
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE" + " --enable-statistics"
+ + " --entry-idle-time-expiration=3" + " --entry-idle-time-expiration-action=DESTROY"
+ + " --entry-time-to-live-expiration=5" + " --entry-time-to-live-expiration-action=DESTROY"
+ + " --region-idle-time-expiration=7" + " --region-idle-time-expiration-action=DESTROY"
+ + " --region-time-to-live-expiration=11"
+ + " --region-time-to-live-expiration-action=DESTROY").statusIsSuccess();
Region foo = server.getCache().getRegion("/FOO");
@@ -307,15 +302,15 @@ public class CreateRegionCommandIntegrationTest {
assertThat(foo.getAttributes().getRegionTimeToLive().getAction())
.isEqualTo(ExpirationAction.DESTROY);
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validatePartitionRegionOptions() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=PARTITION_REDUNDANT"
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=PARTITION_REDUNDANT"
+ " --local-max-memory=1001" + " --recovery-delay=7" + " --redundant-copies=1"
+ " --startup-recovery-delay=5" + " --total-max-memory=2001" + " --total-num-buckets=11"
- + " --partition-resolver=" + TestPartitionResolver.class.getName());
+ + " --partition-resolver=" + TestPartitionResolver.class.getName()).statusIsSuccess();
Region foo = server.getCache().getRegion("/FOO");
@@ -329,15 +324,17 @@ public class CreateRegionCommandIntegrationTest {
foo.getAttributes().getPartitionAttributes().getPartitionResolver().getClass().getName())
.isEqualTo(TestPartitionResolver.class.getName());
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validateCallbackOptions() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=PARTITION_REDUNDANT"
- + " --cache-listener=" + TestCacheListener.class.getName() + " --cache-loader="
- + TestCacheLoader.class.getName() + " --cache-writer=" + TestCacheWriter.class.getName()
- + " --compressor=" + TestCompressor.class.getName());
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=PARTITION_REDUNDANT --cache-listener="
+ + TestCacheListener.class.getName() + " --cache-loader="
+ + TestCacheLoader.class.getName() + " --cache-writer=" + TestCacheWriter.class.getName()
+ + " --compressor=" + TestCompressor.class.getName())
+ .statusIsSuccess();
Region foo = server.getCache().getRegion("/FOO");
@@ -351,13 +348,14 @@ public class CreateRegionCommandIntegrationTest {
assertThat(foo.getAttributes().getCompressor().getClass().getName())
.isEqualTo(TestCompressor.class.getName());
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validateConstraints() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/FOO --type=REPLICATE" + " --key-constraint="
- + TestConstraint.class.getName() + " --value-constraint=" + TestConstraint.class.getName());
+ gfsh.executeAndAssertThat("create region --name=/FOO --type=REPLICATE" + " --key-constraint="
+ + TestConstraint.class.getName() + " --value-constraint=" + TestConstraint.class.getName())
+ .statusIsSuccess();
Region foo = server.getCache().getRegion("/FOO");
@@ -366,22 +364,23 @@ public class CreateRegionCommandIntegrationTest {
assertThat(foo.getAttributes().getValueConstraint().getName())
.isEqualTo(TestConstraint.class.getName());
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validateEntryIdleTimeExpiration() throws Exception {
- gfsh.executeAndVerifyCommand(
- "create region --name=/FOO --type=REPLICATE --entry-idle-time-expiration=7 --enable-statistics");
+ gfsh.executeAndAssertThat(
+ "create region --name=/FOO --type=REPLICATE --entry-idle-time-expiration=7 --enable-statistics")
+ .statusIsSuccess();
Region template = server.getCache().getRegion("/FOO");
assertThat(template.getAttributes().getEntryIdleTimeout().getTimeout()).isEqualTo(7);
- gfsh.executeAndVerifyCommand("destroy region --name=/FOO");
+ gfsh.executeAndAssertThat("destroy region --name=/FOO").statusIsSuccess();
}
@Test
public void validateTemplateRegionAttributesForReplicate() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/TEMPLATE --type=REPLICATE"
+ gfsh.executeAndAssertThat("create region --name=/TEMPLATE --type=REPLICATE"
+ " --enable-async-conflation" + " --enable-cloning" + " --enable-concurrency-checks=false"
+ " --enable-multicast" + " --enable-statistics" + " --enable-subscription-conflation"
+ " --enable-synchronous-disk=false" + " --entry-idle-time-expiration=3"
@@ -392,9 +391,10 @@ public class CreateRegionCommandIntegrationTest {
+ TestCacheListener.class.getName() + " --cache-loader=" + TestCacheLoader.class.getName()
+ " --cache-writer=" + TestCacheWriter.class.getName() + " --compressor="
+ TestCompressor.class.getName() + " --key-constraint=" + TestConstraint.class.getName()
- + " --value-constraint=" + TestConstraint.class.getName());
+ + " --value-constraint=" + TestConstraint.class.getName()).statusIsSuccess();
- gfsh.executeAndVerifyCommand("create region --name=/COPY --template-region=/TEMPLATE");
+ gfsh.executeAndAssertThat("create region --name=/COPY --template-region=/TEMPLATE")
+ .statusIsSuccess();
Region copy = server.getCache().getRegion("/COPY");
@@ -432,14 +432,13 @@ public class CreateRegionCommandIntegrationTest {
assertThat(copy.getAttributes().getValueConstraint().getName())
.isEqualTo(TestConstraint.class.getName());
-
- gfsh.executeAndVerifyCommand("destroy region --name=/COPY");
- gfsh.executeAndVerifyCommand("destroy region --name=/TEMPLATE");
+ gfsh.executeAndAssertThat("destroy region --name=/COPY").statusIsSuccess();
+ gfsh.executeAndAssertThat("destroy region --name=/TEMPLATE").statusIsSuccess();
}
@Test
public void validateTemplateRegionAttributesForPartitionRedundant() throws Exception {
- gfsh.executeAndVerifyCommand("create region --name=/TEMPLATE --type=PARTITION_REDUNDANT"
+ gfsh.executeAndAssertThat("create region --name=/TEMPLATE --type=PARTITION_REDUNDANT"
+ " --enable-async-conflation" + " --enable-cloning" + " --enable-concurrency-checks=false"
+ " --enable-multicast" + " --enable-statistics" + " --enable-subscription-conflation"
+ " --enable-synchronous-disk=false" + " --cache-listener="
@@ -449,9 +448,10 @@ public class CreateRegionCommandIntegrationTest {
+ " --value-constraint=" + TestConstraint.class.getName() + " --local-max-memory=1001"
+ " --recovery-delay=7" + " --redundant-copies=1" + " --startup-recovery-delay=5"
+ " --total-max-memory=2001" + " --total-num-buckets=11" + " --partition-resolver="
- + TestPartitionResolver.class.getName());
+ + TestPartitionResolver.class.getName()).statusIsSuccess();
- gfsh.executeAndVerifyCommand("create region --name=/COPY --template-region=/TEMPLATE");
+ gfsh.executeAndAssertThat("create region --name=/COPY --template-region=/TEMPLATE")
+ .statusIsSuccess();
Region copy = server.getCache().getRegion("/COPY");
@@ -487,7 +487,7 @@ public class CreateRegionCommandIntegrationTest {
copy.getAttributes().getPartitionAttributes().getPartitionResolver().getClass().getName())
.isEqualTo(TestPartitionResolver.class.getName());
- gfsh.executeAndVerifyCommand("destroy region --name=/COPY");
- gfsh.executeAndVerifyCommand("destroy region --name=/TEMPLATE");
+ gfsh.executeAndAssertThat("destroy region --name=/COPY").statusIsSuccess();
+ gfsh.executeAndAssertThat("destroy region --name=/TEMPLATE").statusIsSuccess();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java
index 3b33eb8..6a500af 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandFunctionRegistrationDUnitTest.java
@@ -71,7 +71,8 @@ public class DeployCommandFunctionRegistrationDUnitTest implements Serializable
File outputJar = new File(temporaryFolder.getRoot(), "output.jar");
jarBuilder.buildJar(outputJar, source);
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + outputJar.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + outputJar.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(
"org.apache.geode.management.internal.deployment.ImplementsFunction"));
server.invoke(() -> assertThatFunctionHasVersion(
@@ -88,7 +89,8 @@ public class DeployCommandFunctionRegistrationDUnitTest implements Serializable
File outputJar = new File(temporaryFolder.getRoot(), "output.jar");
jarBuilder.buildJar(outputJar, source);
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + outputJar.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + outputJar.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(
"org.apache.geode.management.internal.deployment.ExtendsFunctionAdapter"));
server.invoke(() -> assertThatFunctionHasVersion(
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
index f15482a..e46d931 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployCommandRedeployDUnitTest.java
@@ -91,23 +91,27 @@ public class DeployCommandRedeployDUnitTest implements Serializable {
@Test
public void redeployJarsWithNewVersionsOfFunctions() throws Exception {
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarAVersion1.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarAVersion1.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION1));
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarBVersion1.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarBVersion1.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatCanLoad(JAR_NAME_B, FULLY_QUALIFIED_FUNCTION_B));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION1));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_B, VERSION1));
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarBVersion2.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarBVersion2.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatCanLoad(JAR_NAME_B, FULLY_QUALIFIED_FUNCTION_B));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION1));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_B, VERSION2));
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarAVersion2.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarAVersion2.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatCanLoad(JAR_NAME_B, FULLY_QUALIFIED_FUNCTION_B));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION2));
@@ -116,14 +120,16 @@ public class DeployCommandRedeployDUnitTest implements Serializable {
@Test
public void hotDeployShouldNotResultInAnyFailedFunctionExecutions() throws Exception {
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarAVersion1.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarAVersion1.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION1));
server.invoke(() -> LoopingFunctionExecutor.startExecuting(FUNCTION_A));
server.invoke(() -> LoopingFunctionExecutor.waitForExecutions(100));
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jarAVersion2.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jarAVersion2.getCanonicalPath())
+ .statusIsSuccess();
server.invoke(() -> assertThatCanLoad(JAR_NAME_A, FUNCTION_A));
server.invoke(() -> assertThatFunctionHasVersion(FUNCTION_A, VERSION2));
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployWithGroupsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployWithGroupsDUnitTest.java
index f2e7824..ea9d4b7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployWithGroupsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DeployWithGroupsDUnitTest.java
@@ -107,7 +107,8 @@ public class DeployWithGroupsDUnitTest implements Serializable {
@Test
public void deployJarToOneGroup() throws Exception {
// Deploy a jar to a single group
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jar2 + " --group=" + GROUP1);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jar2 + " --group=" + GROUP1)
+ .statusIsSuccess();
String resultString = gfshConnector.getGfshOutput();
assertThat(resultString).contains(server1.getName());
@@ -121,14 +122,11 @@ public class DeployWithGroupsDUnitTest implements Serializable {
@Test
public void deployJarsInDirToOneGroup() throws Exception {
// Deploy of multiple JARs to a single group
- gfshConnector.executeAndVerifyCommand(
- "deploy --group=" + GROUP1 + " --dir=" + subdirWithJars3and4.getCanonicalPath());
- String resultString = gfshConnector.getGfshOutput();
-
- assertThat(resultString).describedAs(resultString).contains(server1.getName());
- assertThat(resultString).doesNotContain(server2.getName());
- assertThat(resultString).contains(jarName3);
- assertThat(resultString).contains(jarName4);
+ gfshConnector
+ .executeAndAssertThat(
+ "deploy --group=" + GROUP1 + " --dir=" + subdirWithJars3and4.getCanonicalPath())
+ .statusIsSuccess().containsOutput(server1.getName()).doesNotContainOutput(server2.getName())
+ .containsOutput(jarName3).containsOutput(jarName4);
server1.invoke(() -> {
assertThatCanLoad(jarName3, class3);
@@ -140,7 +138,7 @@ public class DeployWithGroupsDUnitTest implements Serializable {
});
// Undeploy of multiple jars by specifying group
- gfshConnector.executeAndVerifyCommand("undeploy --group=" + GROUP1);
+ gfshConnector.executeAndAssertThat("undeploy --group=" + GROUP1).statusIsSuccess();
server1.invoke(() -> {
assertThatCannotLoad(jarName3, class3);
assertThatCannotLoad(jarName4, class4);
@@ -154,14 +152,11 @@ public class DeployWithGroupsDUnitTest implements Serializable {
@Test
public void deployMultipleJarsToOneGroup() throws Exception {
// Deploy of multiple JARs to a single group
- gfshConnector.executeAndVerifyCommand("deploy --group=" + GROUP1 + " --jars="
- + jar3.getAbsolutePath() + "," + jar4.getAbsolutePath());
- String resultString = gfshConnector.getGfshOutput();
-
- assertThat(resultString).describedAs(resultString).contains(server1.getName());
- assertThat(resultString).doesNotContain(server2.getName());
- assertThat(resultString).contains(jarName3);
- assertThat(resultString).contains(jarName4);
+ gfshConnector
+ .executeAndAssertThat("deploy --group=" + GROUP1 + " --jars=" + jar3.getAbsolutePath() + ","
+ + jar4.getAbsolutePath())
+ .statusIsSuccess().containsOutput(server1.getName()).doesNotContainOutput(server2.getName())
+ .containsOutput(jarName3).containsOutput(jarName4);
server1.invoke(() -> {
assertThatCanLoad(jarName3, class3);
@@ -173,7 +168,8 @@ public class DeployWithGroupsDUnitTest implements Serializable {
});
// Undeploy of multiple jars by specifying group
- gfshConnector.executeAndVerifyCommand("undeploy --jars=" + jarName3 + "," + jarName4);
+ gfshConnector.executeAndAssertThat("undeploy --jars=" + jarName3 + "," + jarName4)
+ .statusIsSuccess();
server1.invoke(() -> {
assertThatCannotLoad(jarName3, class3);
assertThatCannotLoad(jarName4, class4);
@@ -188,7 +184,7 @@ public class DeployWithGroupsDUnitTest implements Serializable {
@Test
public void deployJarToAllServers() throws Exception {
// Deploy a jar to all servers
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + jar1);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + jar1).statusIsSuccess();
String resultString = gfshConnector.getGfshOutput();
assertThat(resultString).contains(server1.getName());
@@ -199,14 +195,15 @@ public class DeployWithGroupsDUnitTest implements Serializable {
server2.invoke(() -> assertThatCanLoad(jarName1, class1));
// Undeploy of jar by specifying group
- gfshConnector.executeAndVerifyCommand("undeploy --group=" + GROUP1);
+ gfshConnector.executeAndAssertThat("undeploy --group=" + GROUP1).statusIsSuccess();
server1.invoke(() -> assertThatCannotLoad(jarName1, class1));
server2.invoke(() -> assertThatCanLoad(jarName1, class1));
}
@Test
public void deployMultipleJarsToAllServers() throws Exception {
- gfshConnector.executeAndVerifyCommand("deploy --dir=" + subdirWithJars3and4.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --dir=" + subdirWithJars3and4.getCanonicalPath())
+ .statusIsSuccess();
server1.invoke(() -> {
assertThatCanLoad(jarName3, class3);
@@ -217,7 +214,7 @@ public class DeployWithGroupsDUnitTest implements Serializable {
assertThatCanLoad(jarName4, class4);
});
- gfshConnector.executeAndVerifyCommand("undeploy");
+ gfshConnector.executeAndAssertThat("undeploy").statusIsSuccess();
server1.invoke(() -> {
assertThatCannotLoad(jarName3, class3);
@@ -231,7 +228,8 @@ public class DeployWithGroupsDUnitTest implements Serializable {
@Test
public void undeployOfMultipleJars() throws Exception {
- gfshConnector.executeAndVerifyCommand("deploy --dir=" + subdirWithJars3and4.getCanonicalPath());
+ gfshConnector.executeAndAssertThat("deploy --dir=" + subdirWithJars3and4.getCanonicalPath())
+ .statusIsSuccess();
server1.invoke(() -> {
assertThatCanLoad(jarName3, class3);
@@ -242,8 +240,8 @@ public class DeployWithGroupsDUnitTest implements Serializable {
assertThatCanLoad(jarName4, class4);
});
- gfshConnector
- .executeAndVerifyCommand("undeploy --jar=" + jar3.getName() + "," + jar4.getName());
+ gfshConnector.executeAndAssertThat("undeploy --jar=" + jar3.getName() + "," + jar4.getName())
+ .statusIsSuccess();
server1.invoke(() -> {
assertThatCannotLoad(jarName3, class3);
assertThatCannotLoad(jarName4, class4);
@@ -270,12 +268,14 @@ public class DeployWithGroupsDUnitTest implements Serializable {
public void testListDeployed() throws Exception {
// Deploy a couple of JAR files which can be listed
gfshConnector
- .executeAndVerifyCommand("deploy --group=" + GROUP1 + " --jar=" + jar1.getCanonicalPath());
+ .executeAndAssertThat("deploy --group=" + GROUP1 + " --jar=" + jar1.getCanonicalPath())
+ .statusIsSuccess();
gfshConnector
- .executeAndVerifyCommand("deploy --group=" + GROUP2 + " --jar=" + jar2.getCanonicalPath());
+ .executeAndAssertThat("deploy --group=" + GROUP2 + " --jar=" + jar2.getCanonicalPath())
+ .statusIsSuccess();
// List for all members
- gfshConnector.executeAndVerifyCommand("list deployed");
+ gfshConnector.executeAndAssertThat("list deployed").statusIsSuccess();
String resultString = gfshConnector.getGfshOutput();
assertThat(resultString).contains(server1.getName());
assertThat(resultString).contains(server2.getName());
@@ -283,7 +283,7 @@ public class DeployWithGroupsDUnitTest implements Serializable {
assertThat(resultString).contains(jarName2);
// List for members in Group1
- gfshConnector.executeAndVerifyCommand("list deployed --group=" + GROUP1);
+ gfshConnector.executeAndAssertThat("list deployed --group=" + GROUP1).statusIsSuccess();
resultString = gfshConnector.getGfshOutput();
assertThat(resultString).contains(server1.getName());
assertThat(resultString).doesNotContain(server2.getName());
@@ -292,7 +292,7 @@ public class DeployWithGroupsDUnitTest implements Serializable {
assertThat(resultString).doesNotContain(jarName2);
// List for members in Group2
- gfshConnector.executeAndVerifyCommand("list deployed --group=" + GROUP2);
+ gfshConnector.executeAndAssertThat("list deployed --group=" + GROUP2).statusIsSuccess();
resultString = gfshConnector.getGfshOutput();
assertThat(resultString).doesNotContain(server1.getName());
assertThat(resultString).contains(server2.getName());
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandJUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandJUnitTest.java
index 0961aee..6238dc0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandJUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandJUnitTest.java
@@ -44,29 +44,22 @@ public class DescribeConfigCommandJUnitTest {
@Test
public void describeConfig() throws Exception {
gfsh.connectAndVerify(server.getJmxPort(), PortType.jmxManager);
- String result = gfsh.execute("describe config --member=" + server.getName());
- for (String datum : EXPECTED_BASE_CONFIGURATION_DATA) {
- assertThat(result).contains(datum);
- }
+ gfsh.executeAndAssertThat("describe config --member=" + server.getName()).statusIsSuccess()
+ .containsOutput(EXPECTED_BASE_CONFIGURATION_DATA);
}
@Test
public void describeConfigAndShowDefaults() throws Exception {
gfsh.connectAndVerify(server.getJmxPort(), PortType.jmxManager);
- String result =
- gfsh.execute("describe config --hide-defaults=false --member=" + server.getName());
- for (String datum : EXPECTED_BASE_CONFIGURATION_DATA) {
- assertThat(result).contains(datum);
- }
- for (String datum : EXPECTED_EXPANDED_CONFIGURATION_DATA) {
- assertThat(result).contains(datum);
- }
+ gfsh.executeAndAssertThat("describe config --hide-defaults=false --member=" + server.getName())
+ .statusIsSuccess().containsOutput(EXPECTED_BASE_CONFIGURATION_DATA)
+ .containsOutput(EXPECTED_EXPANDED_CONFIGURATION_DATA);
}
@Test
public void describeConfigWhenNotConnected() throws Exception {
- String result = gfsh.execute("describe config --member=" + server.getName());
- assertThat(result).contains("was found but is not currently available");
+ gfsh.executeAndAssertThat("describe config --member=" + server.getName()).statusIsError()
+ .containsOutput("was found but is not currently available");
}
@Test
@@ -75,16 +68,16 @@ public class DescribeConfigCommandJUnitTest {
String expectedErrorString = String.format("Member \"%s\" not found", invalidMemberName);
gfsh.connectAndVerify(server.getJmxPort(), PortType.jmxManager);
- String result = gfsh.execute("describe config --member=" + invalidMemberName);
- assertThat(result).contains(expectedErrorString);
+ gfsh.executeAndAssertThat("describe config --member=" + invalidMemberName).statusIsError()
+ .containsOutput(expectedErrorString);
}
@Test
public void describeConfigWithoutMemberName() throws Exception {
- String expectedErrorString = String.format("You should specify option ");
+ String expectedErrorString = "You should specify option ";
gfsh.connectAndVerify(server.getJmxPort(), PortType.jmxManager);
- String result = gfsh.execute("describe config");
- assertThat(result).contains(expectedErrorString);
+ gfsh.executeAndAssertThat("describe config").statusIsError()
+ .containsOutput(expectedErrorString);
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeMembersCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeMembersCommandDUnitTest.java
index 7c7506d..ca89d0d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeMembersCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeMembersCommandDUnitTest.java
@@ -46,36 +46,27 @@ public class DescribeMembersCommandDUnitTest {
@Test
public void describeInvalidMember() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(DESCRIBE_MEMBER + " --name=foo");
- String output = gfsh.getGfshOutput();
-
- assertThat(output).contains("Member \"foo\" not found");
+ gfsh.executeAndAssertThat(DESCRIBE_MEMBER + " --name=foo").statusIsSuccess()
+ .containsOutput("Member \"foo\" not found");
}
@Test
public void describeMembersWhenNotConnected() throws Exception {
- String result = gfsh.execute(DESCRIBE_MEMBER);
- assertThat(result)
- .contains("Command 'describe member' was found but is not currently available");
+ gfsh.executeAndAssertThat(DESCRIBE_MEMBER).statusIsError()
+ .containsOutput("Command 'describe member' was found but is not currently available");
}
@Test
public void describeLocator() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(DESCRIBE_MEMBER + " --name=locator-0");
- String output = gfsh.getGfshOutput();
-
- assertThat(output).contains("locator-0");
- assertThat(output).doesNotContain("server-1");
+ gfsh.executeAndAssertThat(DESCRIBE_MEMBER + " --name=locator-0").statusIsSuccess()
+ .containsOutput("locator-0").doesNotContainOutput("server-1");
}
@Test
public void describeServer() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(DESCRIBE_MEMBER + " --name=server-1");
- String output = gfsh.getGfshOutput();
-
- assertThat(output).doesNotContain("locator-0");
- assertThat(output).contains("server-1");
+ gfsh.executeAndAssertThat(DESCRIBE_MEMBER + " --name=server-1").statusIsSuccess()
+ .doesNotContainOutput("locator-0").containsOutput("server-1");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
index ee4a14d..36beb10 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/DestroyRegionCommandDUnitTest.java
@@ -88,16 +88,19 @@ public class DestroyRegionCommandDUnitTest {
locator.invoke(() -> waitForRegionMBeanCreation("/Order", 2));
// Test unable to destroy with co-location
- gfsh.executeAndVerifyCommandError("destroy region --name=/Customer",
- "The parent region \\[/Customer\\] in colocation chain cannot be destroyed");
+ gfsh.executeAndAssertThat("destroy region --name=/Customer").statusIsError()
+ .containsOutput("The parent region [/Customer] in colocation chain cannot be destroyed");
// Test success
- gfsh.executeAndVerifyCommand("destroy region --name=/Order", "destroyed successfully");
- gfsh.executeAndVerifyCommand("destroy region --name=/Customer", "destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=/Order").statusIsSuccess()
+ .containsOutput("destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=/Customer").statusIsSuccess()
+ .containsOutput("destroyed successfully");
// destroy something that's not exist anymore
- gfsh.executeAndVerifyCommandError("destroy region --name=/Customer", "Could not find a Region");
- gfsh.executeAndVerifyCommand("destroy region --name=/Customer --if-exists");
+ gfsh.executeAndAssertThat("destroy region --name=/Customer").statusIsError()
+ .containsOutput("Could not find a Region");
+ gfsh.executeAndAssertThat("destroy region --name=/Customer --if-exists").statusIsSuccess();
}
@Test
@@ -111,7 +114,8 @@ public class DestroyRegionCommandDUnitTest {
locator.invoke(() -> waitForRegionMBeanCreation("/Customer", 3));
- gfsh.executeAndVerifyCommand("destroy region --name=Customer", "destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=Customer").statusIsSuccess()
+ .containsOutput("destroyed successfully");
MemberVM.invokeInEveryMember(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -142,9 +146,12 @@ public class DestroyRegionCommandDUnitTest {
locator.invoke(() -> waitForRegionMBeanCreation("/Customer_2", 3));
locator.invoke(() -> waitForRegionMBeanCreation("/Customer_3", 3));
- gfsh.executeAndVerifyCommand("destroy region --name=Customer", "destroyed successfully");
- gfsh.executeAndVerifyCommand("destroy region --name=Customer_2", "destroyed successfully");
- gfsh.executeAndVerifyCommand("destroy region --name=Customer_3", "destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=Customer").statusIsSuccess()
+ .containsOutput("destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=Customer_2").statusIsSuccess()
+ .containsOutput("destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=Customer_3").statusIsSuccess()
+ .containsOutput("destroyed successfully");
MemberVM.invokeInEveryMember(() -> {
Cache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -156,7 +163,7 @@ public class DestroyRegionCommandDUnitTest {
@Test
public void testDestroyRegionWithSharedConfig() throws IOException {
- gfsh.executeAndVerifyCommand("create region --name=Customer --type=REPLICATE");
+ gfsh.executeAndAssertThat("create region --name=Customer --type=REPLICATE").statusIsSuccess();
locator.invoke(() -> {
// Make sure the region exists in the cluster config
@@ -173,7 +180,8 @@ public class DestroyRegionCommandDUnitTest {
}, server1, server2, server3);
// destroy the region
- gfsh.executeAndVerifyCommand("destroy region --name=Customer", "destroyed successfully");
+ gfsh.executeAndAssertThat("destroy region --name=Customer").statusIsSuccess()
+ .containsOutput("destroyed successfully");
// make sure the region was removed from cluster config
locator.invoke(() -> {
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
index 2f84430..dd78f0c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandSecurityTest.java
@@ -89,7 +89,8 @@ public class ExecuteFunctionCommandSecurityTest implements Serializable {
public void dataReaderCanExecuteReadFunction() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"dataRead", "dataRead");
- gfsh.executeAndVerifyCommand("execute function --id=" + new ReadFunction().getId());
+ gfsh.executeAndAssertThat("execute function --id=" + new ReadFunction().getId())
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(ReadFunction.SUCCESS_OUTPUT);
}
@@ -97,16 +98,17 @@ public class ExecuteFunctionCommandSecurityTest implements Serializable {
public void dataReaderCanNotExecuteWriteFunction() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"dataRead", "dataRead");
- gfsh.executeCommand("execute function --id=" + new WriteFunction().getId());
- assertThat(gfsh.getGfshOutput()).contains("dataRead not authorized for DATA:WRITE");
- assertThat(gfsh.getGfshOutput()).doesNotContain(WriteFunction.SUCCESS_OUTPUT);
+ gfsh.executeAndAssertThat("execute function --id=" + new WriteFunction().getId())
+ .containsOutput("dataRead not authorized for DATA:WRITE")
+ .doesNotContainOutput(WriteFunction.SUCCESS_OUTPUT);
}
@Test
public void dataWriterCanExecuteWriteFunction() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"dataWrite", "dataWrite");
- gfsh.executeAndVerifyCommand("execute function --id=" + new WriteFunction().getId());
+ gfsh.executeAndAssertThat("execute function --id=" + new WriteFunction().getId())
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(WriteFunction.SUCCESS_OUTPUT);
}
@@ -123,28 +125,28 @@ public class ExecuteFunctionCommandSecurityTest implements Serializable {
public void readOnlyUserOnReplicatedRegion() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"dataRead", "dataRead");
- gfsh.executeAndVerifyCommand(
- "execute function --id=" + new ReadFunction().getId() + " --region=" + REPLICATED_REGION);
- assertThat(gfsh.getGfshOutput()).contains(ReadFunction.SUCCESS_OUTPUT);
-
- gfsh.executeAndVerifyCommand(
- "execute function --id=" + new WriteFunction().getId() + " --region=" + REPLICATED_REGION);
- assertThat(gfsh.getGfshOutput()).contains("dataRead not authorized for DATA:WRITE");
- assertThat(gfsh.getGfshOutput()).doesNotContain(WriteFunction.SUCCESS_OUTPUT);
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + new ReadFunction().getId() + " --region=" + REPLICATED_REGION)
+ .statusIsSuccess().containsOutput(ReadFunction.SUCCESS_OUTPUT);
+
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + new WriteFunction().getId() + " --region=" + REPLICATED_REGION)
+ .statusIsSuccess().containsOutput("dataRead not authorized for DATA:WRITE")
+ .doesNotContainOutput(WriteFunction.SUCCESS_OUTPUT);
}
@Test
public void readOnlyUserOnPartitionedRegion() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"dataRead", "dataRead");
- gfsh.executeAndVerifyCommand(
- "execute function --id=" + new ReadFunction().getId() + " --region=" + PARTITIONED_REGION);
- assertThat(gfsh.getGfshOutput()).contains(ReadFunction.SUCCESS_OUTPUT);
-
- gfsh.executeAndVerifyCommand(
- "execute function --id=" + new WriteFunction().getId() + " --region=" + PARTITIONED_REGION);
- assertThat(gfsh.getGfshOutput()).contains("dataRead not authorized for DATA:WRITE");
- assertThat(gfsh.getGfshOutput()).doesNotContain(WriteFunction.SUCCESS_OUTPUT);
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + new ReadFunction().getId() + " --region=" + PARTITIONED_REGION)
+ .statusIsSuccess().containsOutput(ReadFunction.SUCCESS_OUTPUT);
+
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + new WriteFunction().getId() + " --region=" + PARTITIONED_REGION)
+ .statusIsSuccess().containsOutput("dataRead not authorized for DATA:WRITE")
+ .doesNotContainOutput(WriteFunction.SUCCESS_OUTPUT);
}
private static void waitUntilRegionMBeansAreRegistered() {
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportDataIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportDataIntegrationTest.java
index 1ed7a60..9339f65 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportDataIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportDataIntegrationTest.java
@@ -75,7 +75,7 @@ public class ExportDataIntegrationTest {
public void testExport() throws Exception {
String exportCommand = buildBaseExportCommand()
.addOption(CliStrings.EXPORT_DATA__FILE, snapshotFile.toString()).getCommandString();
- gfsh.executeAndVerifyCommand(exportCommand);
+ gfsh.executeAndAssertThat(exportCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Data successfully exported ");
}
@@ -84,7 +84,7 @@ public class ExportDataIntegrationTest {
String exportCommand =
buildBaseExportCommand().addOption(CliStrings.EXPORT_DATA__DIR, snapshotDir.toString())
.addOption(CliStrings.EXPORT_DATA__PARALLEL, "true").getCommandString();
- gfsh.executeAndVerifyCommand(exportCommand);
+ gfsh.executeAndAssertThat(exportCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Data successfully exported ");
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
index 86971fd..ec86a2d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsDUnitTest.java
@@ -120,7 +120,7 @@ public class ExportLogsDUnitTest {
commandStringBuilder.addOption("end-time", dateTimeFormatter.format(tomorrow));
commandStringBuilder.addOption("log-level", "debug");
- gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+ gfshConnector.executeAndAssertThat(commandStringBuilder.toString()).statusIsSuccess();
Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
@@ -146,7 +146,7 @@ public class ExportLogsDUnitTest {
commandStringBuilder.addOption("end-time", cutoffTimeString);
commandStringBuilder.addOption("log-level", "debug");
- gfshConnector.executeAndVerifyCommand(commandStringBuilder.toString());
+ gfshConnector.executeAndAssertThat(commandStringBuilder.toString()).statusIsSuccess();
expectedMessages.get(server1).add(logLineAfterCutoffTime);
Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
@@ -156,7 +156,8 @@ public class ExportLogsDUnitTest {
@Test
public void testExportWithThresholdLogLevelFilter() throws Exception {
- gfshConnector.executeAndVerifyCommand("export logs --log-level=info --only-log-level=false");
+ gfshConnector.executeAndAssertThat("export logs --log-level=info --only-log-level=false")
+ .statusIsSuccess();
Set<String> acceptedLogLevels = Stream.of("info", "error").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
@@ -165,21 +166,22 @@ public class ExportLogsDUnitTest {
@Test
public void testExportWithExactLogLevelFilter() throws Exception {
- gfshConnector.executeAndVerifyCommand("export logs --log-level=info --only-log-level=true");
+ gfshConnector.executeAndAssertThat("export logs --log-level=info --only-log-level=true")
+ .statusIsSuccess();
Set<String> acceptedLogLevels = Stream.of("info").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
}
@Test
public void testExportWithNoOptionsGiven() throws Exception {
- gfshConnector.executeAndVerifyCommand("export logs");
+ gfshConnector.executeAndAssertThat("export logs").statusIsSuccess();
Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
}
@Test
public void testExportWithNoFilters() throws Exception {
- gfshConnector.executeAndVerifyCommand("export logs --log-level=all");
+ gfshConnector.executeAndAssertThat("export logs --log-level=all").statusIsSuccess();
Set<String> acceptedLogLevels = Stream.of("info", "error", "debug").collect(toSet());
verifyZipFileContents(acceptedLogLevels);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
index b58f24f..f1e3bbd 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsOnServerManagerDUnit.java
@@ -47,7 +47,7 @@ public class ExportLogsOnServerManagerDUnit {
public void testExportWithOneServer() throws Exception {
MemberVM server0 = lsRule.startServerAsJmxManager(0);
gfshConnector.connect(server0.getJmxPort(), GfshShellConnectionRule.PortType.jmxManager);
- gfshConnector.executeAndVerifyCommand("export logs");
+ gfshConnector.executeAndAssertThat("export logs").statusIsSuccess();
String message = gfshConnector.getGfshOutput();
assertThat(message).contains(server0.getWorkingDir().getAbsolutePath());
@@ -66,7 +66,7 @@ public class ExportLogsOnServerManagerDUnit {
lsRule.startServerVM(1, server0.getEmbeddedLocatorPort());
gfshConnector.connect(server0.getEmbeddedLocatorPort(),
GfshShellConnectionRule.PortType.locator);
- gfshConnector.executeAndVerifyCommand("export logs");
+ gfshConnector.executeAndAssertThat("export logs").statusIsSuccess();
String message = gfshConnector.getGfshOutput();
assertThat(message).contains(server0.getWorkingDir().getAbsolutePath());
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
index dbb24a2..f99b278 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsStatsDUnitTest.java
@@ -94,7 +94,7 @@ public class ExportLogsStatsDUnitTest {
@Test
public void testExportLogsAndStats() throws Exception {
connectIfNeeded();
- connector.executeAndVerifyCommand("export logs");
+ connector.executeAndAssertThat("export logs").statusIsSuccess();
String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
Set<String> actualZipEnries = getZipEntries(zipPath);
@@ -106,7 +106,7 @@ public class ExportLogsStatsDUnitTest {
@Test
public void testExportLogsOnly() throws Exception {
connectIfNeeded();
- connector.executeAndVerifyCommand("export logs --logs-only");
+ connector.executeAndAssertThat("export logs --logs-only").statusIsSuccess();
String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
Set<String> actualZipEnries = getZipEntries(zipPath);
@@ -117,7 +117,7 @@ public class ExportLogsStatsDUnitTest {
@Test
public void testExportStatsOnly() throws Exception {
connectIfNeeded();
- connector.executeAndVerifyCommand("export logs --stats-only");
+ connector.executeAndAssertThat("export logs --stats-only").statusIsSuccess();
String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
Set<String> actualZipEnries = getZipEntries(zipPath);
@@ -137,8 +137,8 @@ public class ExportLogsStatsDUnitTest {
commandStringBuilder.addOption("start-time", dateTimeFormatter.format(tomorrow));
commandStringBuilder.addOption("log-level", "debug");
- String output = connector.execute(commandStringBuilder.toString());
- assertThat(output).contains("No files to be exported");
+ connector.executeAndAssertThat(commandStringBuilder.toString()).statusIsError()
+ .containsOutput("No files to be exported");
}
@Test
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
index 4ca0814..8e0a469 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ExportLogsWithMemberGroupDUnitTest.java
@@ -91,7 +91,7 @@ public class ExportLogsWithMemberGroupDUnitTest {
@Test
public void testExportLogsWithMemberName() throws Exception {
connectIfNeeded();
- connector.executeAndVerifyCommand("export logs --member=server-1");
+ connector.executeAndAssertThat("export logs --member=server-1").statusIsSuccess();
String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
Set<String> actualZipEntries = getZipEntries(zipPath);
@@ -102,14 +102,14 @@ public class ExportLogsWithMemberGroupDUnitTest {
@Test
public void testExportLogsWithGroupName() throws Exception {
connectIfNeeded();
- connector.executeAndVerifyCommand("export logs --group=group1");
+ connector.executeAndAssertThat("export logs --group=group1").statusIsSuccess();
String zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
Set<String> actualZipEntries = getZipEntries(zipPath);
Set<String> expectedFiles = Sets.newHashSet("server-1/server-1.log", "server-2/server-2.log");
assertThat(actualZipEntries).isEqualTo(expectedFiles);
- connector.executeAndVerifyCommand("export logs --group=group2");
+ connector.executeAndAssertThat("export logs --group=group2").statusIsSuccess();
zipPath = getZipPathFromCommandResult(connector.getGfshOutput());
actualZipEntries = getZipEntries(zipPath);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
index b269d56..03286bd 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsDUnitTest.java
@@ -15,6 +15,8 @@
package org.apache.geode.management.internal.cli.commands;
+import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION1;
+import static org.apache.geode.internal.cache.functions.TestFunction.TEST_FUNCTION_RETURN_ARGS;
import static org.assertj.core.api.Assertions.assertThat;
import static org.awaitility.Awaitility.await;
@@ -33,6 +35,7 @@ import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
+
import org.assertj.core.util.Strings;
import org.json.JSONArray;
import org.junit.Before;
@@ -96,10 +99,8 @@ public class FunctionCommandsDUnitTest {
}
});
- registerFunction(new TestFunction(true, TestFunction.TEST_FUNCTION1), locator, server1,
- server2);
- registerFunction(new TestFunction(true, TestFunction.TEST_FUNCTION_RETURN_ARGS), locator,
- server1, server2);
+ registerFunction(new TestFunction(true, TEST_FUNCTION1), locator, server1, server2);
+ registerFunction(new TestFunction(true, TEST_FUNCTION_RETURN_ARGS), locator, server1, server2);
locator.invoke(() -> {
Cache cache = LocatorServerStartupRule.locatorStarter.getLocator().getCache();
@@ -124,108 +125,105 @@ public class FunctionCommandsDUnitTest {
@Test
public void testExecuteFunctionOnRegion() throws Exception {
- CommandResult result = gfsh.executeAndVerifyCommand(
- "execute function --id=" + TestFunction.TEST_FUNCTION1 + " --region=/" + REGION_ONE);
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(2);
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + TEST_FUNCTION1 + " --region=/" + REGION_ONE).statusIsSuccess()
+ .tableHasColumnWithValuesContaining("Member ID/Name", server1.getName(), server2.getName());
}
@Test
public void testExecuteUnknownFunction() throws Exception {
- CommandResult result = gfsh.executeAndVerifyCommand("execute function --id=UNKNOWN_FUNCTION");
- assertThat(result.getContent().toString())
- .contains("UNKNOWN_FUNCTION is not registered on member");
+ gfsh.executeAndAssertThat("execute function --id=UNKNOWN_FUNCTION").statusIsSuccess()
+ .containsOutput("UNKNOWN_FUNCTION is not registered on member");
}
@Test
public void testExecuteFunctionOnRegionWithCustomResultCollector() {
- CommandResult result = gfsh
- .executeAndVerifyCommand("execute function --id=" + TestFunction.TEST_FUNCTION_RETURN_ARGS
- + " --region=" + REGION_ONE + " --arguments=arg1,arg2" + " --result-collector="
- + ToUpperResultCollector.class.getName());
- assertThat(result.getContent().toString()).contains("ARG1");
+ gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION_RETURN_ARGS + " --region="
+ + REGION_ONE + " --arguments=arg1,arg2" + " --result-collector="
+ + ToUpperResultCollector.class.getName()).statusIsSuccess().containsOutput("ARG1");
}
@Test
public void testExecuteFunctionOnMember() {
- CommandResult result = gfsh.executeAndVerifyCommand("execute function --id="
- + TestFunction.TEST_FUNCTION1 + " --member=" + server1.getMember().getName());
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(1);
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + TEST_FUNCTION1 + " --member=" + server1.getMember().getName())
+ .statusIsSuccess().tableHasColumnWithValuesContaining("Member ID/Name", server1.getName());
}
@Test
public void testExecuteFunctionOnInvalidMember() {
- CommandResult result = gfsh.executeCommand(
- "execute function --id=" + TestFunction.TEST_FUNCTION1 + " --member=INVALID_MEMBER");
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + TEST_FUNCTION1 + " --member=INVALID_MEMBER").statusIsError();
}
@Test
public void testExecuteFunctionOnAllMembers() {
- CommandResult result =
- gfsh.executeAndVerifyCommand("execute function --id=" + TestFunction.TEST_FUNCTION1);
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(2);
+ gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1).statusIsSuccess()
+ .tableHasColumnWithValuesContaining("Member ID/Name", server1.getName(), server2.getName());
}
@Test
public void testExecuteFunctionOnMultipleMembers() {
- CommandResult result =
- gfsh.executeAndVerifyCommand("execute function --id=" + TestFunction.TEST_FUNCTION1
- + " --member=" + Strings.join(server1.getName(), server2.getName()).with(","));
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(2);
+ gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --member="
+ + Strings.join(server1.getName(), server2.getName()).with(",")).statusIsSuccess()
+ .tableHasColumnWithValuesContaining("Member ID/Name", server1.getName(), server2.getName());
}
@Test
public void testExecuteFunctionOnMultipleMembersWithArgsAndResultCollector() {
- CommandResult result = gfsh.executeAndVerifyCommand(
- "execute function --id=" + TestFunction.TEST_FUNCTION_RETURN_ARGS + " --arguments=arg1,arg2"
- + " --result-collector=" + ToUpperResultCollector.class.getName());
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(2);
- assertThat(((JSONArray) result.getContent().get("Function Execution Result")).getString(0))
- .contains("ARG1");
- assertThat(((JSONArray) result.getContent().get("Function Execution Result")).getString(1))
- .contains("ARG1");
+ gfsh.executeAndAssertThat(
+ "execute function --id=" + TEST_FUNCTION_RETURN_ARGS + " --arguments=arg1,arg2"
+ + " --result-collector=" + ToUpperResultCollector.class.getName())
+ .statusIsSuccess()
+ .tableHasColumnWithValuesContaining("Member ID/Name", server1.getName(), server2.getName())
+ .tableHasColumnWithValuesContaining("Function Execution Result", "ARG1", "ARG1");
}
@Test
public void testExecuteFunctionOnGroup() {
- CommandResult result = gfsh.executeAndVerifyCommand(
- "execute function --id=" + TestFunction.TEST_FUNCTION1 + " --groups=group-1");
- assertThat(((JSONArray) result.getContent().get("Member ID/Name")).length()).isEqualTo(1);
+ gfsh.executeAndAssertThat("execute function --id=" + TEST_FUNCTION1 + " --groups=group-1")
+ .statusIsSuccess().tableHasColumnWithValuesContaining("Member ID/Name", server1.getName());
}
@Test
public void testDestroyFunctionOnMember() {
- gfsh.executeAndVerifyCommand(
- "destroy function --id=" + TestFunction.TEST_FUNCTION1 + " --member=" + server1.getName());
- CommandResult result = gfsh.executeAndVerifyCommand("list functions");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(3);
- gfsh.executeAndVerifyCommand(
- "destroy function --id=" + TestFunction.TEST_FUNCTION1 + " --member=" + server2.getName());
- result = gfsh.executeAndVerifyCommand("list functions");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(2);
+ gfsh.executeAndAssertThat(
+ "destroy function --id=" + TEST_FUNCTION1 + " --member=" + server1.getName())
+ .statusIsSuccess();
+
+ gfsh.executeAndAssertThat("list functions").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
+ TEST_FUNCTION1, TEST_FUNCTION_RETURN_ARGS);
+ gfsh.executeAndAssertThat(
+ "destroy function --id=" + TEST_FUNCTION1 + " --member=" + server2.getName())
+ .statusIsSuccess();
+ gfsh.executeAndAssertThat("list functions").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
+ TEST_FUNCTION_RETURN_ARGS);
}
@Test
public void testDestroyFunctionOnGroup() {
- gfsh.executeAndVerifyCommand(
- "destroy function --id=" + TestFunction.TEST_FUNCTION1 + " --groups=group-1");
- CommandResult result = gfsh.executeAndVerifyCommand("list functions");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(3);
+ gfsh.executeAndAssertThat("destroy function --id=" + TEST_FUNCTION1 + " --groups=group-1")
+ .statusIsSuccess();
+ gfsh.executeAndAssertThat("list functions").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION_RETURN_ARGS,
+ TEST_FUNCTION1, TEST_FUNCTION_RETURN_ARGS);
}
@Test
public void testListFunctions() {
- CommandResult result = gfsh.executeAndVerifyCommand("list functions");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(4);
+ gfsh.executeAndAssertThat("list functions").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1, TEST_FUNCTION1,
+ TEST_FUNCTION_RETURN_ARGS, TEST_FUNCTION_RETURN_ARGS);
- result = gfsh.executeAndVerifyCommand("list functions --matches=Test.*");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(2);
+ gfsh.executeAndAssertThat("list functions --matches=Test.*").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1, TEST_FUNCTION1);
- result = gfsh.executeAndVerifyCommand("list functions --matches=Test.* --groups=group-1");
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(1);
+ gfsh.executeAndAssertThat("list functions --matches=Test.* --groups=group-1").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1);
- result = gfsh
- .executeAndVerifyCommand("list functions --matches=Test.* --members=" + server1.getName());
- assertThat(((JSONArray) result.getContent().get("Function")).length()).isEqualTo(1);
+ gfsh.executeAndAssertThat("list functions --matches=Test.* --members=" + server1.getName())
+ .statusIsSuccess().tableHasColumnWithExactValuesInAnyOrder("Function", TEST_FUNCTION1);
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
index 1cb0f8a..2cf5772 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GcCommandDUnitTest.java
@@ -82,7 +82,7 @@ public class GcCommandDUnitTest {
@Test
public void testGCForGroup() {
String gcCommand = "gc --group=" + GROUP0;
- gfsh.executeAndVerifyCommand(gcCommand);
+ gfsh.executeAndAssertThat(gcCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(MANAGER_NAME);
}
@@ -91,14 +91,14 @@ public class GcCommandDUnitTest {
public void testGCForMemberID() {
String gcCommand = "gc --member=" + MANAGER_NAME;
- gfsh.executeAndVerifyCommand(gcCommand);
+ gfsh.executeAndAssertThat(gcCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(MANAGER_NAME);
}
@Test
public void testGCForEntireCluster() {
String command = "gc";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).contains(SERVER1_NAME);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GetCommandIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GetCommandIntegrationTest.java
index 6df8be9..226edc3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GetCommandIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GetCommandIntegrationTest.java
@@ -76,26 +76,28 @@ public class GetCommandIntegrationTest {
@Test
public void get() throws Exception {
- gfsh.executeAndVerifyCommand("get --region=Users --key=jonbloom");
+ gfsh.executeAndAssertThat("get --region=Users --key=jonbloom").statusIsSuccess();
}
@Test
public void getWithSlashedRegionName() throws Exception {
- gfsh.executeAndVerifyCommand("get --region=/Users --key=jonbloom");
+ gfsh.executeAndAssertThat("get --region=/Users --key=jonbloom").statusIsSuccess();
}
@Test
public void getOnCacheMiss() throws Exception {
- gfsh.executeAndVerifyCommand("get --region=Users --key=jonbloom");
+ gfsh.executeAndAssertThat("get --region=Users --key=jonbloom").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Result : true");
- gfsh.executeAndVerifyCommand("get --region=Users --key=jondoe --load-on-cache-miss=false");
+ gfsh.executeAndAssertThat("get --region=Users --key=jondoe --load-on-cache-miss=false")
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Result : false");
- gfsh.executeAndVerifyCommand("get --region=Users --key=jondoe");
+ gfsh.executeAndAssertThat("get --region=Users --key=jondoe").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Result : true");
// get something that does not exist
- gfsh.executeAndVerifyCommand("get --region=Users --key=missingUser --load-on-cache-miss");
+ gfsh.executeAndAssertThat("get --region=Users --key=missingUser --load-on-cache-miss")
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Result : false");
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandIntegrationTest.java
index 60b83c7..fa7d7dc 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/GfshCommandIntegrationTest.java
@@ -36,14 +36,12 @@ public class GfshCommandIntegrationTest {
@Test
public void invalidCommandWhenNotConnected() throws Exception {
- String result = gfsh.execute("abc");
- assertThat(result).contains("Command 'abc' not found");
+ gfsh.executeAndAssertThat("abc").statusIsError().containsOutput("Command 'abc' not found");
}
@Test
public void invalidCommandWhenConnected() throws Exception {
gfsh.connectAndVerify(locator);
- String result = gfsh.execute("abc");
- assertThat(result).contains("Command 'abc' not found");
+ gfsh.executeAndAssertThat("abc").statusIsError().containsOutput("Command 'abc' not found");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ImportDataIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ImportDataIntegrationTest.java
index 46da5d0..627e8e7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ImportDataIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ImportDataIntegrationTest.java
@@ -75,13 +75,13 @@ public class ImportDataIntegrationTest {
public void testExportImport() throws Exception {
String exportCommand = buildBaseExportCommand()
.addOption(CliStrings.EXPORT_DATA__FILE, snapshotFile.toString()).getCommandString();
- gfsh.executeAndVerifyCommand(exportCommand);
+ gfsh.executeAndAssertThat(exportCommand).statusIsSuccess();
loadRegion("");
String importCommand = buildBaseImportCommand()
.addOption(CliStrings.IMPORT_DATA__FILE, snapshotFile.toString()).getCommandString();
- gfsh.executeAndVerifyCommand(importCommand);
+ gfsh.executeAndAssertThat(importCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Data imported from file");
validateImport("value");
}
@@ -90,13 +90,13 @@ public class ImportDataIntegrationTest {
public void testExportImportRelativePath() throws Exception {
String exportCommand = buildBaseExportCommand()
.addOption(CliStrings.EXPORT_DATA__FILE, SNAPSHOT_FILE).getCommandString();
- gfsh.executeAndVerifyCommand(exportCommand);
+ gfsh.executeAndAssertThat(exportCommand).statusIsSuccess();
loadRegion("");
String importCommand = buildBaseImportCommand()
.addOption(CliStrings.IMPORT_DATA__FILE, SNAPSHOT_FILE).getCommandString();
- gfsh.executeAndVerifyCommand(importCommand);
+ gfsh.executeAndAssertThat(importCommand).statusIsSuccess();
Files.deleteIfExists(Paths.get(SNAPSHOT_FILE));
assertThat(gfsh.getGfshOutput()).contains("Data imported from file");
validateImport("value");
@@ -107,14 +107,14 @@ public class ImportDataIntegrationTest {
String exportCommand =
buildBaseExportCommand().addOption(CliStrings.EXPORT_DATA__DIR, snapshotDir.toString())
.addOption(CliStrings.EXPORT_DATA__PARALLEL, "true").getCommandString();
- gfsh.executeAndVerifyCommand(exportCommand);
+ gfsh.executeAndAssertThat(exportCommand).statusIsSuccess();
loadRegion("");
String importCommand =
buildBaseImportCommand().addOption(CliStrings.IMPORT_DATA__DIR, snapshotDir.toString())
.addOption(CliStrings.IMPORT_DATA__PARALLEL, "true").getCommandString();
- gfsh.executeAndVerifyCommand(importCommand);
+ gfsh.executeAndAssertThat(importCommand).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Data imported from file");
validateImport("value");
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
index 48737fb..cce69c5 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsIntegrationTest.java
@@ -78,10 +78,10 @@ public class IndexCommandsIntegrationTest {
// destroy all existing indexes
Collection<Index> indices = server.getCache().getQueryService().getIndexes();
indices.stream().map(Index::getName).forEach(indexName -> {
- gfsh.executeAndVerifyCommand("destroy index --name=" + indexName);
+ gfsh.executeAndAssertThat("destroy index --name=" + indexName).statusIsSuccess();
});
- gfsh.executeAndVerifyCommand("list index");
+ gfsh.executeAndAssertThat("list index").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("No Indexes Found");
}
@@ -102,10 +102,10 @@ public class IndexCommandsIntegrationTest {
createStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION,
"\"/" + regionName + " s, s.history h\"");
- gfsh.executeAndVerifyCommand(createStringBuilder.toString());
+ gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
- gfsh.executeAndVerifyCommand("list index");
+ gfsh.executeAndAssertThat("list index").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("indexA");
}
@@ -117,10 +117,10 @@ public class IndexCommandsIntegrationTest {
createStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION,
"\"/" + regionName + " s, s.history h\"");
- gfsh.executeAndVerifyCommand(createStringBuilder.toString());
+ gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
- gfsh.executeAndVerifyCommand("list index");
+ gfsh.executeAndAssertThat("list index").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("indexA");
}
@@ -145,10 +145,10 @@ public class IndexCommandsIntegrationTest {
csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
csb.addOption(CliStrings.CREATE_INDEX__REGION, regionName);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Index successfully created");
- gfsh.executeAndVerifyCommand("list index");
+ gfsh.executeAndAssertThat("list index").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("indexA");
}
@@ -169,9 +169,9 @@ public class IndexCommandsIntegrationTest {
@Test
public void cannotCreateWithTheSameName() throws Exception {
createSimpleIndexA();
- gfsh.execute("create index --name=indexA --expression=key --region=/regionA");
- assertThat(gfsh.getGfshOutput())
- .contains("Index \"indexA\" already exists. Create failed due to duplicate name");
+ gfsh.executeAndAssertThat("create index --name=indexA --expression=key --region=/regionA")
+ .statusIsError()
+ .containsOutput("Index \"indexA\" already exists. Create failed due to duplicate name");
}
@Test
@@ -236,8 +236,8 @@ public class IndexCommandsIntegrationTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
csb.addOption(CliStrings.DESTROY_INDEX__REGION, regionName);
- gfsh.executeAndVerifyCommand(csb.toString(),
- "Indexes on region : /regionA successfully destroyed");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput("Indexes on region : /regionA successfully destroyed");
}
@Test
@@ -246,7 +246,8 @@ public class IndexCommandsIntegrationTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DESTROY_INDEX);
csb.addOption(CliStrings.GROUP, groupName);
- gfsh.executeAndVerifyCommand(csb.toString(), "Indexes successfully destroyed");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput("Indexes successfully destroyed");
}
private void createSimpleIndexA() throws Exception {
@@ -254,7 +255,8 @@ public class IndexCommandsIntegrationTest {
csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
csb.addOption(CliStrings.CREATE_INDEX__REGION, "/" + regionName);
- gfsh.executeAndVerifyCommand(csb.toString(), "Index successfully created");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput("Index successfully created");
}
private static Region<?, ?> createPartitionedRegion(String regionName, Cache cache,
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsShareConfigurationDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsShareConfigurationDUnitTest.java
index 1d8762a..68199e3 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsShareConfigurationDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/IndexCommandsShareConfigurationDUnitTest.java
@@ -106,7 +106,7 @@ public class IndexCommandsShareConfigurationDUnitTest {
createStringBuilder.addOption(CliStrings.CREATE_INDEX__EXPRESSION, "key");
createStringBuilder.addOption(CliStrings.GROUP, groupName);
createStringBuilder.addOption(CliStrings.CREATE_INDEX__REGION, "/" + partitionedRegionName);
- gfsh.executeAndVerifyCommand(createStringBuilder.toString());
+ gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
assertTrue(indexIsListed());
@@ -126,7 +126,7 @@ public class IndexCommandsShareConfigurationDUnitTest {
createStringBuilder.addOption(CliStrings.DESTROY_INDEX__NAME, indexName);
createStringBuilder.addOption(CliStrings.GROUP, groupName);
createStringBuilder.addOption(CliStrings.DESTROY_INDEX__REGION, "/" + partitionedRegionName);
- gfsh.executeAndVerifyCommand(createStringBuilder.toString());
+ gfsh.executeAndAssertThat(createStringBuilder.toString()).statusIsSuccess();
locator.invoke(() -> {
ClusterConfigurationService sharedConfig =
@@ -167,7 +167,7 @@ public class IndexCommandsShareConfigurationDUnitTest {
}
private boolean indexIsListed() throws Exception {
- gfsh.executeAndVerifyCommand(CliStrings.LIST_INDEX);
+ gfsh.executeAndAssertThat(CliStrings.LIST_INDEX).statusIsSuccess();
return gfsh.getGfshOutput().contains(indexName);
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
index 2f5efb4..664a886 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListAndDescribeRegionDUnitTest.java
@@ -21,7 +21,6 @@ import static org.apache.geode.distributed.ConfigurationProperties.LOG_LEVEL;
import static org.apache.geode.distributed.ConfigurationProperties.MCAST_PORT;
import static org.apache.geode.distributed.ConfigurationProperties.NAME;
import static org.apache.geode.distributed.ConfigurationProperties.STATISTIC_SAMPLING_ENABLED;
-import static org.apache.geode.management.internal.cli.commands.CliCommandTestBase.commandResultToString;
import static org.apache.geode.management.internal.cli.i18n.CliStrings.DESCRIBE_REGION;
import static org.apache.geode.management.internal.cli.i18n.CliStrings.DESCRIBE_REGION__NAME;
import static org.apache.geode.management.internal.cli.i18n.CliStrings.GROUP;
@@ -49,7 +48,6 @@ import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.compression.SnappyCompressor;
import org.apache.geode.internal.cache.RegionEntryContext;
-import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.management.internal.cli.util.CommandStringBuilder;
import org.apache.geode.management.internal.cli.util.RegionAttributesNames;
import org.apache.geode.test.dunit.Host;
@@ -134,82 +132,57 @@ public class ListAndDescribeRegionDUnitTest implements Serializable {
@Test
public void listAllRegions() throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(LIST_REGION);
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains(LOCALREGIONONMANAGER);
- assertThat(commandResultString).contains(REGION1);
- assertThat(commandResultString).contains(REGION2);
- assertThat(commandResultString).contains(REGION3);
+ String listRegions = new CommandStringBuilder(LIST_REGION).toString();
+ gfshShellConnectionRule.executeAndAssertThat(listRegions).statusIsSuccess().containsOutput(PR1,
+ LOCALREGIONONMANAGER, REGION1, REGION2, REGION3);
}
@Test
public void listRegionsOnManager() throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(LIST_REGION);
- csb.addOption(MEMBER, "Manager");
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains(LOCALREGIONONMANAGER);
+ String listRegions =
+ new CommandStringBuilder(LIST_REGION).addOption(MEMBER, "Manager").toString();
+ gfshShellConnectionRule.executeAndAssertThat(listRegions).statusIsSuccess().containsOutput(PR1,
+ LOCALREGIONONMANAGER);
}
@Test
public void listRegionsOnServer() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LIST_REGION);
csb.addOption(MEMBER, "Server");
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains(REGION1);
- assertThat(commandResultString).contains(REGION2);
- assertThat(commandResultString).contains(REGION3);
- assertThat(commandResultString).contains(SUBREGION1A);
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(PR1, REGION1, REGION2, REGION3, SUBREGION1A);
}
@Test
public void listRegionsInGroup1() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LIST_REGION);
csb.addOption(GROUP, "G1");
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains(LOCALREGIONONMANAGER);
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(PR1, LOCALREGIONONMANAGER);
}
@Test
public void listRegionsInGroup2() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LIST_REGION);
csb.addOption(GROUP, "G2");
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains(REGION1);
- assertThat(commandResultString).contains(REGION2);
- assertThat(commandResultString).contains(REGION3);
- assertThat(commandResultString).contains(SUBREGION1A);
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(PR1, REGION1, REGION2, REGION3, SUBREGION1A);
}
@Test
public void describeRegionsOnManager() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(DESCRIBE_REGION);
csb.addOption(DESCRIBE_REGION__NAME, PR1);
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
-
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(PR1);
- assertThat(commandResultString).contains("Server");
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(PR1, "Server");
}
@Test
public void describeRegionsOnServer() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(DESCRIBE_REGION);
csb.addOption(DESCRIBE_REGION__NAME, LOCALREGIONONMANAGER);
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
-
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(LOCALREGIONONMANAGER);
- assertThat(commandResultString).contains("Manager");
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(LOCALREGIONONMANAGER, "Manager");
}
/**
@@ -231,11 +204,9 @@ public class ListAndDescribeRegionDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(DESCRIBE_REGION);
csb.addOption(DESCRIBE_REGION__NAME, regionName);
String commandString = csb.toString();
- CommandResult commandResult = gfshShellConnectionRule.executeAndVerifyCommand(commandString);
- String commandResultString = commandResultToString(commandResult);
- assertThat(commandResultString).contains(regionName);
- assertThat(commandResultString).contains(RegionAttributesNames.COMPRESSOR);
- assertThat(commandResultString).contains(RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER);
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(
+ regionName, RegionAttributesNames.COMPRESSOR,
+ RegionEntryContext.DEFAULT_COMPRESSION_PROVIDER);
// Destroy compressed region
vm.invoke(() -> {
@@ -266,7 +237,7 @@ public class ListAndDescribeRegionDUnitTest implements Serializable {
/**
* Creates a region that uses compression on region entry values.
- *
+ *
* @param regionName a unique region name.
*/
private static void createCompressedRegion(final String regionName) {
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
index fbddcb1..5048722 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListIndexCommandDUnitTest.java
@@ -23,13 +23,11 @@ import org.apache.geode.cache.RegionFactory;
import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.management.internal.cli.domain.Stock;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.json.GfJsonObject;
-import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
-import org.json.JSONArray;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -74,18 +72,16 @@ public class ListIndexCommandDUnitTest {
@Test
public void testListIndexes() throws Exception {
- CommandResult result = gfsh.executeAndVerifyCommand(CliStrings.LIST_INDEX);
- assertThat(((JSONArray) result.getContent().get("Member Name")).get(0))
- .isEqualTo(server.getName());
+ gfsh.executeAndAssertThat(CliStrings.LIST_INDEX).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Member Name", server.getName());
}
@Test
public void testListIndexesWithStats() throws Exception {
- CommandResult result = gfsh.executeAndVerifyCommand(CliStrings.LIST_INDEX + " --with-stats");
- GfJsonObject content = result.getContent();
- assertThat(((JSONArray) content.get("Member Name")).get(0)).isEqualTo(server.getName());
- assertThat(((JSONArray) content.get("Updates")).get(0)).isEqualTo("1");
- assertThat(((JSONArray) content.get("Keys")).get(0)).isEqualTo("1");
- assertThat(((JSONArray) content.get("Values")).get(0)).isEqualTo("1");
+ gfsh.executeAndAssertThat(CliStrings.LIST_INDEX + " --with-stats").statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Member Name", server.getName())
+ .tableHasColumnWithExactValuesInAnyOrder("Updates", "1")
+ .tableHasColumnWithExactValuesInAnyOrder("Keys", "1")
+ .tableHasColumnWithExactValuesInAnyOrder("Values", "1");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListMembersCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListMembersCommandDUnitTest.java
index c0dc45a..b3d5f9d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListMembersCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ListMembersCommandDUnitTest.java
@@ -50,14 +50,14 @@ public class ListMembersCommandDUnitTest {
@Test
public void listMembersWithoutConnection() throws Exception {
- String result = gfsh.execute(LIST_MEMBER);
- assertThat(result).contains("Command 'list members' was found but is not currently available");
+ gfsh.executeAndAssertThat(LIST_MEMBER).statusIsError()
+ .containsOutput("Command 'list members' was found but is not currently available");
}
@Test
public void listAllMembers() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(LIST_MEMBER);
+ gfsh.executeAndAssertThat(LIST_MEMBER).statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).contains("locator-0");
@@ -69,7 +69,7 @@ public class ListMembersCommandDUnitTest {
@Test
public void listMembersInLocatorGroup() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(LIST_MEMBER + " --group=locatorGroup");
+ gfsh.executeAndAssertThat(LIST_MEMBER + " --group=locatorGroup").statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).contains("locator-0");
@@ -81,7 +81,7 @@ public class ListMembersCommandDUnitTest {
@Test
public void listMembersInServerGroupOne() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(LIST_MEMBER + " --group=serverGroup1");
+ gfsh.executeAndAssertThat(LIST_MEMBER + " --group=serverGroup1").statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).doesNotContain("locator-0");
@@ -93,7 +93,7 @@ public class ListMembersCommandDUnitTest {
@Test
public void listMembersInServerGroupTwo() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(LIST_MEMBER + " --group=serverGroup2");
+ gfsh.executeAndAssertThat(LIST_MEMBER + " --group=serverGroup2").statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).doesNotContain("locator-0");
@@ -105,7 +105,7 @@ public class ListMembersCommandDUnitTest {
@Test
public void listMembersInNonExistentGroup() throws Exception {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(LIST_MEMBER + " --group=foo");
+ gfsh.executeAndAssertThat(LIST_MEMBER + " --group=foo").statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).doesNotContain("locator-0");
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/PutCommandIntegrationTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/PutCommandIntegrationTest.java
index 4dae79f..e50adb7 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/PutCommandIntegrationTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/PutCommandIntegrationTest.java
@@ -41,12 +41,14 @@ public class PutCommandIntegrationTest {
@Test
public void putWithoutSlash() throws Exception {
- gfsh.executeAndVerifyCommand("put --region=testRegion --key=key1 --value=value1");
+ gfsh.executeAndAssertThat("put --region=testRegion --key=key1 --value=value1")
+ .statusIsSuccess();
}
@Test
public void putWithSlash() throws Exception {
- gfsh.executeAndVerifyCommand("put --region=/testRegion --key=key1 --value=value1");
+ gfsh.executeAndAssertThat("put --region=/testRegion --key=key1 --value=value1")
+ .statusIsSuccess();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandTest.java
index be88b99..6049714 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/QueryCommandTest.java
@@ -38,8 +38,6 @@ import org.junit.runners.Parameterized;
import org.apache.geode.cache.Cache;
import org.apache.geode.cache.Region;
import org.apache.geode.cache.RegionShortcut;
-import org.apache.geode.management.cli.Result;
-import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.management.internal.cli.shell.Gfsh;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
import org.apache.geode.test.junit.rules.ServerStarterRule;
@@ -56,6 +54,8 @@ public class QueryCommandTest {
@Parameterized.Parameter
public boolean useHttp;
+ private final String DEFAULT_FETCH_SIZE = String.valueOf(Gfsh.DEFAULT_APP_FETCH_SIZE);
+
@ClassRule
public static ServerStarterRule server =
new ServerStarterRule().withJMXManager().withRegion(RegionShortcut.REPLICATE, "simpleRegion")
@@ -92,18 +92,15 @@ public class QueryCommandTest {
@Test
public void doesShowLimitIfLimitNotInQuery() throws Exception {
- String output = gfsh.execute("query --query='select * from /simpleRegion'");
- assertThat(output).contains("Rows : " + Gfsh.DEFAULT_APP_FETCH_SIZE);
- assertThat(output).contains("Limit : " + Gfsh.DEFAULT_APP_FETCH_SIZE);
- assertThatOutputHasResult(output);
+ gfsh.executeAndAssertThat("query --query='select * from /simpleRegion'")
+ .containsKeyValuePair("Rows", DEFAULT_FETCH_SIZE)
+ .containsKeyValuePair("Limit", DEFAULT_FETCH_SIZE).hasResult();
}
@Test
public void doesNotShowLimitIfLimitInQuery() throws Exception {
- String output = gfsh.execute("query --query='select * from /simpleRegion limit 50'");
- assertThat(output).contains("Rows : 50");
- assertThat(output).doesNotContain("Limit");
- assertThatOutputHasResult(output);
+ gfsh.executeAndAssertThat("query --query='select * from /simpleRegion limit 50'")
+ .containsKeyValuePair("Rows", "50").doesNotContainOutput("Limit").hasResult();
}
@Test
@@ -111,12 +108,11 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
FileUtils.deleteQuietly(outputFile);
- String output =
- gfsh.execute("query --query='invalid query' --file=" + outputFile.getAbsolutePath());
- assertThat(outputFile).doesNotExist();
+ gfsh.executeAndAssertThat(
+ "query --query='invalid query' --file=" + outputFile.getAbsolutePath()).hasNoResult()
+ .doesNotContainOutput("Query results output to");
- assertThatOutputHasNoResult(output);
- assertThat(output).doesNotContain("Query results output to");
+ assertThat(outputFile).doesNotExist();
}
@Test
@@ -124,12 +120,11 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
FileUtils.deleteQuietly(outputFile);
- String output = gfsh.execute(
- "query --query='select * from /nonExistentRegion' --file=" + outputFile.getAbsolutePath());
- assertThat(outputFile).doesNotExist();
+ gfsh.executeAndAssertThat(
+ "query --query='select * from /nonExistentRegion' --file=" + outputFile.getAbsolutePath())
+ .hasNoResult().doesNotContainOutput("Query results output to");
- assertThatOutputHasNoResult(output);
- assertThat(output).doesNotContain("Query results output to");
+ assertThat(outputFile).doesNotExist();
}
@Test
@@ -137,13 +132,10 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
FileUtils.deleteQuietly(outputFile);
- String output = gfsh.execute(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath());
-
- assertThat(output).contains("Rows");
- assertThat(output).contains("Limit");
- assertThat(output).contains("Query results output to");
- assertThatOutputHasResult(output);
+ gfsh.executeAndAssertThat(
+ "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath())
+ .hasResult().containsOutput("Rows").containsOutput("Limit")
+ .containsOutput("Query results output to");
}
@Test
@@ -151,12 +143,9 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
assertThat(outputFile).exists();
- CommandResult result = gfsh.executeCommand(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath());
-
- assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR);
- assertThat(result.getContent().getString("message"))
- .contains("The specified output file already exists.");
+ gfsh.executeAndAssertThat(
+ "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath())
+ .statusIsError().containsOutput("The specified output file already exists.");
}
@Test
@@ -164,10 +153,11 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
FileUtils.deleteQuietly(outputFile);
- CommandResult result = gfsh.executeAndVerifyCommand(
- "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath());
+ gfsh.executeAndAssertThat(
+ "query --query='select * from /simpleRegion' --file=" + outputFile.getAbsolutePath())
+ .statusIsSuccess().containsOutput(outputFile.getAbsolutePath());
+
assertThat(outputFile).exists();
- assertThat(result.getContent().toString()).contains(outputFile.getAbsolutePath());
List<String> lines = Files.readLines(outputFile, StandardCharsets.UTF_8);
@@ -181,12 +171,12 @@ public class QueryCommandTest {
File outputFile = temporaryFolder.newFile("queryOutput.txt");
FileUtils.deleteQuietly(outputFile);
- CommandResult result = gfsh.executeAndVerifyCommand(
+ gfsh.executeAndAssertThat(
"query --query='select c.name, c.address from /complexRegion c' --file="
- + outputFile.getAbsolutePath());
- assertThat(outputFile).exists();
- assertThat(result.getContent().toString()).contains(outputFile.getAbsolutePath());
+ + outputFile.getAbsolutePath())
+ .statusIsSuccess().containsOutput(outputFile.getAbsolutePath());
+ assertThat(outputFile).exists();
List<String> lines = Files.readLines(outputFile, StandardCharsets.UTF_8);
assertThat(lines.get(0)).containsPattern("name\\s+\\|\\s+address");
@@ -210,41 +200,22 @@ public class QueryCommandTest {
@Test
public void queryWithInvalidRegionNameGivesDescriptiveErrorMessage() throws Exception {
- String output = gfsh.execute("query --query='select * from /nonExistentRegion'");
- assertThatOutputHasNoResult(output);
- assertThatOutputHasMessage(output,
- "Cannot find regions <[/nonExistentRegion]> in any of the members");
+ gfsh.executeAndAssertThat("query --query='select * from /nonExistentRegion'")
+ .containsKeyValuePair("Result", "false")
+ .containsOutput("Cannot find regions <[/nonExistentRegion]> in any of the members");
}
@Test
public void invalidQueryGivesDescriptiveErrorMessage() throws Exception {
- String output = gfsh.execute("query --query='this is not a valid query'");
-
- assertThatOutputHasNoResult(output);
- assertThatOutputHasMessage(output, "Query is invalid due for error : <Syntax error in query:");
+ gfsh.executeAndAssertThat("query --query='this is not a valid query'")
+ .containsKeyValuePair("Result", "false")
+ .containsOutput("Query is invalid due for error : <Syntax error in query:");
}
@Test
public void queryGivesDescriptiveErrorMessageIfNoQueryIsSpecified() throws Exception {
- String output = gfsh.execute("query");
-
- assertThat(output)
- .contains("You should specify option (--query, --file, --interactive) for this command");
- }
-
- private void assertThatOutputHasResult(String output) {
- String resultPattern = "Result\\s+:\\s+" + "true";
- assertThat(output).containsPattern(resultPattern);
- }
-
- private void assertThatOutputHasNoResult(String output) {
- String resultPattern = "Result\\s+:\\s+" + "false";
- assertThat(output).containsPattern(resultPattern);
- }
-
- private void assertThatOutputHasMessage(String output, String message) {
- String patternToMatch = "Message\\s+:\\s+" + Pattern.quote(message);
- assertThat(output).containsPattern(patternToMatch);
+ gfsh.executeAndAssertThat("query").containsOutput(
+ "You should specify option (--query, --file, --interactive) for this command");
}
private String[] splitOnLineBreaks(String multilineString) {
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
index 5a1d7a9..986d1ae 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandDUnitTest.java
@@ -94,27 +94,23 @@ public class RemoveCommandDUnitTest implements Serializable {
public void removeFromInvalidRegion() throws Exception {
String command = "remove --all --region=NotAValidRegion";
- gfsh.executeAndVerifyCommandError(command, String.format(REGION_NOT_FOUND, "/NotAValidRegion"));
+ gfsh.executeAndAssertThat(command).statusIsError()
+ .containsOutput(String.format(REGION_NOT_FOUND, "/NotAValidRegion"));
}
@Test
public void removeWithNoKeyOrAllSpecified() throws Exception {
String command = "remove --region=" + REPLICATE_REGION_NAME;
- gfsh.executeAndVerifyCommandError(command);
- assertThat(gfsh.getGfshOutput()).contains("Key is Null");
+ gfsh.executeAndAssertThat(command).statusIsError().containsOutput("Key is Null");
}
@Test
public void removeKeyFromReplicateRegion() {
String command = "remove --key=key1 --region=" + REPLICATE_REGION_NAME;
- gfsh.executeAndVerifyCommand(command);
-
- String output = gfsh.getGfshOutput();
- assertThat(output).containsPattern("Result\\s+:\\s+true");
- assertThat(output).containsPattern("Key Class\\s+:\\s+java.lang.String");
- assertThat(output).containsPattern("Key\\s+:\\s+key1");
+ gfsh.executeAndAssertThat(command).statusIsSuccess().containsKeyValuePair("Result", "true")
+ .containsKeyValuePair("Key Class", "java.lang.String").containsKeyValuePair("Key", "key1");
server1.invoke(() -> verifyKeyIsRemoved(REPLICATE_REGION_NAME, "key1"));
server2.invoke(() -> verifyKeyIsRemoved(REPLICATE_REGION_NAME, "key1"));
@@ -127,7 +123,7 @@ public class RemoveCommandDUnitTest implements Serializable {
public void removeKeyFromPartitionedRegion() {
String command = "remove --key=key1 --region=" + PARTITIONED_REGION_NAME;
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).containsPattern("Result\\s+:\\s+true");
@@ -145,8 +141,8 @@ public class RemoveCommandDUnitTest implements Serializable {
public void removeAllFromReplicateRegion() {
String command = "remove --all --region=" + REPLICATE_REGION_NAME;
- gfsh.executeAndVerifyCommand("list regions");
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat("list regions").statusIsSuccess();
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Cleared all keys in the region");
@@ -160,7 +156,7 @@ public class RemoveCommandDUnitTest implements Serializable {
String command = "remove --all --region=" + PARTITIONED_REGION_NAME;
// Maybe this should return an "error" status, but the current behavior is status "OK"
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
assertThat(gfsh.getGfshOutput())
.contains("Option --all is not supported on partitioned region");
@@ -175,7 +171,7 @@ public class RemoveCommandDUnitTest implements Serializable {
server2.invoke(() -> verifyKeyIsPresent(REPLICATE_REGION_NAME, EMPTY_STRING));
String command = "remove --key=\"\" --region=" + REPLICATE_REGION_NAME;
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
server1.invoke(() -> verifyKeyIsRemoved(REPLICATE_REGION_NAME, EMPTY_STRING));
server2.invoke(() -> verifyKeyIsRemoved(REPLICATE_REGION_NAME, EMPTY_STRING));
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
index b084ab5..1f2a757 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/RemoveCommandJsonDUnitTest.java
@@ -98,7 +98,7 @@ public class RemoveCommandJsonDUnitTest implements Serializable {
String keyJson = "('id':'key1','name':'name1')";
String command = removeCommand(keyJson);
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
server1.invoke(() -> verifyKeyIsRemoved(1));
server2.invoke(() -> verifyKeyIsRemoved(1));
@@ -112,7 +112,7 @@ public class RemoveCommandJsonDUnitTest implements Serializable {
String keyJson = "('id':'key1')";
String command = removeCommand(keyJson);
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
server1.invoke(() -> verifyKeyIsRemoved(1));
server2.invoke(() -> verifyKeyIsRemoved(1));
@@ -126,7 +126,7 @@ public class RemoveCommandJsonDUnitTest implements Serializable {
String keyJson = "('foo':'bar')";
String command = removeCommand(keyJson);
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
server1.invoke(() -> verifyKeyIsPresent(1));
server2.invoke(() -> verifyKeyIsPresent(1));
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
index 265277b..e3818d0 100755
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowDeadlockDUnitTest.java
@@ -88,7 +88,7 @@ public class ShowDeadlockDUnitTest {
@Test
public void testNoDeadlock() throws Exception {
- gfsh.executeAndVerifyCommand(showDeadlockCommand);
+ gfsh.executeAndAssertThat(showDeadlockCommand).statusIsSuccess();
String commandOutput = gfsh.getGfshOutput();
assertThat(commandOutput).startsWith(CliStrings.SHOW_DEADLOCK__NO__DEADLOCK);
@@ -105,7 +105,7 @@ public class ShowDeadlockDUnitTest {
lockTheLocks(server2, server1, countDownLatch);
Awaitility.await().atMost(5, TimeUnit.MINUTES).pollDelay(5, TimeUnit.SECONDS).until(() -> {
- gfsh.executeAndVerifyCommand(showDeadlockCommand);
+ gfsh.executeAndAssertThat(showDeadlockCommand).statusIsSuccess();
String commandOutput = gfsh.getGfshOutput();
assertThat(commandOutput).startsWith(CliStrings.SHOW_DEADLOCK__DEADLOCK__DETECTED);
assertThat(outputFile).exists();
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
index 5ec07b8..cf1cd52 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowLogCommandDUnitTest.java
@@ -111,7 +111,7 @@ public class ShowLogCommandDUnitTest implements Serializable {
writeLogMessages();
String command = "show log --member=" + MANAGER_NAME;
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(MESSAGE_ON_MANAGER);
assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_SERVER1);
assertThat(gfsh.getGfshOutput()).doesNotContain(MESSAGE_ON_SERVER2);
@@ -123,7 +123,7 @@ public class ShowLogCommandDUnitTest implements Serializable {
String command = "show log --member=" + SERVER1_NAME + " --lines=50";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
String output = gfsh.getGfshOutput();
assertThat(output).contains(MESSAGE_ON_SERVER1);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsDUnitTest.java
index 017867e..67c6c3d 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMetricsDUnitTest.java
@@ -32,6 +32,7 @@ import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
+
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -39,6 +40,7 @@ import org.junit.experimental.categories.Category;
import org.junit.rules.TemporaryFolder;
import java.io.File;
+
import javax.management.ObjectName;
@Category(DistributedTest.class)
@@ -116,21 +118,20 @@ public class ShowMetricsDUnitTest {
@Test
public void testShowMetricsDefault() throws Exception {
- gfsh.executeAndVerifyCommand("show metrics");
+ gfsh.executeAndAssertThat("show metrics").statusIsSuccess();
}
@Test
public void testShowMetricsRegion() throws Exception {
- gfsh.executeAndVerifyCommand("show metrics --region=REGION1");
+ gfsh.executeAndAssertThat("show metrics --region=REGION1").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Cluster-wide Region Metrics");
}
@Test
public void testShowMetricsMember() throws Exception {
- gfsh.executeAndVerifyCommand(
- "show metrics --member=" + server.getName() + " --port=" + server.getPort());
- assertThat(gfsh.getGfshOutput()).contains("Member Metrics");
- assertThat(gfsh.getGfshOutput()).contains("cache-server");
+ gfsh.executeAndAssertThat(
+ "show metrics --member=" + server.getName() + " --port=" + server.getPort())
+ .statusIsSuccess().containsOutput("Member Metrics").containsOutput("cache-server");
}
@Test
@@ -138,18 +139,18 @@ public class ShowMetricsDUnitTest {
File output = tempFolder.newFile("memberMetricReport.csv");
output.delete();
- gfsh.executeAndVerifyCommand("show metrics --member=" + server.getName() + " --port="
- + server.getPort() + " --file=" + output.getAbsolutePath());
- assertThat(gfsh.getGfshOutput()).contains("Member Metrics");
- assertThat(gfsh.getGfshOutput()).contains("cache-server");
- assertThat(gfsh.getGfshOutput())
- .contains("Member metrics exported to " + output.getAbsolutePath());
+ gfsh.executeAndAssertThat("show metrics --member=" + server.getName() + " --port="
+ + server.getPort() + " --file=" + output.getAbsolutePath()).statusIsSuccess()
+ .containsOutput("Member Metrics").containsOutput("cache-server")
+ .containsOutput("Member metrics exported to " + output.getAbsolutePath());
+
assertThat(output).exists();
}
@Test
public void testShowMetricsRegionFromMember() throws Exception {
- gfsh.executeAndVerifyCommand("show metrics --member=" + server.getName() + " --region=REGION1");
+ gfsh.executeAndAssertThat("show metrics --member=" + server.getName() + " --region=REGION1")
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Metrics for region:/REGION1 On Member server-1");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
index a857437..bdda1c0 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShowMissingDiskStoresDUnitTest.java
@@ -78,7 +78,7 @@ public class ShowMissingDiskStoresDUnitTest {
csb = new CommandStringBuilder(CliStrings.CREATE_DISK_STORE)
.addOption(CliStrings.CREATE_DISK_STORE__NAME, "diskStore")
.addOption(CliStrings.CREATE_DISK_STORE__DIRECTORY_AND_SIZE, "diskStoreDir");
- gfshConnector.executeAndVerifyCommand(csb.getCommandString());
+ gfshConnector.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
Awaitility.await().until(() -> {
return new File(server1.getWorkingDir(), "diskStoreDir").exists()
@@ -90,7 +90,7 @@ public class ShowMissingDiskStoresDUnitTest {
.addOption(CliStrings.CREATE_REGION__DISKSTORE, "diskStore")
.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT,
RegionShortcut.REPLICATE_PERSISTENT.toString());
- gfshConnector.executeAndVerifyCommand(csb.getCommandString());
+ gfshConnector.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
// Add data to the region
putUsingGfsh(gfshConnector, testRegionName, 1, "A");
@@ -147,6 +147,6 @@ public class ShowMissingDiskStoresDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.PUT)
.addOption(CliStrings.PUT__KEY, Integer.toString(key)).addOption(CliStrings.PUT__VALUE, val)
.addOption(CliStrings.PUT__REGIONNAME, regionName);
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
index ee5f70e..e60262c 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/commands/ShutdownCommandDUnitTest.java
@@ -93,13 +93,13 @@ public class ShutdownCommandDUnitTest {
public void testShutdownServers() {
String command = "shutdown";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Shutdown is triggered");
verifyShutDown(server1, server2);
// Make sure the locator is still running
- gfsh.executeAndVerifyCommand("list members");
+ gfsh.executeAndAssertThat("list members").statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(MANAGER_NAME);
}
@@ -107,7 +107,7 @@ public class ShutdownCommandDUnitTest {
public void testShutdownAll() {
String command = "shutdown --include-locators=true";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("Shutdown is triggered");
verifyShutDown(server1, server2, manager);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
index ae0d932..751d22b 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/cli/shell/GfshMultilineCommandTest.java
@@ -44,12 +44,12 @@ public class GfshMultilineCommandTest {
// Execute a command
CommandStringBuilder csb = new CommandStringBuilder(LIST_MEMBER);
csb.addOption(GROUP, "nogroup");
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
assertThat(gfsh.getGfshOutput().trim()).isEqualTo(NO_MEMBERS_FOUND_MESSAGE);
// Now execute same command with a new Continuation on new line
csb = new CommandStringBuilder(LIST_MEMBER).addNewLine().addOption(GROUP, "nogroup");
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
assertThat(gfsh.getGfshOutput().trim()).isEqualTo(NO_MEMBERS_FOUND_MESSAGE);
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
index a0d60b8..a4f25ea 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigDeployJarDUnitTest.java
@@ -54,7 +54,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJarPath);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + clusterJarPath).statusIsSuccess();
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
@@ -80,7 +80,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + clusterJar).statusIsSuccess();
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
@@ -106,7 +106,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + clusterJar).statusIsSuccess();
ConfigGroup cluster = new ConfigGroup("cluster").jars("cluster.jar");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
@@ -115,7 +115,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
expectedClusterConfig.verify(server2);
expectedClusterConfig.verify(server3);
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + group1Jar + " --group=group1");
+ gfshConnector.executeAndAssertThat("deploy --jar=" + group1Jar + " --group=group1")
+ .statusIsSuccess();
ConfigGroup group1 = new ConfigGroup("group1").jars("group1.jar");
ClusterConfig expectedGroup1Config = new ClusterConfig(cluster, group1);
@@ -124,7 +125,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
expectedGroup1Config.verify(server2);
expectedGroup1Config.verify(server3);
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + group2Jar + " --group=group2");
+ gfshConnector.executeAndAssertThat("deploy --jar=" + group2Jar + " --group=group2")
+ .statusIsSuccess();
ConfigGroup group2 = new ConfigGroup("group2").jars("group2.jar");
ClusterConfig expectedGroup1and2Config = new ClusterConfig(cluster, group1, group2);
@@ -158,7 +160,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + clusterJar).statusIsSuccess();
// deploy cluster.jar to the cluster
cluster.addJar("cluster.jar");
@@ -168,7 +170,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
expectedClusterConfig.verify(server3);
// deploy group1.jar to both group1 and group2
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + group1Jar + " --group=group1,group2");
+ gfshConnector.executeAndAssertThat("deploy --jar=" + group1Jar + " --group=group1,group2")
+ .statusIsSuccess();
group1.addJar("group1.jar");
group2.addJar("group1.jar");
@@ -178,7 +181,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
server3Config.verify(server3);
// test undeploy cluster
- gfshConnector.executeAndVerifyCommand("undeploy --jar=cluster.jar");
+ gfshConnector.executeAndAssertThat("undeploy --jar=cluster.jar").statusIsSuccess();
cluster = cluster.removeJar("cluster.jar");
server3Config.verify(locator);
@@ -186,7 +189,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
server2Config.verify(server2);
server3Config.verify(server3);
- gfshConnector.executeAndVerifyCommand("undeploy --jar=group1.jar --group=group1");
+ gfshConnector.executeAndAssertThat("undeploy --jar=group1.jar --group=group1")
+ .statusIsSuccess();
group1 = group1.removeJar("group1.jar");
/*
@@ -227,7 +231,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
gfshConnector.connect(locator);
assertThat(gfshConnector.isConnected()).isTrue();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + clusterJar);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + clusterJar).statusIsSuccess();
// deploy cluster.jar to the cluster
cluster.addJar("cluster.jar");
@@ -237,7 +241,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
expectedClusterConfig.verify(server3);
// deploy group1.jar to both group1 and group2
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + group1Jar + " --group=group1,group2");
+ gfshConnector.executeAndAssertThat("deploy --jar=" + group1Jar + " --group=group1,group2")
+ .statusIsSuccess();
group1.addJar("group1.jar");
group2.addJar("group1.jar");
@@ -249,7 +254,7 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
server3.getVM().bounce();
// test undeploy cluster
- gfshConnector.executeAndVerifyCommand("undeploy --jar=cluster.jar");
+ gfshConnector.executeAndAssertThat("undeploy --jar=cluster.jar").statusIsSuccess();
server3 = lsRule.startServerVM(3, serverProps, locator.getPort());
cluster = cluster.removeJar("cluster.jar");
@@ -258,7 +263,8 @@ public class ClusterConfigDeployJarDUnitTest extends ClusterConfigTestBase {
server2Config.verify(server2);
server3Config.verify(server3);
- gfshConnector.executeAndVerifyCommand("undeploy --jar=group1.jar --group=group1");
+ gfshConnector.executeAndAssertThat("undeploy --jar=group1.jar --group=group1")
+ .statusIsSuccess();
group1 = group1.removeJar("group1.jar");
/*
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 1de2864..74f1f2f 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
@@ -77,20 +77,26 @@ public class ClusterConfigDistributionDUnitTest {
final String DESTROY_REGION = "regionToBeDestroyed";
gfshConnector
- .executeAndVerifyCommand("create region --name=" + REPLICATE_REGION + " --type=REPLICATE");
+ .executeAndAssertThat("create region --name=" + REPLICATE_REGION + " --type=REPLICATE")
+ .statusIsSuccess();
gfshConnector
- .executeAndVerifyCommand("create region --name=" + PARTITION_REGION + " --type=PARTITION");
+ .executeAndAssertThat("create region --name=" + PARTITION_REGION + " --type=PARTITION")
+ .statusIsSuccess();
gfshConnector
- .executeAndVerifyCommand("create region --name=" + DESTROY_REGION + " --type=REPLICATE");
-
- gfshConnector.executeAndVerifyCommand(
- "create index --name=" + INDEX1 + " --expression=AAPL --region=" + REPLICATE_REGION);
- gfshConnector.executeAndVerifyCommand(
- "create index --name=" + INDEX2 + " --expression=VMW --region=" + PARTITION_REGION);
+ .executeAndAssertThat("create region --name=" + DESTROY_REGION + " --type=REPLICATE")
+ .statusIsSuccess();
+ gfshConnector
+ .executeAndAssertThat(
+ "create index --name=" + INDEX1 + " --expression=AAPL --region=" + REPLICATE_REGION)
+ .statusIsSuccess();
+ gfshConnector
+ .executeAndAssertThat(
+ "create index --name=" + INDEX2 + " --expression=VMW --region=" + PARTITION_REGION)
+ .statusIsSuccess();
String asyncEventQueueJarPath = createAsyncEventQueueJar();
- gfshConnector.executeAndVerifyCommand("deploy --jar=" + asyncEventQueueJarPath);
+ gfshConnector.executeAndAssertThat("deploy --jar=" + asyncEventQueueJarPath).statusIsSuccess();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, AsyncEventQueue1);
@@ -101,13 +107,14 @@ public class ClusterConfigDistributionDUnitTest {
csb.addOptionWithValueCheck(CliStrings.GROUP, null);
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "false");
csb.addOptionWithValueCheck(CliStrings.CREATE_ASYNC_EVENT_QUEUE__MAXIMUM_QUEUE_MEMORY, "1000");
- gfshConnector.executeAndVerifyCommand(csb.getCommandString());
+ gfshConnector.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
- gfshConnector.executeAndVerifyCommand("destroy region --name=" + DESTROY_REGION);
+ gfshConnector.executeAndAssertThat("destroy region --name=" + DESTROY_REGION).statusIsSuccess();
- gfshConnector.executeAndVerifyCommand(
- "destroy index --name=" + INDEX2 + " --region=" + PARTITION_REGION);
- gfshConnector.executeAndVerifyCommand("alter runtime --copy-on-read=true");
+ gfshConnector
+ .executeAndAssertThat("destroy index --name=" + INDEX2 + " --region=" + PARTITION_REGION)
+ .statusIsSuccess();
+ gfshConnector.executeAndAssertThat("alter runtime --copy-on-read=true").statusIsSuccess();
// Start a new member which receives the shared configuration
// Verify the config creation on this member
@@ -170,7 +177,7 @@ public class ClusterConfigDistributionDUnitTest {
csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__IGNORE__UNREAD_FIELDS, "true");
csb.addOptionWithValueCheck(CliStrings.CONFIGURE_PDX__READ__SERIALIZED, "true");
- String message = gfshConnector.execute(csb.getCommandString());
- assertThat(message).contains(CliStrings.CONFIGURE_PDX__NORMAL__MEMBERS__WARNING);
+ gfshConnector.executeAndAssertThat(csb.getCommandString())
+ .containsOutput(CliStrings.CONFIGURE_PDX__NORMAL__MEMBERS__WARNING);
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
index b93cd2f..76a4175 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigImportDUnitTest.java
@@ -101,8 +101,10 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
@Test
public void testImportClusterConfig() throws Exception {
- gfshConnector.executeAndVerifyCommand(
- "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
+ gfshConnector
+ .executeAndAssertThat(
+ "import cluster-configuration --zip-file-name=" + clusterConfigZipPath)
+ .statusIsSuccess();
// Make sure that a backup of the old clusterConfig was created
assertThat(locatorVM.getWorkingDir().listFiles())
@@ -134,8 +136,10 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
"localhost[" + locatorVM.getPort() + "],localhost[" + locator1.getPort() + "]");
MemberVM locator2 = lsRule.startLocatorVM(2, locatorProps);
- gfshConnector.executeAndVerifyCommand(
- "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
+ gfshConnector
+ .executeAndAssertThat(
+ "import cluster-configuration --zip-file-name=" + clusterConfigZipPath)
+ .statusIsSuccess();
CONFIG_FROM_ZIP.verify(locatorVM);
REPLICATED_CONFIG_FROM_ZIP.verify(locator1);
@@ -159,7 +163,8 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
public void testExportClusterConfig(String zipFilePath) throws Exception {
MemberVM server1 = lsRule.startServerVM(1, serverProps, locatorVM.getPort());
- gfshConnector.executeAndVerifyCommand("create region --name=myRegion --type=REPLICATE");
+ gfshConnector.executeAndAssertThat("create region --name=myRegion --type=REPLICATE")
+ .statusIsSuccess();
ConfigGroup cluster = new ConfigGroup("cluster").regions("myRegion");
ClusterConfig expectedClusterConfig = new ClusterConfig(cluster);
@@ -167,7 +172,8 @@ public class ClusterConfigImportDUnitTest extends ClusterConfigTestBase {
expectedClusterConfig.verify(locatorVM);
gfshConnector
- .executeAndVerifyCommand("export cluster-configuration --zip-file-name=" + zipFilePath);
+ .executeAndAssertThat("export cluster-configuration --zip-file-name=" + zipFilePath)
+ .statusIsSuccess();
File exportedZip = new File(zipFilePath);
assertThat(exportedZip).exists();
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
index dbfbc9b..37a42c5 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigWithSecurityDUnitTest.java
@@ -93,8 +93,10 @@ public class ClusterConfigWithSecurityDUnitTest {
connector.connect(locator0, CliStrings.CONNECT__USERNAME, "cluster",
CliStrings.CONNECT__PASSWORD, "cluster");
- connector.executeAndVerifyCommand(
- "import cluster-configuration --zip-file-name=" + clusterConfigZipPath);
+ connector
+ .executeAndAssertThat(
+ "import cluster-configuration --zip-file-name=" + clusterConfigZipPath)
+ .statusIsSuccess();
locator0.invoke(() -> {
InternalLocator locator = LocatorServerStartupRule.locatorStarter.getLocator();
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
index d643b13..9d435bc 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportClusterConfigDistributedTest.java
@@ -59,8 +59,10 @@ public class ImportClusterConfigDistributedTest {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand("create region --name=replicateRegion --type=REPLICATE");
- gfsh.executeAndVerifyCommand("create region --name=partitionRegion --type=PARTITION");
+ gfsh.executeAndAssertThat("create region --name=replicateRegion --type=REPLICATE")
+ .statusIsSuccess();
+ gfsh.executeAndAssertThat("create region --name=partitionRegion --type=PARTITION")
+ .statusIsSuccess();
server.invoke(ImportClusterConfigDistributedTest::validateServerIsUsingClusterConfig);
@@ -68,8 +70,9 @@ public class ImportClusterConfigDistributedTest {
// do not create the file yet
this.exportedClusterConfig = new File(tempFolder.getRoot(), EXPORTED_CLUSTER_CONFIG_ZIP_NAME);
- gfsh.executeAndVerifyCommand(
- "export cluster-configuration --zip-file-name=" + exportedClusterConfig.getCanonicalPath());
+ gfsh.executeAndAssertThat(
+ "export cluster-configuration --zip-file-name=" + exportedClusterConfig.getCanonicalPath())
+ .statusIsSuccess();
gfsh.disconnect();
locator.stopMember();
@@ -103,8 +106,8 @@ public class ImportClusterConfigDistributedTest {
locator = lsRule.startLocatorVM(0);
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand("import cluster-configuration --zip-file-name="
- + this.exportedClusterConfig.getCanonicalPath());
+ gfsh.executeAndAssertThat("import cluster-configuration --zip-file-name="
+ + this.exportedClusterConfig.getCanonicalPath()).statusIsSuccess();
server = lsRule.startServerVM(1, locator.getPort());
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportOldClusterConfigDUnitTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportOldClusterConfigDUnitTest.java
index 55a1cb7..c78545a 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportOldClusterConfigDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/configuration/ImportOldClusterConfigDUnitTest.java
@@ -69,14 +69,14 @@ public class ImportOldClusterConfigDUnitTest {
gfsh.connectAndVerify(locator);
- gfsh.executeAndVerifyCommand(
- "import cluster-configuration --zip-file-name=" + zipFile.toString());
+ gfsh.executeAndAssertThat("import cluster-configuration --zip-file-name=" + zipFile.toString())
+ .statusIsSuccess();
server = lsRule.startServerVM(1, locator.getPort());
server.invoke(ImportOldClusterConfigDUnitTest::regionOneExists);
- gfsh.executeAndVerifyCommand("create region --name=two --type=REPLICATE");
+ gfsh.executeAndAssertThat("create region --name=two --type=REPLICATE").statusIsSuccess();
server.invoke(ImportOldClusterConfigDUnitTest::regionOneExists);
server.invoke(ImportOldClusterConfigDUnitTest::regionTwoExists);
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
index e40ba71..53d7676 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsPostProcessorTest.java
@@ -58,13 +58,13 @@ public class GfshCommandsPostProcessorTest {
gfshConnection.executeCommand("put --region=region1 --key=key3 --value=value3");
// for get command, assert the return value is processed
- String result = gfshConnection.execute("get --region=region1 --key=key1");
- assertThat(result).contains("dataWrite,dataRead/region1/key1/value1");
+ gfshConnection.executeAndAssertThat("get --region=region1 --key=key1")
+ .containsOutput("dataWrite,dataRead/region1/key1/value1");
// for query command, assert the return values are processed
- result = gfshConnection.execute("query --query=\"select * from /region1\"");
- assertThat(result).contains("dataWrite,dataRead/null/null/value1");
- assertThat(result).contains("dataWrite,dataRead/null/null/value2");
- assertThat(result).contains("dataWrite,dataRead/null/null/value3");
+ gfshConnection.executeAndAssertThat("query --query=\"select * from /region1\"")
+ .containsOutput("dataWrite,dataRead/null/null/value1")
+ .containsOutput("dataWrite,dataRead/null/null/value2")
+ .containsOutput("dataWrite,dataRead/null/null/value3");
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
index 648784f..9e3478cb 100644
--- a/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
+++ b/geode-core/src/test/java/org/apache/geode/management/internal/security/GfshCommandsSecurityTest.java
@@ -185,8 +185,8 @@ public class GfshCommandsSecurityTest {
@ConnectionConfiguration(user = "dataManage,clusterWriteDisk",
password = "dataManage,clusterWriteDisk")
public void createPartitionedPersistentRegionWithCorrectPermissions() throws Exception {
- gfshConnection
- .executeAndVerifyCommand("create region --name=region2 --type=PARTITION_PERSISTENT");
+ gfshConnection.executeAndAssertThat("create region --name=region2 --type=PARTITION_PERSISTENT")
+ .statusIsSuccess();
}
@Test
diff --git a/geode-core/src/test/java/org/apache/geode/security/PDXGfshPostProcessorOnRemoteServerTest.java b/geode-core/src/test/java/org/apache/geode/security/PDXGfshPostProcessorOnRemoteServerTest.java
index d8ba08b..03b73af 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PDXGfshPostProcessorOnRemoteServerTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PDXGfshPostProcessorOnRemoteServerTest.java
@@ -35,7 +35,6 @@ import org.apache.geode.cache.RegionShortcut;
import org.apache.geode.internal.cache.InternalCache;
import org.apache.geode.management.ManagementService;
import org.apache.geode.management.internal.cli.i18n.CliStrings;
-import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.pdx.SimpleClass;
import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
@@ -102,10 +101,10 @@ public class PDXGfshPostProcessorOnRemoteServerTest {
CliStrings.CONNECT__USERNAME, "dataUser", CliStrings.CONNECT__PASSWORD, "1234567");
// get command
- CommandResult result = gfsh.executeAndVerifyCommand("get --key=key1 --region=AuthRegion");
- assertTrue(result.getContent().toString().contains(SimpleClass.class.getName()));
+ gfsh.executeAndAssertThat("get --key=key1 --region=AuthRegion").statusIsSuccess()
+ .containsOutput(SimpleClass.class.getName());
- gfsh.executeAndVerifyCommand("query --query=\"select * from /AuthRegion\"");
+ gfsh.executeAndAssertThat("query --query=\"select * from /AuthRegion\"").statusIsSuccess();
serverVM.invoke(() -> {
PDXPostProcessor pp = (PDXPostProcessor) LocatorServerStartupRule.serverStarter.getCache()
diff --git a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
index 984c2f2..284a19d 100644
--- a/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/security/PDXPostProcessorDUnitTest.java
@@ -42,7 +42,6 @@ import org.apache.geode.cache.client.ClientRegionShortcut;
import org.apache.geode.cache.query.SelectResults;
import org.apache.geode.cache.util.CacheListenerAdapter;
import org.apache.geode.internal.cache.EntryEventImpl;
-import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.pdx.SimpleClass;
import org.apache.geode.test.dunit.Host;
import org.apache.geode.test.dunit.IgnoredException;
@@ -217,17 +216,17 @@ public class PDXPostProcessorDUnitTest extends JUnit4DistributedTestCase {
GfshShellConnectionRule.PortType.jmxManager, "dataUser", "1234567");
// get command
- CommandResult result = gfsh.executeAndVerifyCommand("get --key=key1 --region=AuthRegion");
+ gfsh.executeAndAssertThat("get --key=key1 --region=AuthRegion").statusIsSuccess();
if (this.pdxPersistent) {
assertThat(gfsh.getGfshOutput().contains("org.apache.geode.pdx.internal.PdxInstanceImpl"));
} else {
assertThat(gfsh.getGfshOutput()).contains("SimpleClass");
}
- result = gfsh.executeAndVerifyCommand("get --key=key2 --region=AuthRegion");
- assertThat(result.getContent().toString()).contains("byte[]");
+ gfsh.executeAndAssertThat("get --key=key2 --region=AuthRegion").statusIsSuccess()
+ .containsOutput("byte[]");
- gfsh.executeAndVerifyCommand("query --query=\"select * from /AuthRegion\"");
+ gfsh.executeAndAssertThat("query --query=\"select * from /AuthRegion\"").statusIsSuccess();
gfsh.close();
});
diff --git a/geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleAssert.java b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleAssert.java
new file mode 100644
index 0000000..79d54d9
--- /dev/null
+++ b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleAssert.java
@@ -0,0 +1,232 @@
+/*
+ * 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.test.junit.assertions;
+
+import static org.assertj.core.api.Assertions.assertThat;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Optional;
+
+import org.assertj.core.api.AbstractAssert;
+import org.assertj.core.api.Assertions;
+import org.json.JSONArray;
+
+import org.apache.geode.management.cli.Result;
+import org.apache.geode.management.internal.cli.json.GfJsonObject;
+import org.apache.geode.management.internal.cli.result.CommandResult;
+import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
+
+
+public class GfshShellConnectionRuleAssert
+ extends AbstractAssert<GfshShellConnectionRuleAssert, GfshShellConnectionRuleExecution> {
+ public GfshShellConnectionRuleAssert(GfshShellConnectionRule gfsh, CommandResult commandResult) {
+ super(new GfshShellConnectionRuleExecution(gfsh, commandResult),
+ GfshShellConnectionRuleAssert.class);
+ }
+
+ /**
+ * Verifies that the gfsh output contains the given key, value pair.
+ *
+ * For example, given the following gfsh output:
+ *
+ * <pre>
+ * {@code
+ * Result : true
+ * Key Class : java.lang.String
+ * Key : key92
+ * Locations Found : 2
+ * }
+ * </pre>
+ *
+ * We might assert that:
+ *
+ * <pre>
+ * <code> containsKeyValuePair("Key Class", "java.lang.String"); </code>
+ * </pre>
+ */
+ public GfshShellConnectionRuleAssert containsKeyValuePair(String key, String value) {
+ assertThat(actual.getGfshOutput()).containsPattern(key + "\\s+: " + value);
+
+ return this;
+ }
+
+ /**
+ * Verifies the gfsh output contains the given output
+ */
+ public GfshShellConnectionRuleAssert containsOutput(String... expectedOutputs) {
+ for (String expectedOutput : expectedOutputs) {
+ assertThat(actual.getGfshOutput()).contains(expectedOutput);
+ }
+
+ return this;
+ }
+
+ /**
+ * Verifies the gfsh output does not contain the given output
+ */
+ public GfshShellConnectionRuleAssert doesNotContainOutput(String... expectedOutputs) {
+ for (String expectedOutput : expectedOutputs) {
+ assertThat(actual.getGfshOutput()).doesNotContain(expectedOutput);
+ }
+
+ return this;
+ }
+
+ /**
+ * Verifies that gfsh executed with status OK
+ */
+ public GfshShellConnectionRuleAssert statusIsSuccess() {
+ CommandResult result = actual.getCommandResult();
+ Assertions.assertThat(result.getStatus()).describedAs(actual.getGfsh().getGfshOutput())
+ .isEqualTo(Result.Status.OK);
+
+ return this;
+ }
+
+ /**
+ * Verifies that gfsh executed with status ERROR
+ */
+ public GfshShellConnectionRuleAssert statusIsError() {
+ CommandResult result = actual.getCommandResult();
+ Assertions.assertThat(result.getStatus()).describedAs(actual.getGfsh().getGfshOutput())
+ .isEqualTo(Result.Status.ERROR);
+
+ return this;
+ }
+
+ /**
+ * Verifies that the gfsh output contains a table that has a column with the specified header and
+ * the specified values in the specified order.
+ *
+ * For example, given the following gfsh output:
+ *
+ * <pre>
+ * Index Name | Region Path | Server Name | Indexed Fields |
+ * ---------- | ----------- | ----------- | ------------------------ |
+ * index1 | /region1 | server-0 | [field1, field3, field2] |
+ * index2 | /region2 | server-0 | [field1, field3, field2] |
+ * </pre>
+ *
+ * We might assert that:
+ *
+ * <pre>
+ * <code> tableHasColumnWithExactValuesInExactOrder("Region Path", "/region1", "/region2");
+ * </code>
+ * </pre>
+ */
+ public GfshShellConnectionRuleAssert tableHasColumnWithExactValuesInExactOrder(String header,
+ Object... expectedValues) {
+ GfJsonObject resultContentJSON = actual.getCommandResult().getContent();
+ Object content = resultContentJSON.get(header);
+
+ if (content == null) {
+ failWithMessage(
+ "Command result did not contain <" + header + ">: " + resultContentJSON.toString());
+ }
+
+ Object[] actualValues = toArray((JSONArray) content);
+ assertThat(actualValues).containsExactly(expectedValues);
+
+ return this;
+ }
+
+ /**
+ * Verifies that the gfsh output contains a table that has a column with the specified header and
+ * the specified values in any order.
+ *
+ * For example, given the following gfsh output:
+ *
+ * <pre>
+ * Index Name | Region Path | Server Name | Indexed Fields |
+ * ---------- | ----------- | ----------- | ------------------------ |
+ * index1 | /region1 | server-0 | [field1, field3, field2] |
+ * index2 | /region2 | server-0 | [field1, field3, field2] |
+ *
+ * </pre>
+ *
+ * We might assert that:
+ *
+ * <pre>
+ * <code> tableHasColumnWithExactValuesInAnyOrder("Region Path", "/region2", "/region1"); </code>
+ * </pre>
+ */
+ public GfshShellConnectionRuleAssert tableHasColumnWithExactValuesInAnyOrder(String header,
+ Object... expectedValues) {
+ GfJsonObject resultContentJSON = actual.getCommandResult().getContent();
+ Object content = resultContentJSON.get(header);
+
+ if (content == null) {
+ failWithMessage("Command result did not contain a table with column header <" + header + ">: "
+ + resultContentJSON.toString());
+ }
+
+ Object[] actualValues = toArray((JSONArray) content);
+ assertThat(actualValues).containsExactlyInAnyOrder(expectedValues);
+
+ return this;
+ }
+
+ /**
+ * Verifies that each of the actual values in the column with the given header contains at least
+ * one of the expectedValues.
+ */
+ public GfshShellConnectionRuleAssert tableHasColumnWithValuesContaining(String header,
+ String... expectedValues) {
+ GfJsonObject resultContentJSON = actual.getCommandResult().getContent();
+ Object content = resultContentJSON.get(header);
+
+ if (content == null) {
+ failWithMessage("Command result did not contain a table with column header <" + header + ">: "
+ + resultContentJSON.toString());
+ }
+
+ Object[] actualValues = toArray((JSONArray) content);
+
+ for (Object actualValue : actualValues) {
+ String actualValueString = (String) actualValue;
+ boolean actualValueContainsAnExpectedValue =
+ Arrays.stream(expectedValues).anyMatch(actualValueString::contains);
+
+ if (!actualValueContainsAnExpectedValue) {
+ failWithMessage("Found unexpected value: " + actualValue);
+ }
+ }
+
+ return this;
+ }
+
+ public GfshShellConnectionRuleAssert hasResult() {
+ containsKeyValuePair("Result", "true");
+
+ return this;
+ }
+
+ public GfshShellConnectionRuleAssert hasNoResult() {
+ containsKeyValuePair("Result", "false");
+
+ return this;
+ }
+
+ private Object[] toArray(JSONArray array) {
+ Object[] values = new Object[array.length()];
+
+ for (int i = 0; i < array.length(); i++) {
+ values[i] = array.get(i);
+ }
+
+ return values;
+ }
+}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleExecution.java
similarity index 57%
copy from geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
copy to geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleExecution.java
index 12d93fa..b4c3003 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
+++ b/geode-core/src/test/java/org/apache/geode/test/junit/assertions/GfshShellConnectionRuleExecution.java
@@ -12,18 +12,31 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
*/
+package org.apache.geode.test.junit.assertions;
-package org.apache.geode.management.internal.cli.commands;
-
-import org.apache.geode.test.dunit.rules.MemberVM;
-import org.apache.geode.test.junit.categories.DistributedTest;
+import org.apache.geode.management.internal.cli.result.CommandResult;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
-import org.junit.experimental.categories.Category;
-@Category(DistributedTest.class)
-public class FunctionCommandsOverHttpDUnitTest extends FunctionCommandsDUnitTest {
- @Override
- public void connectGfsh(MemberVM vm) throws Exception {
- gfsh.connectAndVerify(vm.getHttpPort(), GfshShellConnectionRule.PortType.http);
+public class GfshShellConnectionRuleExecution {
+ private GfshShellConnectionRule gfsh;
+ private CommandResult commandResult;
+
+ public GfshShellConnectionRuleExecution(GfshShellConnectionRule gfsh,
+ CommandResult commandResult) {
+
+ this.gfsh = gfsh;
+ this.commandResult = commandResult;
+ }
+
+ public GfshShellConnectionRule getGfsh() {
+ return gfsh;
+ }
+
+ public CommandResult getCommandResult() {
+ return commandResult;
+ }
+
+ public String getGfshOutput() {
+ return gfsh.getGfshOutput();
}
}
diff --git a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshShellConnectionRule.java b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshShellConnectionRule.java
index 9c869b2..ac9a0c9 100644
--- a/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshShellConnectionRule.java
+++ b/geode-core/src/test/java/org/apache/geode/test/junit/rules/GfshShellConnectionRule.java
@@ -34,6 +34,7 @@ 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.util.CommandStringBuilder;
import org.apache.geode.test.dunit.IgnoredException;
+import org.apache.geode.test.junit.assertions.GfshShellConnectionRuleAssert;
/**
* Class which eases the connection to the locator/jmxManager in Gfsh shell and execute gfsh
@@ -208,10 +209,6 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
gfsh = null;
}
- public HeadlessGfsh getHeadlessGfsh() {
- return gfsh;
- }
-
public Gfsh getGfsh() {
return gfsh.getGfsh();
}
@@ -241,11 +238,18 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
return result;
}
+ public GfshShellConnectionRuleAssert executeAndAssertThat(String command) {
+ CommandResult commandResult = executeCommand(command);
+ return new GfshShellConnectionRuleAssert(this, commandResult);
+ }
+
+
public String getGfshOutput() {
return gfsh.outputString;
}
- public CommandResult executeAndVerifyCommand(String command, String... expectedOutputs) {
+ @Deprecated
+ public void executeAndVerifyCommand(String command, String... expectedOutputs) {
CommandResult result = null;
try {
result = executeCommand(command);
@@ -256,22 +260,8 @@ public class GfshShellConnectionRule extends DescribedExternalResource {
for (String expectedOutput : expectedOutputs) {
assertThat(getGfshOutput()).containsPattern(expectedOutput);
}
- return result;
}
- public CommandResult executeAndVerifyCommandError(String command, String... expectedOutputs) {
- CommandResult result = null;
- try {
- result = executeCommand(command);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
- assertThat(result.getStatus()).describedAs(getGfshOutput()).isEqualTo(Result.Status.ERROR);
- for (String expectedOutput : expectedOutputs) {
- assertThat(getGfshOutput()).containsPattern(expectedOutput);
- }
- return result;
- }
public String execute(String command) throws Exception {
executeCommand(command);
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 1012f6b..acc237e 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
@@ -197,10 +197,10 @@ public class LuceneCommandsSecurityDUnitTest {
GfshShellConnectionRule.PortType.locator, "cluster,data", "cluster,data");
// Create lucene index
- this.gfshShell.executeAndVerifyCommand(getCreateIndexCommand());
+ this.gfshShell.executeAndAssertThat(getCreateIndexCommand()).statusIsSuccess();
// Create region
- this.gfshShell.executeAndVerifyCommand(getCreateRegionCommand());
+ this.gfshShell.executeAndAssertThat(getCreateRegionCommand()).statusIsSuccess();
// Disconnect gfsh
this.gfshShell.disconnect();
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 c563df5..5418f97 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
@@ -29,7 +29,6 @@ import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.concurrent.TimeUnit;
-import java.util.stream.IntStream;
import junitparams.JUnitParamsRunner;
import junitparams.Parameters;
@@ -58,12 +57,10 @@ import org.apache.geode.internal.i18n.LocalizedStrings;
import org.apache.geode.management.cli.Result.Status;
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.Host;
-import org.apache.geode.test.dunit.VM;
import org.apache.geode.test.dunit.rules.LocatorServerStartupRule;
import org.apache.geode.test.dunit.rules.MemberVM;
+import org.apache.geode.test.junit.assertions.GfshShellConnectionRuleAssert;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
import org.apache.geode.test.junit.rules.serializable.SerializableTestName;
@@ -101,21 +98,23 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true");
- gfsh.executeAndVerifyCommand(csb.toString(), INDEX_NAME, "Documents");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Documents", 0)
+ .tableHasColumnWithExactValuesInAnyOrder("Index Name", "index");
}
@Test
public void listIndexShouldReturnExistingIndexWithoutStats() throws Exception {
createIndex();
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
- gfsh.executeAndVerifyCommand(csb.toString(), INDEX_NAME);
- assertThat(gfsh.getGfshOutput()).doesNotContain("Documents");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(INDEX_NAME)
+ .doesNotContainOutput("Documents");
}
@Test
public void listIndexWhenNoExistingIndexShouldReturnNoIndex() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
- gfsh.executeAndVerifyCommand(csb.toString(), "No lucene indexes found");
+ gfsh.executeAndAssertThat(csb.toString()).containsOutput("No lucene indexes found");
}
@Test
@@ -124,10 +123,10 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(Collections.singletonList(INDEX_NAME), data.retrieveAllValues("Index Name"));
- assertEquals(Collections.singletonList("Defined"), data.retrieveAllValues("Status"));
+
+ gfsh.executeAndAssertThat(csb.toString())
+ .tableHasColumnWithExactValuesInAnyOrder("Status", "Defined")
+ .tableHasColumnWithExactValuesInAnyOrder("Index Name", INDEX_NAME);
}
@Test
@@ -142,18 +141,19 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
csb.addOption(LuceneCliStrings.LUCENE_LIST_INDEX__STATS, "true");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(Collections.singletonList(INDEX_NAME), data.retrieveAllValues("Index Name"));
- assertEquals(Collections.singletonList("Initialized"), data.retrieveAllValues("Status"));
- assertEquals(Collections.singletonList("/region"), data.retrieveAllValues("Region Path"));
- assertEquals(Collections.singletonList("1"), data.retrieveAllValues("Query Executions"));
- assertEquals(Collections.singletonList("2"), data.retrieveAllValues("Commits"));
- assertEquals(Collections.singletonList("2"), data.retrieveAllValues("Updates"));
- assertEquals(Collections.singletonList("2"), data.retrieveAllValues("Documents"));
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("Index Name", INDEX_NAME)
+ .tableHasColumnWithExactValuesInAnyOrder("Status", "Initialized")
+ .tableHasColumnWithExactValuesInAnyOrder("Region Path", "/region")
+ .tableHasColumnWithExactValuesInAnyOrder("Query Executions", 1)
+ .tableHasColumnWithExactValuesInAnyOrder("Commits", 2)
+ .tableHasColumnWithExactValuesInAnyOrder("Updates", 2)
+ .tableHasColumnWithExactValuesInAnyOrder("Documents", 2);
+
}
+
@Test
public void createIndexShouldCreateANewIndex() throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
@@ -161,7 +161,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -184,7 +184,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, String.join(",", analyzerNames));
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -206,7 +206,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__SERIALIZER,
PrimitiveSerializer.class.getCanonicalName());
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -224,7 +224,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, "\'__\'");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString(),
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(
"Region names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens, underscores, or forward slashes:");
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
@@ -232,7 +232,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, "\' @@@*%\'");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString(),
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(
"Region names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens, underscores, or forward slashes:");
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
@@ -240,7 +240,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString(),
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(
"Index names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens or underscores:");
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_CREATE_INDEX);
@@ -248,7 +248,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString(),
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(
"Index names may only be alphanumeric, must not begin with double-underscores, but can contain hyphens or underscores:");
}
@@ -266,7 +266,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER,
"\"org.apache.lucene.analysis.standard.StandardAnalyzer, org.apache.lucene.analysis.core.KeywordAnalyzer, org.apache.lucene.analysis.standard.StandardAnalyzer\"");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -286,7 +286,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneServiceImpl luceneService = (LuceneServiceImpl) LuceneServiceProvider.get(getCache());
@@ -309,7 +309,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, "'" + analyzerList + "'");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
// Test empty analyzer name
analyzerList =
@@ -320,7 +320,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, analyzerList);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
// Test keyword analyzer name
analyzerList = StandardAnalyzer.class.getCanonicalName() + ",DEFAULT,"
@@ -331,7 +331,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "field1,field2,field3");
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__ANALYZER, analyzerList);
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> {
LuceneService luceneService = LuceneServiceProvider.get(getCache());
@@ -378,7 +378,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
- gfsh.executeAndVerifyCommand(csb.toString(), INDEX_NAME);
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(INDEX_NAME);
}
@Test
@@ -390,14 +390,14 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__SERIALIZER,
PrimitiveSerializer.class.getCanonicalName());
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
serverVM.invoke(() -> createRegion());
csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
- String resultAsString = gfsh.executeAndVerifyCommand(csb.toString()).toString();
- assertThat(resultAsString).contains(PrimitiveSerializer.class.getSimpleName());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(PrimitiveSerializer.class.getSimpleName());
}
@Test
@@ -407,7 +407,8 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "notAnIndex");
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
- gfsh.executeAndVerifyCommand(csb.toString(), "No lucene indexes found");
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput("No lucene indexes found");
}
@Test
@@ -416,7 +417,7 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_DESCRIBE_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, "notAnIndex");
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
- gfsh.executeAndVerifyCommand(csb.toString(), REGION_NAME);
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess().containsOutput(REGION_NAME);
}
@Test
@@ -439,9 +440,8 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(4, data.retrieveAllValues("key").size());
+ gfsh.executeAndAssertThat(csb.toString()).tableHasColumnWithExactValuesInAnyOrder("key", "E",
+ "A", "G", "C");
}
@Test
@@ -462,16 +462,15 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:jon~");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(4, data.retrieveAllValues("key").size());
-
- // confirm the order
- List<String> scoreRatings = data.retrieveAllValues("score");
- boolean inOrder = IntStream.range(0, scoreRatings.size() - 1)
- .allMatch(index -> scoreRatings.get(index).compareTo(scoreRatings.get(index + 1)) >= 0);
- assertTrue("Lucene search result not in expected order", inOrder);
+ GfshShellConnectionRuleAssert assertion =
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
+ try {
+ assertion.tableHasColumnWithExactValuesInExactOrder("key", "A", "B", "C", "D");
+ } catch (AssertionError e) {
+ // Since B and C have the same score, we can expect them to appear in either order
+ assertion.tableHasColumnWithExactValuesInExactOrder("key", "A", "C", "B", "D");
+ }
}
@Test
@@ -494,8 +493,8 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "NotAnExistingValue");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
- gfsh.executeAndVerifyCommand(csb.toString(),
- LuceneCliStrings.LUCENE_SEARCH_INDEX__NO_RESULTS_MESSAGE);
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(LuceneCliStrings.LUCENE_SEARCH_INDEX__NO_RESULTS_MESSAGE);
}
@Test
@@ -518,9 +517,9 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "field1:value1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__LIMIT, "2");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(2, data.retrieveAllValues("key").size());
+
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("key", "A", "G");
}
@Test
@@ -543,14 +542,12 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "QWE");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field2");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(1, data.retrieveAllValues("key").size());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("key", "C");
}
@Test
public void searchOnIndexWithoutRegionShouldReturnError() throws Exception {
-
createIndexWithoutRegion();
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, INDEX_NAME);
@@ -558,12 +555,12 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__QUERY_STRING, "EFG");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field2");
- gfsh.executeAndVerifyCommand(csb.toString(), getRegionNotFoundErrorMessage("/region"));
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .containsOutput(getRegionNotFoundErrorMessage("/region"));
}
@Test
public void searchWithoutIndexShouldReturnError() throws Exception {
-
serverVM.invoke(() -> createRegion());
CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_SEARCH_INDEX);
@@ -603,9 +600,8 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__DEFAULT_FIELD, "field1");
csb.addOption(LuceneCliStrings.LUCENE_SEARCH_INDEX__KEYSONLY, "true");
- TabularResultData data =
- (TabularResultData) gfsh.executeAndVerifyCommand(csb.toString()).getResultData();
- assertEquals(4, data.retrieveAllValues("key").size());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInAnyOrder("key", "C", "G", "E", "A");
}
@Test
@@ -620,8 +616,8 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
String expectedStatus = CliStrings.format(
LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1,
new Object[] {"index", "/region"});
- gfsh.executeAndVerifyCommand("destroy lucene index --name=index --region=region",
- expectedStatus);
+ gfsh.executeAndAssertThat("destroy lucene index --name=index --region=region").statusIsSuccess()
+ .containsOutput(expectedStatus);
}
@Test
@@ -632,10 +628,13 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
} else {
createIndexWithoutRegion();
}
- gfsh.executeAndVerifyCommand("destroy lucene index --region=region",
- CliStrings.format(
- LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0,
- new Object[] {"/region"}));
+
+ String expectedOutput = CliStrings.format(
+ LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0,
+ new Object[] {"/region"});
+
+ gfsh.executeAndAssertThat("destroy lucene index --region=region").statusIsSuccess()
+ .containsOutput(expectedOutput);
}
@Test
@@ -644,16 +643,18 @@ public class LuceneIndexCommandsDUnitTest implements Serializable {
String expectedStatus = LocalizedStrings.LuceneService_INDEX_0_NOT_FOUND_IN_REGION_1
.toLocalizedString(new Object[] {INDEX_NAME, '/' + REGION_NAME});
- gfsh.executeAndVerifyCommand("destroy lucene index --name=index --region=region",
- expectedStatus);
+ gfsh.executeAndAssertThat("destroy lucene index --name=index --region=region").statusIsSuccess()
+ .containsOutput(expectedStatus);
}
@Test
public void testDestroyNonExistentIndexes() throws Exception {
serverVM.invoke(() -> createRegion());
- gfsh.executeAndVerifyCommand("destroy lucene index --region=region",
- LocalizedStrings.LuceneService_NO_INDEXES_WERE_FOUND_IN_REGION_0
- .toLocalizedString(new Object[] {"/region"}));
+
+ String expectedOutput = LocalizedStrings.LuceneService_NO_INDEXES_WERE_FOUND_IN_REGION_0
+ .toLocalizedString(new Object[] {"/region"});
+ gfsh.executeAndAssertThat("destroy lucene index --region=region").statusIsSuccess()
+ .containsOutput(expectedOutput);
}
private void createRegion() {
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 b3d3251..7e6cdc6 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
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -43,8 +42,6 @@ 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.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.management.internal.configuration.domain.Configuration;
import org.apache.geode.test.dunit.SerializableRunnableIF;
@@ -209,26 +206,24 @@ public class LuceneClusterConfigurationDUnitTest {
createRegionUsingGfsh(REGION_NAME, RegionShortcut.PARTITION, null);
// Alter region in group
- CommandResult alterRegionResult = alterRegionUsingGfsh(group);
- TabularResultData alterRegionResultData = (TabularResultData) alterRegionResult.getResultData();
- List<String> alterRegionResultDataStatus = alterRegionResultData.retrieveAllValues("Status");
+ CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_REGION);
+ csb.addOption(CliStrings.ALTER_REGION__REGION, REGION_NAME);
+ csb.addOption(CliStrings.GROUP, group);
+ csb.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
- // Verify region is altered on only one server
- assertEquals(1, alterRegionResultDataStatus.size());
- assertEquals("Region \"/" + REGION_NAME + "\" altered on \"" + vm2.getName() + "\"",
- alterRegionResultDataStatus.get(0));
+ String expectedStatusOutput =
+ "Region \"/" + REGION_NAME + "\" altered on \"" + vm2.getName() + "\"";
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInExactOrder("Status", expectedStatusOutput);
// Start another member with group
ls.startServerVM(3, properties, locator.getPort());
// Verify all members have indexes
- CommandResult listIndexesResult = listIndexesUsingGfsh();
- TabularResultData listIndexesResultData = (TabularResultData) listIndexesResult.getResultData();
- List<String> listIndexesResultDataStatus = listIndexesResultData.retrieveAllValues("Status");
- assertEquals(3, listIndexesResultDataStatus.size());
- for (String status : listIndexesResultDataStatus) {
- assertEquals("Initialized", status);
- }
+ csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess()
+ .tableHasColumnWithExactValuesInExactOrder("Status", "Initialized", "Initialized",
+ "Initialized");
}
private void createAndAddIndexes() throws Exception {
@@ -278,7 +273,7 @@ public class LuceneClusterConfigurationDUnitTest {
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName);
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
csb.addOption(LuceneCliStrings.LUCENE_CREATE_INDEX__FIELD, "'field1, field2, field3'");
- gfshConnector.executeAndVerifyCommand(csb.toString());
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createLuceneIndexWithAnalyzerUsingGfsh() throws Exception {
@@ -293,7 +288,7 @@ public class LuceneClusterConfigurationDUnitTest {
+ "org.apache.lucene.analysis.standard.StandardAnalyzer");
// Execute Gfsh command.
- gfshConnector.executeAndVerifyCommand(csb.toString());
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createLuceneIndexWithSerializerUsingGfsh(boolean addGroup) throws Exception {
@@ -306,7 +301,7 @@ public class LuceneClusterConfigurationDUnitTest {
PrimitiveSerializer.class.getCanonicalName());
// Execute Gfsh command.
- gfshConnector.executeAndVerifyCommand(csb.toString());
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void destroyLuceneIndexUsingGfsh(String indexName) throws Exception {
@@ -316,7 +311,7 @@ public class LuceneClusterConfigurationDUnitTest {
csb.addOption(LuceneCliStrings.LUCENE__INDEX_NAME, indexName);
}
csb.addOption(LuceneCliStrings.LUCENE__REGION_PATH, REGION_NAME);
- gfshConnector.executeAndVerifyCommand(csb.toString());
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createRegionUsingGfsh(String regionName, RegionShortcut regionShortCut, String group)
@@ -325,20 +320,7 @@ public class LuceneClusterConfigurationDUnitTest {
csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
csb.addOptionWithValueCheck(CliStrings.GROUP, group);
- gfshConnector.executeAndVerifyCommand(csb.toString());
- }
-
- private CommandResult alterRegionUsingGfsh(String group) throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_REGION);
- csb.addOption(CliStrings.ALTER_REGION__REGION, REGION_NAME);
- csb.addOption(CliStrings.GROUP, group);
- csb.addOption(CliStrings.ALTER_REGION__EVICTIONMAX, "5764");
- return gfshConnector.executeAndVerifyCommand(csb.toString());
- }
-
- private CommandResult listIndexesUsingGfsh() throws Exception {
- CommandStringBuilder csb = new CommandStringBuilder(LuceneCliStrings.LUCENE_LIST_INDEX);
- return gfshConnector.executeAndVerifyCommand(csb.toString());
+ gfshConnector.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private static void validateIndexFields(String[] indexFields, LuceneIndex index) {
diff --git a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationIndexWithFromClauseDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationIndexWithFromClauseDUnitTest.java
index b2e505b..55e31d2 100644
--- a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationIndexWithFromClauseDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/ClusterConfigurationIndexWithFromClauseDUnitTest.java
@@ -70,7 +70,7 @@ public class ClusterConfigurationIndexWithFromClauseDUnitTest {
createIndexUsingGfsh("\"" + REGION_NAME + ".entrySet() z\"", "z.key", INDEX_NAME);
String serverName = vm1.getName();
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_MEMBER);
- gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess();
lsRule.stopVM(1);
lsRule.startServerVM(1, locator.getPort());
verifyIndexRecreated(INDEX_NAME);
@@ -78,7 +78,7 @@ public class ClusterConfigurationIndexWithFromClauseDUnitTest {
private void verifyIndexRecreated(String indexName) throws Exception {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.LIST_INDEX);
- gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess();
String resultAsString = gfshShellConnectionRule.getGfshOutput();
assertTrue(resultAsString.contains(indexName));
}
@@ -89,7 +89,7 @@ public class ClusterConfigurationIndexWithFromClauseDUnitTest {
csb.addOption(CliStrings.CREATE_INDEX__EXPRESSION, expression);
csb.addOption(CliStrings.CREATE_INDEX__REGION, regionName);
csb.addOption(CliStrings.CREATE_INDEX__NAME, indexName);
- gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
private void createRegionUsingGfsh(String regionName, RegionShortcut regionShortCut, String group)
@@ -98,6 +98,6 @@ public class ClusterConfigurationIndexWithFromClauseDUnitTest {
csb.addOption(CliStrings.CREATE_REGION__REGION, regionName);
csb.addOption(CliStrings.CREATE_REGION__REGIONSHORTCUT, regionShortCut.name());
csb.addOptionWithValueCheck(CliStrings.GROUP, group);
- gfshShellConnectionRule.executeAndVerifyCommand(csb.toString());
+ gfshShellConnectionRule.executeAndAssertThat(csb.toString()).statusIsSuccess();
}
}
diff --git a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WANClusterConfigurationDUnitTest.java b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WANClusterConfigurationDUnitTest.java
index ce6cd7e..c91fc6b 100644
--- a/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WANClusterConfigurationDUnitTest.java
+++ b/geode-wan/src/test/java/org/apache/geode/management/internal/configuration/WANClusterConfigurationDUnitTest.java
@@ -89,7 +89,7 @@ public class WANClusterConfigurationDUnitTest {
csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__ENDPORT, "20000");
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYRECEIVER__MAXTIMEBETWEENPINGS, "20");
csb.addOption(CliStrings.CREATE_GATEWAYRECEIVER__HOSTNAMEFORSENDERS, "myLocalHost");
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
// create GatewaySender
csb = new CommandStringBuilder(CliStrings.CREATE_GATEWAYSENDER);
@@ -112,7 +112,7 @@ public class WANClusterConfigurationDUnitTest {
csb.addOptionWithValueCheck(CliStrings.CREATE_GATEWAYSENDER__SOCKETREADTIMEOUT,
socketReadTimeout);
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
// Start a new member which receives the shared configuration
// Verify the config creation on this member
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
index f99b6f0..d5d83e2 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/AlterRuntimeCommandDUnitTest.java
@@ -100,7 +100,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "true");
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
server0.invoke(() -> {
InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -145,7 +145,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -181,7 +181,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csbSetFileSizeLimit =
new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csbSetFileSizeLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "50");
- gfsh.executeAndVerifyCommand(csbSetFileSizeLimit.toString());
+ gfsh.executeAndAssertThat(csbSetFileSizeLimit.toString()).statusIsSuccess();
server2.invoke(() -> {
InternalCache cache = LocatorServerStartupRule.serverStarter.getCache();
@@ -194,7 +194,7 @@ public class AlterRuntimeCommandDUnitTest {
new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csbSetDiskSpaceLimit.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
- gfsh.executeAndVerifyCommand(csbSetDiskSpaceLimit.toString());
+ gfsh.executeAndAssertThat(csbSetDiskSpaceLimit.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -230,7 +230,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.MEMBERS, server1.getName());
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT, "10");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -276,7 +276,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__DISK__SPACE__LIMIT,
String.valueOf(TEST_LIMIT));
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -322,7 +322,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__LOG__FILE__SIZE__LIMIT, "11");
- gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -432,7 +432,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -470,7 +470,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
csb.addOption(CliStrings.MEMBERS, server1.getName());
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (final MemberVM server : new MemberVM[] {server1, server2}) {
String expectedName;
@@ -515,7 +515,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__ARCHIVE__FILE, TEST_NAME);
csb.addOption(CliStrings.GROUP, "G1");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
String expectedName;
@@ -557,7 +557,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLE__RATE, "2000");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -596,7 +596,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_RATE));
csb.addOption(CliStrings.MEMBER, server1.getName());
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (final MemberVM server : new MemberVM[] {server1, server2}) {
int expectedSampleRate;
@@ -642,7 +642,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_RATE));
csb.addOption(CliStrings.GROUP, "G1");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
int expectedSampleRate;
@@ -723,7 +723,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__DISK__SPACE__LIMIT,
String.valueOf(TEST_LIMIT));
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -763,7 +763,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_LIMIT));
csb.addOption(CliStrings.MEMBER, server1.getName());
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (final MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -810,7 +810,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_LIMIT));
csb.addOption(CliStrings.GROUP, "G1");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -905,7 +905,7 @@ public class AlterRuntimeCommandDUnitTest {
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__ARCHIVE__FILE__SIZE__LIMIT,
String.valueOf(TEST_LIMIT));
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -945,7 +945,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_LIMIT));
csb.addOption(CliStrings.MEMBER, server1.getName());
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (final MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -992,7 +992,7 @@ public class AlterRuntimeCommandDUnitTest {
String.valueOf(TEST_LIMIT));
csb.addOption(CliStrings.GROUP, "G1");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
int expectedLimit;
@@ -1072,7 +1072,7 @@ public class AlterRuntimeCommandDUnitTest {
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.ALTER_RUNTIME_CONFIG);
csb.addOption(CliStrings.ALTER_RUNTIME_CONFIG__STATISTIC__SAMPLING__ENABLED, "false");
- CommandResult result = gfsh.executeAndVerifyCommand(csb.toString());
+ gfsh.executeAndAssertThat(csb.toString()).statusIsSuccess();
for (MemberVM server : new MemberVM[] {server1, server2}) {
server.invoke(() -> {
@@ -1193,7 +1193,7 @@ public class AlterRuntimeCommandDUnitTest {
startupRule.startServerVM(1, props, locator.getPort());
String command = "alter runtime --group=Group1 --log-level=fine";
- gfsh.executeAndVerifyCommand(command);
+ gfsh.executeAndAssertThat(command).statusIsSuccess();
locator.invoke(() -> {
ClusterConfigurationService sharedConfig =
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ClusterConfigurationDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ClusterConfigurationDUnitTest.java
index 4201a15..415bf67 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ClusterConfigurationDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ClusterConfigurationDUnitTest.java
@@ -72,26 +72,27 @@ public class ClusterConfigurationDUnitTest {
MemberVM server2 = startupRule.startServerVM(2, locator.getPort());
// create regions, index and asyncEventQueue
- gfsh.executeAndVerifyCommand("create region --name=R1 --type=REPLICATE");
- gfsh.executeAndVerifyCommand("create region --name=R2 --type=PARTITION");
- gfsh.executeAndVerifyCommand("create index --name=ID1 --expression=AAPL --region=R1");
+ gfsh.executeAndAssertThat("create region --name=R1 --type=REPLICATE").statusIsSuccess();
+ gfsh.executeAndAssertThat("create region --name=R2 --type=PARTITION").statusIsSuccess();
+ gfsh.executeAndAssertThat("create index --name=ID1 --expression=AAPL --region=R1")
+ .statusIsSuccess();
createAsyncEventQueue("Q1");
MemberVM server3 = startupRule.startServerVM(3, locator.getPort());
- gfsh.executeAndVerifyCommand("describe region --name=R1");
+ gfsh.executeAndAssertThat("describe region --name=R1").statusIsSuccess();
verifyContainsAllServerNames(gfsh.getGfshOutput(), server1.getName(), server2.getName(),
server3.getName());
- gfsh.executeAndVerifyCommand("describe region --name=R2");
+ gfsh.executeAndAssertThat("describe region --name=R2").statusIsSuccess();
verifyContainsAllServerNames(gfsh.getGfshOutput(), server1.getName(), server2.getName(),
server3.getName());
- gfsh.executeAndVerifyCommand("list indexes");
+ gfsh.executeAndAssertThat("list indexes").statusIsSuccess();
verifyContainsAllServerNames(gfsh.getGfshOutput(), server1.getName(), server2.getName(),
server3.getName());
- gfsh.executeAndVerifyCommand("list async-event-queues");
+ gfsh.executeAndAssertThat("list async-event-queues").statusIsSuccess();
verifyContainsAllServerNames(gfsh.getGfshOutput(), server1.getName(), server2.getName(),
server3.getName());
}
@@ -121,7 +122,7 @@ public class ClusterConfigurationDUnitTest {
FileUtils.writeByteArrayToFile(jarFile, jarBytes);
CommandStringBuilder csb = new CommandStringBuilder(CliStrings.DEPLOY);
csb.addOption(CliStrings.JAR, jarFile.getAbsolutePath());
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
csb = new CommandStringBuilder(CliStrings.CREATE_ASYNC_EVENT_QUEUE);
csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__ID, queueName);
@@ -139,6 +140,6 @@ public class ClusterConfigurationDUnitTest {
csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PERSISTENT, "true");
csb.addOption(CliStrings.CREATE_ASYNC_EVENT_QUEUE__PARALLEL, "true");
- gfsh.executeAndVerifyCommand(csb.getCommandString());
+ gfsh.executeAndAssertThat(csb.getCommandString()).statusIsSuccess();
}
}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpTest.java
index 2533e7d..3166f32 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/CommandOverHttpTest.java
@@ -67,8 +67,8 @@ public class CommandOverHttpTest {
@Test
public void exportLogs() throws Exception {
- CommandResult result = gfshRule.executeAndVerifyCommand("export logs");
- assertThat(result.getContent().toString()).contains("Logs exported to:");
+ gfshRule.executeAndAssertThat("export logs").statusIsSuccess()
+ .containsOutput("Logs exported to:");
}
@Test
@@ -77,15 +77,14 @@ public class CommandOverHttpTest {
String jarName = "deployCommand.jar";
File jar = temporaryFolder.newFile(jarName);
new ClassBuilder().writeJarFromName(className, jar);
- gfshRule.executeAndVerifyCommand("deploy --jar=" + jar);
+ gfshRule.executeAndAssertThat("deploy --jar=" + jar).statusIsSuccess();
}
@Test
public void exportConfig() throws Exception {
String dir = temporaryFolder.getRoot().getAbsolutePath();
- gfshRule.executeAndVerifyCommand("export config --dir=" + dir);
- String result = gfshRule.getGfshOutput();
- assertThat(result).contains("Downloading Cache XML file: " + dir + "/server-cache.xml");
- assertThat(result).contains("Downloading properties file: " + dir + "/server-gf.properties");
+ gfshRule.executeAndAssertThat("export config --dir=" + dir).statusIsSuccess()
+ .containsOutput("Downloading Cache XML file: " + dir + "/server-cache.xml")
+ .containsOutput("Downloading properties file: " + dir + "/server-gf.properties");
}
}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSecurityTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSecurityTest.java
index 4b42b2e..b49363b 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSecurityTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ConnectCommandWithSecurityTest.java
@@ -39,20 +39,20 @@ public class ConnectCommandWithSecurityTest {
public void connectToLocator() throws Exception {
gfsh.secureConnectAndVerify(locator.getPort(), GfshShellConnectionRule.PortType.locator,
"clusterRead", "clusterRead");
- gfsh.executeAndVerifyCommand("list members");
+ gfsh.executeAndAssertThat("list members").statusIsSuccess();
}
@Test
public void connectOverJmx() throws Exception {
gfsh.secureConnectAndVerify(locator.getJmxPort(), GfshShellConnectionRule.PortType.jmxManager,
"clusterRead", "clusterRead");
- gfsh.executeAndVerifyCommand("list members");
+ gfsh.executeAndAssertThat("list members").statusIsSuccess();
}
@Test
public void connectOverHttp() throws Exception {
gfsh.secureConnectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http,
"clusterRead", "clusterRead");
- gfsh.executeAndVerifyCommand("list members");
+ gfsh.executeAndAssertThat("list members").statusIsSuccess();
}
}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandDUnitTest.java
index 5238a47..8586ad7 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/DescribeConfigCommandDUnitTest.java
@@ -73,7 +73,7 @@ public class DescribeConfigCommandDUnitTest {
config.setArchiveFileSizeLimit(1000);
});
- gfsh.executeAndVerifyCommand("describe config --member=" + server0.getName());
+ gfsh.executeAndAssertThat("describe config --member=" + server0.getName()).statusIsSuccess();
String result = gfsh.getGfshOutput();
assertThat(result).containsPattern("enable-time-statistics\\s+: true");
@@ -83,9 +83,8 @@ public class DescribeConfigCommandDUnitTest {
assertThat(result).containsPattern("is-server\\s+: true");
assertThat(result).doesNotContain("copy-on-read");
- gfsh.executeAndVerifyCommand(
- "describe config --member=" + server0.getName() + " --hide-defaults=false");
- result = gfsh.getGfshOutput();
- assertThat(result).contains("copy-on-read");
+ gfsh.executeAndAssertThat(
+ "describe config --member=" + server0.getName() + " --hide-defaults=false")
+ .statusIsSuccess().containsOutput("copy-on-read");
}
}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandWithSecurityDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandWithSecurityDUnitTest.java
index cdbf9e0..ed58418 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandWithSecurityDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExecuteFunctionCommandWithSecurityDUnitTest.java
@@ -94,12 +94,14 @@ public class ExecuteFunctionCommandWithSecurityDUnitTest {
}
private void executeReadFunctionIsSuccessful() {
- gfsh.executeAndVerifyCommand("execute function --id=" + new ReadFunction().getId());
+ gfsh.executeAndAssertThat("execute function --id=" + new ReadFunction().getId())
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains(ReadFunction.SUCCESS_OUTPUT);
}
private void executeWriteFunctionThrowsError() {
- gfsh.executeAndVerifyCommand("execute function --id=" + new WriteFunction().getId());
+ gfsh.executeAndAssertThat("execute function --id=" + new WriteFunction().getId())
+ .statusIsSuccess();
assertThat(gfsh.getGfshOutput()).contains("dataRead not authorized for DATA:WRITE");
}
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
index c978743..1e8b46f 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/ExportConfigCommandDUnitTest.java
@@ -73,7 +73,7 @@ public class ExportConfigCommandDUnitTest {
// export all members' config into a folder
File tempDir = temporaryFolder.newFolder("all-members");
- gfsh.executeAndVerifyCommand("export config --dir=" + tempDir.getAbsolutePath());
+ gfsh.executeAndAssertThat("export config --dir=" + tempDir.getAbsolutePath()).statusIsSuccess();
List<String> expectedFiles = Arrays.asList("server-0-cache.xml", "server-1-cache.xml",
"server-2-cache.xml", "server-3-cache.xml", "server-0-gf.properties",
@@ -86,8 +86,8 @@ public class ExportConfigCommandDUnitTest {
// export just one member's config
tempDir = temporaryFolder.newFolder("member0");
- gfsh.executeAndVerifyCommand(
- "export config --member=server-0 --dir=" + tempDir.getAbsolutePath());
+ gfsh.executeAndAssertThat("export config --member=server-0 --dir=" + tempDir.getAbsolutePath())
+ .statusIsSuccess();
expectedFiles = Arrays.asList("server-0-cache.xml", "server-0-gf.properties");
@@ -98,7 +98,8 @@ public class ExportConfigCommandDUnitTest {
// export group2 config into a folder
tempDir = temporaryFolder.newFolder("group2");
- gfsh.executeAndVerifyCommand("export config --group=Group2 --dir=" + tempDir.getAbsolutePath());
+ gfsh.executeAndAssertThat("export config --group=Group2 --dir=" + tempDir.getAbsolutePath())
+ .statusIsSuccess();
expectedFiles = Arrays.asList("server-1-cache.xml", "server-2-cache.xml",
"server-1-gf.properties", "server-2-gf.properties");
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
index 12d93fa..d1aacbb 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/cli/commands/FunctionCommandsOverHttpDUnitTest.java
@@ -15,10 +15,11 @@
package org.apache.geode.management.internal.cli.commands;
+import org.junit.experimental.categories.Category;
+
import org.apache.geode.test.dunit.rules.MemberVM;
import org.apache.geode.test.junit.categories.DistributedTest;
import org.apache.geode.test.junit.rules.GfshShellConnectionRule;
-import org.junit.experimental.categories.Category;
@Category(DistributedTest.class)
public class FunctionCommandsOverHttpDUnitTest extends FunctionCommandsDUnitTest {
diff --git a/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java b/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
index 07a3abc..2b7c984 100644
--- a/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
+++ b/geode-web/src/test/java/org/apache/geode/management/internal/security/LogNoPasswordTest.java
@@ -53,7 +53,7 @@ public class LogNoPasswordTest {
MemberVM locator = lsRule.startLocatorVM(0, properties);
gfsh.secureConnectAndVerify(locator.getHttpPort(), GfshShellConnectionRule.PortType.http, "any",
PASSWORD);
- gfsh.executeAndVerifyCommand("list members");
+ gfsh.executeAndAssertThat("list members").statusIsSuccess();
// scan all locator log files to find any occurrences of password
File[] serverLogFiles =
--
To stop receiving notification emails like this one, please contact
['"commits@geode.apache.org" <co...@geode.apache.org>'].