use of org.apache.gobblin.broker.iface.SharedResourceFactory 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