@Test @ConnectionConfiguration(user = "data,cluster", password = "data,cluster") public void modifyInternalRegionSuperUser() { CommandResult result = gfshConnection.executeCommand("put --key=key1 --value=value1 --region=PdxTypes"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains("Unauthorized"); }
@Test @ConnectionConfiguration(user = "clusterWriteDisk", password = "clusterWriteDisk") public void createPartitionedPersistentRegionWithoutDataManage() throws Exception { CommandResult result = gfshConnection.executeCommand("create region --name=region2 --type=PARTITION_PERSISTENT"); assertThat(result.getMessageFromContent()).contains("not authorized for DATA:MANAGE"); }
@Test public void noMemberFound() throws Exception { doReturn(Collections.EMPTY_SET).when(command).findMembers(any(), any()); result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --expression=abc --region=abc"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("No Members Found"); }
@Test public void validIndexType2() throws Exception { doReturn(Collections.EMPTY_SET).when(command).findMembers(any(), any()); result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --expression=abc --region=abc --type=hash"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("No Members Found"); }
@Test public void validIndexType() throws Exception { doReturn(Collections.EMPTY_SET).when(command).findMembers(any(), any()); result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --expression=abc --region=abc --type=range"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("No Members Found"); }
@Test public void testPortOnly() throws Exception { ShowMetricsCommand command = spy(ShowMetricsCommand.class); CommandResult result = parser.executeCommandWithInstance(command, "show metrics --port=0"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains( "If the --port parameter is specified, then the --member parameter must also be specified."); }
@Test public void testPortAndRegion() throws Exception { ShowMetricsCommand command = spy(ShowMetricsCommand.class); CommandResult result = parser.executeCommandWithInstance(command, "show metrics --port=0 --region=regionA"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()) .contains("The --region and --port parameters are mutually exclusive"); }
@Test public void invalidPortNumber() throws Exception { ShowMetricsCommand command = spy(ShowMetricsCommand.class); CommandResult result = parser.executeCommandWithInstance(command, "show metrics --port=abc"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); // When relying on Spring's converters, any command that does not parse is "Invalid" assertThat(result.getMessageFromContent()).contains("Invalid command"); } }
@Test public void invalidKeyType() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --key-type=abc-def"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }
@Test public void invalidValueType() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --value-type=abc-def"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }
@Test public void missingRegion() throws Exception { result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --expression=abc"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }
@Test public void invalidIndexType() throws Exception { result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --expression=abc --region=abc --type=abc"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }
@Test public void missingBothTypeAndUseAttributeFrom() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()) .contains("One of \"type\" or \"template-region\" is required."); }
@Test public void invalidEvictionAttributes() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --eviction-max-memory=1000 --eviction-entry-count=200"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()) .contains("eviction-max-memory and eviction-entry-count cannot both be specified."); }
@Test public void invalidEvictionSizerAndCount() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --eviction-entry-count=1 --eviction-object-sizer=abc --eviction-action=local-destroy"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()) .contains("eviction-object-sizer cannot be specified with eviction-entry-count"); }
@Test public void noDefinitions() throws Exception { result = gfshParser.executeCommandWithInstance(command, "create defined indexes"); assertThat(result.getStatus()).isEqualTo(OK); assertThat(result.getMessageFromContent()).contains("No indexes defined"); }
@Test public void missingName() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }
@Test public void haveBothTypeAndUseAttributeFrom() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --template-region=regionB"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()) .contains("Only one of type & template-region can be specified."); }
@Test public void missingEvictionAction() throws Exception { CommandResult result = parser.executeCommandWithInstance(command, "create region --name=region --type=REPLICATE --eviction-max-memory=1000"); assertThat(result.getStatus()).isEqualTo(Result.Status.ERROR); assertThat(result.getMessageFromContent()).contains("eviction-action must be specified."); }
@Test public void missingExpression() throws Exception { result = gfshParser.executeCommandWithInstance(command, "create index --name=abc --region=abc"); assertThat(result.getStatus()).isEqualTo(ERROR); assertThat(result.getMessageFromContent()).contains("Invalid command"); }