final ResourceModelSourceService service = ResourceModelSourceService.getInstanceForFramework(
getFrameworkInstance());
{
final test1 factory = new test1();
final sourceTest1 provider = new sourceTest1();
final INodeSet nodesettest = new NodeSetImpl();
provider.toReturn = nodesettest;
factory.toReturn = provider;
service.registerInstance("test", factory);
//no properties
final ResourceModelSource result = service.getSourceForConfiguration("test", null);
assertNotNull(result);
assertTrue(factory.called);
assertNull(factory.createNodesProviderConfiguration);
assertNotNull(result.getNodes());
assertEquals(nodesettest, result.getNodes());
}
{
final test1 factory = new test1();
final sourceTest1 provider = new sourceTest1();
final INodeSet nodesettest = new NodeSetImpl();
provider.toReturn = nodesettest;
factory.toReturn = provider;
service.registerInstance("test", factory);
final Properties properties = new Properties();
//use properties
final ResourceModelSource result = service.getSourceForConfiguration("test", properties);
assertNotNull(result);
assertTrue(factory.called);
assertNotNull(factory.createNodesProviderConfiguration);
assertEquals(properties, factory.createNodesProviderConfiguration);
assertNotNull(result.getNodes());
assertEquals(nodesettest, result.getNodes());
}
{
final test1 factory = new test1();
final sourceTest1 provider = new sourceTest1();
final INodeSet nodesettest = new NodeSetImpl();
provider.toReturn = nodesettest;
factory.toReturn = provider;
factory.toThrow = new ConfigurationException("test1");