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");
}
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));
}
Aggregations