use of junitparams.Parameters in project geode by apache.
the class LuceneCommandsSecurityDUnitTest method verifyDescribeIndexPermissions.
@Test
@Parameters(method = "getDescribeIndexUserNameAndExpectedResponses")
public void verifyDescribeIndexPermissions(UserNameAndExpectedResponse user) throws Exception {
// Create index and region
createIndexAndRegion();
// Connect gfsh
this.gfshShell.secureConnectAndVerify(this.locator.getPort(), GfshShellConnectionRule.PortType.locator, user.getUserName(), user.getUserName());
// Attempt to search lucene index
CommandResult result = this.gfshShell.executeCommand(getDescribeIndexCommand());
// Verify result
verifyResult(user, result);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testDestroyAllIndexesWithRegionMembers.
@Test
@Parameters({ "true", "false" })
public void testDestroyAllIndexesWithRegionMembers(boolean expectedToSucceed) throws Exception {
LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
String indexName = null;
String regionPath = "regionPath";
Set<DistributedMember> members = new HashSet<>();
DistributedMember mockMember = mock(DistributedMember.class);
when(mockMember.getId()).thenReturn("member0");
members.add(mockMember);
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0, new Object[] { regionPath });
cliFunctionResults.add(new CliFunctionResult(mockMember.getId()));
} else {
Exception e = new IllegalStateException("failed");
expectedStatus = e.getMessage();
cliFunctionResults.add(new CliFunctionResult("member0", e, e.getMessage()));
}
doReturn(mockResultCollector).when(commands).executeFunction(isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
doReturn(cliFunctionResults).when(mockResultCollector).getResult();
doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());
doReturn(Collections.emptySet()).when(commands).getRegionMembers(any(), any());
CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
verifyDestroyIndexCommandResult(result, cliFunctionResults, expectedStatus);
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsDUnitTest method testDestroyAllIndexes.
@Test
@Parameters({ "true", "false" })
public void testDestroyAllIndexes(boolean createRegion) throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
if (createRegion) {
createIndex(vm1);
} else {
createIndexWithoutRegion(vm1);
}
CommandResult result = createAndExecuteDestroyIndexCommand(null, REGION_NAME);
String resultAsString = commandResultToString(result);
String expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0, new Object[] { REGION_NAME });
assertTrue(resultAsString.contains(expectedStatus));
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsDUnitTest method testDestroySingleIndex.
@Test
@Parameters({ "true", "false" })
public void testDestroySingleIndex(boolean createRegion) throws Exception {
final VM vm1 = Host.getHost(0).getVM(1);
if (createRegion) {
createIndex(vm1);
} else {
createIndexWithoutRegion(vm1);
}
CommandResult result = createAndExecuteDestroyIndexCommand(INDEX_NAME, REGION_NAME);
String resultAsString = commandResultToString(result);
String expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEX_0_FROM_REGION_1, new Object[] { INDEX_NAME, REGION_NAME });
assertTrue(resultAsString.contains(expectedStatus));
}
use of junitparams.Parameters in project geode by apache.
the class LuceneIndexCommandsJUnitTest method testDestroyAllIndexesNoRegionMembers.
@Test
@Parameters({ "true", "false" })
public void testDestroyAllIndexesNoRegionMembers(boolean expectedToSucceed) throws Exception {
LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
String indexName = null;
String regionPath = "regionPath";
final ResultCollector mockResultCollector = mock(ResultCollector.class);
final List<CliFunctionResult> cliFunctionResults = new ArrayList<>();
String expectedStatus;
if (expectedToSucceed) {
expectedStatus = CliStrings.format(LuceneCliStrings.LUCENE_DESTROY_INDEX__MSG__SUCCESSFULLY_DESTROYED_INDEXES_FROM_REGION_0, new Object[] { regionPath });
cliFunctionResults.add(new CliFunctionResult("member0"));
} else {
Exception e = new IllegalStateException("failed");
expectedStatus = e.getMessage();
cliFunctionResults.add(new CliFunctionResult("member0", e, e.getMessage()));
}
doReturn(mockResultCollector).when(commands).executeFunction(isA(LuceneDestroyIndexFunction.class), any(LuceneDestroyIndexInfo.class), any());
doReturn(cliFunctionResults).when(mockResultCollector).getResult();
doReturn(Collections.emptySet()).when(commands).getNormalMembers(any());
doReturn(Collections.emptySet()).when(commands).getRegionMembers(any(), any());
CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
verifyDestroyIndexCommandResult(result, cliFunctionResults, expectedStatus);
}
Aggregations