Search in sources :

Example 1 with ProvisionerModule

use of io.cdap.cdap.internal.provision.ProvisionerModule in project cdap by cdapio.

the class TetheringProvisionerTest method testGuiceInjector.

@Test
public void testGuiceInjector() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new InMemoryDiscoveryModule(), new StorageModule(), new ProvisionerModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(SecureStore.class).toInstance(FakeSecureStore.builder().build());
            bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class);
        }
    });
    ProvisionerProvider provisionerProvider = injector.getInstance(ProvisionerProvider.class);
    Map<String, Provisioner> provisioners = provisionerProvider.loadProvisioners();
    Assert.assertNotNull(provisioners.get(TetheringProvisioner.TETHERING_NAME));
    ProvisionerConfigProvider configProvider = injector.getInstance(ProvisionerConfigProvider.class);
    Map<String, ProvisionerConfig> configs = configProvider.loadProvisionerConfigs(provisioners.values());
    Assert.assertNotNull(configs.get(TetheringProvisioner.TETHERING_NAME));
}
Also used : NoOpProgramStateWriter(io.cdap.cdap.app.runtime.NoOpProgramStateWriter) ProvisionerProvider(io.cdap.cdap.internal.provision.ProvisionerProvider) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ProvisionerConfigProvider(io.cdap.cdap.internal.provision.ProvisionerConfigProvider) StorageModule(io.cdap.cdap.data.runtime.StorageModule) ProvisionerModule(io.cdap.cdap.internal.provision.ProvisionerModule) ProvisionerConfig(io.cdap.cdap.internal.provision.ProvisionerConfig) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) Provisioner(io.cdap.cdap.runtime.spi.provisioner.Provisioner) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) Injector(com.google.inject.Injector) Test(org.junit.Test)

Example 2 with ProvisionerModule

use of io.cdap.cdap.internal.provision.ProvisionerModule in project cdap by caskdata.

the class TetheringProvisionerTest method testGuiceInjector.

@Test
public void testGuiceInjector() throws Exception {
    CConfiguration cConf = CConfiguration.create();
    cConf.set(Constants.CFG_LOCAL_DATA_DIR, TEMP_FOLDER.newFolder().getAbsolutePath());
    Injector injector = Guice.createInjector(new ConfigModule(cConf), new LocalLocationModule(), new InMemoryDiscoveryModule(), new StorageModule(), new ProvisionerModule(), new MessagingServerRuntimeModule().getInMemoryModules(), new AbstractModule() {

        @Override
        protected void configure() {
            bind(MetricsCollectionService.class).to(NoOpMetricsCollectionService.class);
            bind(SecureStore.class).toInstance(FakeSecureStore.builder().build());
            bind(ProgramStateWriter.class).to(NoOpProgramStateWriter.class);
        }
    });
    ProvisionerProvider provisionerProvider = injector.getInstance(ProvisionerProvider.class);
    Map<String, Provisioner> provisioners = provisionerProvider.loadProvisioners();
    Assert.assertNotNull(provisioners.get(TetheringProvisioner.TETHERING_NAME));
    ProvisionerConfigProvider configProvider = injector.getInstance(ProvisionerConfigProvider.class);
    Map<String, ProvisionerConfig> configs = configProvider.loadProvisionerConfigs(provisioners.values());
    Assert.assertNotNull(configs.get(TetheringProvisioner.TETHERING_NAME));
}
Also used : NoOpProgramStateWriter(io.cdap.cdap.app.runtime.NoOpProgramStateWriter) ProvisionerProvider(io.cdap.cdap.internal.provision.ProvisionerProvider) InMemoryDiscoveryModule(io.cdap.cdap.common.guice.InMemoryDiscoveryModule) ProvisionerConfigProvider(io.cdap.cdap.internal.provision.ProvisionerConfigProvider) StorageModule(io.cdap.cdap.data.runtime.StorageModule) ProvisionerModule(io.cdap.cdap.internal.provision.ProvisionerModule) ProvisionerConfig(io.cdap.cdap.internal.provision.ProvisionerConfig) ConfigModule(io.cdap.cdap.common.guice.ConfigModule) Provisioner(io.cdap.cdap.runtime.spi.provisioner.Provisioner) MessagingServerRuntimeModule(io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule) NoOpMetricsCollectionService(io.cdap.cdap.common.metrics.NoOpMetricsCollectionService) CConfiguration(io.cdap.cdap.common.conf.CConfiguration) AbstractModule(com.google.inject.AbstractModule) LocalLocationModule(io.cdap.cdap.common.guice.LocalLocationModule) Injector(com.google.inject.Injector) Test(org.junit.Test)

Aggregations

AbstractModule (com.google.inject.AbstractModule)2 Injector (com.google.inject.Injector)2 NoOpProgramStateWriter (io.cdap.cdap.app.runtime.NoOpProgramStateWriter)2 CConfiguration (io.cdap.cdap.common.conf.CConfiguration)2 ConfigModule (io.cdap.cdap.common.guice.ConfigModule)2 InMemoryDiscoveryModule (io.cdap.cdap.common.guice.InMemoryDiscoveryModule)2 LocalLocationModule (io.cdap.cdap.common.guice.LocalLocationModule)2 NoOpMetricsCollectionService (io.cdap.cdap.common.metrics.NoOpMetricsCollectionService)2 StorageModule (io.cdap.cdap.data.runtime.StorageModule)2 ProvisionerConfig (io.cdap.cdap.internal.provision.ProvisionerConfig)2 ProvisionerConfigProvider (io.cdap.cdap.internal.provision.ProvisionerConfigProvider)2 ProvisionerModule (io.cdap.cdap.internal.provision.ProvisionerModule)2 ProvisionerProvider (io.cdap.cdap.internal.provision.ProvisionerProvider)2 MessagingServerRuntimeModule (io.cdap.cdap.messaging.guice.MessagingServerRuntimeModule)2 Provisioner (io.cdap.cdap.runtime.spi.provisioner.Provisioner)2 Test (org.junit.Test)2