@Test
public void testBadMetrics() throws Exception {
LayerImpl layer = MapTests.createLayer(null, BadRenderMetricsFactory.ALWAYS_EXCEPTION, null);
RendererCreatorImpl creator = MapTests.createRendererCreator(layer.getMapInternal());
creator.getLayers().add(layer);
Collection<RenderContext> configuration = creator.getConfiguration();
assertEquals(0, configuration.size());
layer = MapTests.createLayer(null, BadRenderMetricsFactory.CAN_RENDER_NO_EXCEPTION, null);
creator.getLayers().clear();
creator.getLayers().add(layer);
creator.reset();
configuration = creator.getConfiguration();
assertEquals(1, configuration.size());
assertTrue( creator.getRenderer(configuration.iterator().next()) instanceof PlaceHolder );
layer = MapTests.createLayer(null, BadRenderMetricsFactory.CAN_CREATE_METRICS, null);
creator.getLayers().clear();
creator.getLayers().add(layer);
creator.reset();
configuration = creator.getConfiguration();
assertEquals(1, configuration.size());
assertTrue( creator.getRenderer(configuration.iterator().next()) instanceof PlaceHolder );
layer = MapTests.createLayer(null, BadRenderMetricsFactory.CAN_ADD_LAYER_EXCEPTION, null);
creator.getLayers().clear();
layer.setName("layer1"); //$NON-NLS-1$
creator.getLayers().add(layer);
layer = MapTests.createLayer(null, BadRenderMetricsFactory.CAN_ADD_LAYER_EXCEPTION, layer.getMapInternal());
layer.setName("layer2"); //$NON-NLS-1$
creator.getLayers().add(layer);
creator.reset();
configuration = creator.getConfiguration();
assertEquals(2, configuration.size());
Iterator<RenderContext> iter = configuration.iterator();
assertFalse( creator.getRenderer(iter.next()) instanceof PlaceHolder );
assertFalse( creator.getRenderer(iter.next()) instanceof PlaceHolder );
}