Search in sources :

Example 1 with ConfigView

use of org.apache.gobblin.broker.iface.ConfigView in project incubator-gobblin by apache.

the class SharedResourcesBrokerFactoryTest method testLoadingOfClasspath.

@Test
public void testLoadingOfClasspath() {
    Config config = ConfigFactory.parseMap(ImmutableMap.of(SharedResourcesBrokerFactory.BROKER_CONF_FILE_KEY, "/broker/testBroker.conf"));
    SharedResourcesBrokerImpl<SimpleScopeType> broker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(config, SimpleScopeType.GLOBAL.defaultScopeInstance());
    ConfigView configView = broker.getConfigView(null, null, "factory");
    Assert.assertTrue(configView.getConfig().hasPath("testKey"));
    Assert.assertEquals(configView.getConfig().getString("testKey"), "testValue");
}
Also used : ConfigView(org.apache.gobblin.broker.iface.ConfigView) Config(com.typesafe.config.Config) Test(org.testng.annotations.Test)

Example 2 with ConfigView

use of org.apache.gobblin.broker.iface.ConfigView in project incubator-gobblin by apache.

the class DefaultGobblinBrokerTest method testExplicitBinding.

@Test
public void testExplicitBinding() throws Exception {
    Config config = ConfigFactory.empty();
    SharedResourcesBrokerImpl<SimpleScopeType> topBroker = SharedResourcesBrokerFactory.createDefaultTopLevelBroker(config, SimpleScopeType.GLOBAL.defaultScopeInstance());
    SharedResourceFactory<Long, EmptyKey, SimpleScopeType> factory = new SharedResourceFactory<Long, EmptyKey, SimpleScopeType>() {

        @Override
        public String getName() {
            return "myTestFactory";
        }

        @Override
        public SharedResourceFactoryResponse<Long> createResource(SharedResourcesBroker<SimpleScopeType> broker, ScopedConfigView<SimpleScopeType, EmptyKey> config) throws NotConfiguredException {
            throw new UnsupportedOperationException();
        }

        @Override
        public SimpleScopeType getAutoScope(SharedResourcesBroker<SimpleScopeType> broker, ConfigView<SimpleScopeType, EmptyKey> config) {
            return broker.selfScope().getType();
        }
    };
    topBroker.bindSharedResourceAtScope(factory, new EmptyKey(), SimpleScopeType.GLOBAL, 10l);
    Assert.assertEquals(topBroker.getSharedResource(factory, new EmptyKey()), new Long(10));
}
Also used : SharedResourceFactory(org.apache.gobblin.broker.iface.SharedResourceFactory) ConfigView(org.apache.gobblin.broker.iface.ConfigView) ScopedConfigView(org.apache.gobblin.broker.iface.ScopedConfigView) Config(com.typesafe.config.Config) ScopedConfigView(org.apache.gobblin.broker.iface.ScopedConfigView) SharedResourcesBroker(org.apache.gobblin.broker.iface.SharedResourcesBroker) Test(org.testng.annotations.Test)

Aggregations

Config (com.typesafe.config.Config)2 ConfigView (org.apache.gobblin.broker.iface.ConfigView)2 Test (org.testng.annotations.Test)2 ScopedConfigView (org.apache.gobblin.broker.iface.ScopedConfigView)1 SharedResourceFactory (org.apache.gobblin.broker.iface.SharedResourceFactory)1 SharedResourcesBroker (org.apache.gobblin.broker.iface.SharedResourcesBroker)1