use of org.apache.openejb.config.provider.ProviderCircularReferenceException in project tomee by apache.
the class ProviderManagerTest method testCircularDependency.
public void testCircularDependency() throws Exception {
final ProviderManager manager = new ProviderManager(new ProviderLoader() {
@Override
public ServiceProvider load(final ID id) {
if ("color".equalsIgnoreCase(id.getName())) {
final ServiceProvider color = new ServiceProvider(Color.class, "Color", "Resource");
color.setParent("Orange");
color.getProperties().setProperty("red", "0");
color.getProperties().setProperty("green", "0");
color.getProperties().setProperty("blue", "0");
return color;
}
if ("red".equalsIgnoreCase(id.getName())) {
final ServiceProvider red = new ServiceProvider();
red.setId("Red");
red.setParent("Color");
red.getProperties().setProperty("red", "255");
return red;
}
if ("orange".equalsIgnoreCase(id.getName())) {
final ServiceProvider orange = new ServiceProvider();
orange.setId("Orange");
orange.setParent("Red");
orange.getProperties().setProperty("green", "200");
return orange;
}
throw new IllegalStateException(id.toString());
}
@Override
public List<ServiceProvider> load(final String namespace) {
return null;
}
});
assertEquals(0, manager.getAll().size());
try {
manager.get("dEFAUlT", "orAngE");
fail("ProviderCircularReferenceException should have been thrown");
} catch (final ProviderCircularReferenceException e) {
// pass
}
}
Aggregations