use of org.apache.flink.core.plugin.TestingPluginManager in project flink by apache.
the class ExternalResourceUtilsTest method testConstructExternalResourceDriversFromConfig.
@Test
public void testConstructExternalResourceDriversFromConfig() {
final Configuration config = new Configuration();
final String driverFactoryClassName = TestingExternalResourceDriverFactory.class.getName();
final Map<Class<?>, Iterator<?>> plugins = new HashMap<>();
plugins.put(ExternalResourceDriverFactory.class, IteratorUtils.singletonIterator(new TestingExternalResourceDriverFactory()));
final PluginManager testingPluginManager = new TestingPluginManager(plugins);
config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1));
config.setString(ExternalResourceOptions.getExternalResourceDriverFactoryConfigOptionForResource(RESOURCE_NAME_1), driverFactoryClassName);
final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManager);
assertThat(externalResourceDrivers.size(), is(1));
assertThat(externalResourceDrivers.get(RESOURCE_NAME_1), instanceOf(TestingExternalResourceDriver.class));
}
use of org.apache.flink.core.plugin.TestingPluginManager in project flink by apache.
the class ExternalResourceUtilsTest method testFactoryFailedToCreateDriver.
@Test
public void testFactoryFailedToCreateDriver() {
final Configuration config = new Configuration();
final String driverFactoryClassName = TestingFailedExternalResourceDriverFactory.class.getName();
final Map<Class<?>, Iterator<?>> plugins = new HashMap<>();
plugins.put(ExternalResourceDriverFactory.class, IteratorUtils.singletonIterator(new TestingFailedExternalResourceDriverFactory()));
final PluginManager testingPluginManager = new TestingPluginManager(plugins);
config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1));
config.setString(ExternalResourceOptions.getExternalResourceDriverFactoryConfigOptionForResource(RESOURCE_NAME_1), driverFactoryClassName);
final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManager);
assertThat(externalResourceDrivers.entrySet(), is(empty()));
}
use of org.apache.flink.core.plugin.TestingPluginManager in project flink by apache.
the class ExternalResourceUtilsTest method testFactoryPluginDoesNotExist.
@Test
public void testFactoryPluginDoesNotExist() {
final Configuration config = new Configuration();
final String driverFactoryClassName = TestingExternalResourceDriverFactory.class.getName();
final PluginManager testingPluginManager = new TestingPluginManager(Collections.emptyMap());
config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1));
config.setString(ExternalResourceOptions.getExternalResourceDriverFactoryConfigOptionForResource(RESOURCE_NAME_1), driverFactoryClassName);
final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManager);
assertThat(externalResourceDrivers.entrySet(), is(empty()));
}
use of org.apache.flink.core.plugin.TestingPluginManager in project flink by apache.
the class ExternalResourceUtilsTest method testNotConfiguredFactoryClass.
@Test
public void testNotConfiguredFactoryClass() {
final Configuration config = new Configuration();
final Map<Class<?>, Iterator<?>> plugins = new HashMap<>();
plugins.put(ExternalResourceDriverFactory.class, IteratorUtils.singletonIterator(new TestingExternalResourceDriverFactory()));
final PluginManager testingPluginManager = new TestingPluginManager(plugins);
config.set(ExternalResourceOptions.EXTERNAL_RESOURCE_LIST, Collections.singletonList(RESOURCE_NAME_1));
final Map<String, ExternalResourceDriver> externalResourceDrivers = ExternalResourceUtils.externalResourceDriversFromConfig(config, testingPluginManager);
assertThat(externalResourceDrivers.entrySet(), is(empty()));
}
use of org.apache.flink.core.plugin.TestingPluginManager in project flink by apache.
the class ReporterSetupTest method testReflectionInterception.
/**
* Verifies that the factory approach is used if the factory is annotated with {@link
* org.apache.flink.metrics.reporter.InterceptInstantiationViaReflection}.
*/
@Test
public void testReflectionInterception() {
final Configuration config = new Configuration();
config.setString(ConfigConstants.METRICS_REPORTER_PREFIX + "test." + ConfigConstants.METRICS_REPORTER_CLASS_SUFFIX, InstantiationTypeTrackingTestReporter.class.getName());
final List<ReporterSetup> reporterSetups = ReporterSetup.fromConfiguration(config, new TestingPluginManager(Collections.singletonMap(MetricReporterFactory.class, Collections.singletonList(new InterceptingInstantiationTypeTrackingTestReporterFactory()).iterator())));
assertEquals(1, reporterSetups.size());
final ReporterSetup reporterSetup = reporterSetups.get(0);
final InstantiationTypeTrackingTestReporter metricReporter = (InstantiationTypeTrackingTestReporter) reporterSetup.getReporter();
assertTrue(metricReporter.createdByFactory);
}
Aggregations