Search in sources :

Example 1 with Parameters

use of junitparams.Parameters in project druid by druid-io.

the class WhiteListBasedDruidToTimelineEventConverterTest method testGetName.

@Test
@Parameters
public void testGetName(ServiceMetricEvent serviceMetricEvent, String expectedPath) {
    TimelineMetric metric = defaultWhiteListBasedDruidToTimelineEventConverter.druidEventToTimelineMetric(serviceMetricEvent);
    String path = null;
    if (metric != null) {
        path = metric.getMetricName();
    }
    Assert.assertEquals(expectedPath, path);
}
Also used : TimelineMetric(org.apache.hadoop.metrics2.sink.timeline.TimelineMetric) Parameters(junitparams.Parameters) Test(org.junit.Test)

Example 2 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneCommandsSecurityDUnitTest method verifySearchIndexPermissions.

@Test
@Parameters(method = "getSearchIndexUserNameAndExpectedResponses")
public void verifySearchIndexPermissions(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(getSearchIndexCommand());
    // Verify result
    verifyResult(user, result);
}
Also used : CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Parameters(junitparams.Parameters) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 3 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneCommandsSecurityDUnitTest method verifyDestroyIndexPermissions.

@Test
@Parameters(method = "getDestroyIndexUserNameAndExpectedResponses")
public void verifyDestroyIndexPermissions(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(getDestroyIndexCommand());
    // Verify result
    verifyResult(user, result);
}
Also used : CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Parameters(junitparams.Parameters) SecurityTest(org.apache.geode.test.junit.categories.SecurityTest) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest)

Example 4 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneIndexCommandsJUnitTest method testDestroySingleIndexNoRegionMembers.

@Test
@Parameters({ "true", "false" })
public void testDestroySingleIndexNoRegionMembers(boolean expectedToSucceed) throws Exception {
    LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
    String indexName = "index";
    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_INDEX_0_FROM_REGION_1, new Object[] { indexName, 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);
}
Also used : CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) LuceneDestroyIndexFunction(org.apache.geode.cache.lucene.internal.cli.functions.LuceneDestroyIndexFunction) ArrayList(java.util.ArrayList) Mockito.anyString(org.mockito.Mockito.anyString) ResultCollector(org.apache.geode.cache.execute.ResultCollector) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) Parameters(junitparams.Parameters) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Example 5 with Parameters

use of junitparams.Parameters in project geode by apache.

the class LuceneIndexCommandsJUnitTest method testDestroySingleIndexWithRegionMembers.

@Test
@Parameters({ "true", "false" })
public void testDestroySingleIndexWithRegionMembers(boolean expectedToSucceed) throws Exception {
    LuceneIndexCommands commands = createTestLuceneIndexCommandsForDestroyIndex();
    String indexName = "index";
    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_INDEX_0_FROM_REGION_1, new Object[] { indexName, 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(members).when(commands).getNormalMembers(any());
    doReturn(members).when(commands).getRegionMembers(any(), any());
    CommandResult result = (CommandResult) commands.destroyIndex(indexName, regionPath);
    verifyDestroyIndexCommandResult(result, cliFunctionResults, expectedStatus);
}
Also used : LuceneDestroyIndexFunction(org.apache.geode.cache.lucene.internal.cli.functions.LuceneDestroyIndexFunction) ArrayList(java.util.ArrayList) Mockito.anyString(org.mockito.Mockito.anyString) CommandResult(org.apache.geode.management.internal.cli.result.CommandResult) CliFunctionResult(org.apache.geode.management.internal.cli.functions.CliFunctionResult) DistributedMember(org.apache.geode.distributed.DistributedMember) ResultCollector(org.apache.geode.cache.execute.ResultCollector) HashSet(java.util.HashSet) Parameters(junitparams.Parameters) UnitTest(org.apache.geode.test.junit.categories.UnitTest) Test(org.junit.Test)

Aggregations

Parameters (junitparams.Parameters)344 Test (org.junit.Test)344 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)55 DescriptorSet (com.spotify.protoman.descriptor.DescriptorSet)43 ValidationViolation (com.spotify.protoman.validation.ValidationViolation)43 SerializableRunnableIF (org.apache.geode.test.dunit.SerializableRunnableIF)41 QueryDataSource (org.apache.druid.query.QueryDataSource)30 TableDataSource (org.apache.druid.query.TableDataSource)30 GlobalTableDataSource (org.apache.druid.query.GlobalTableDataSource)26 DefaultDimensionSpec (org.apache.druid.query.dimension.DefaultDimensionSpec)26 CountAggregatorFactory (org.apache.druid.query.aggregation.CountAggregatorFactory)24 Method (java.lang.reflect.Method)19 LookupDataSource (org.apache.druid.query.LookupDataSource)19 IByteArrayKeyValueDatabase (org.aion.base.db.IByteArrayKeyValueDatabase)18 InternalSerializationService (com.hazelcast.internal.serialization.InternalSerializationService)17 DefaultSerializationServiceBuilder (com.hazelcast.internal.serialization.impl.DefaultSerializationServiceBuilder)13 File (java.io.File)13 MapTableField (com.hazelcast.sql.impl.schema.map.MapTableField)12 Owner (org.candlepin.model.Owner)12 Product (org.candlepin.model.Product)12