@Test
  public void testInitMissingParam() {
    MockControl mockRendererComponentFactoryDescriptorControl =
        MockClassControl.createControl(RendererComponentFactoryDescriptor.class);
    RendererComponentFactoryDescriptor mockRendererComponentFactoryDescriptor =
        (RendererComponentFactoryDescriptor)
            mockRendererComponentFactoryDescriptorControl.getMock();
    mockRendererComponentFactoryDescriptor.getPlugin();
    mockRendererComponentFactoryDescriptorControl.setReturnValue(null);
    mockRendererComponentFactoryDescriptor.getParams();
    mockRendererComponentFactoryDescriptorControl.setReturnValue(new HashMap());
    mockRendererComponentFactoryDescriptor.getCompleteKey();
    mockRendererComponentFactoryDescriptorControl.setReturnValue("pluginkey");
    mockRendererComponentFactoryDescriptorControl.replay();

    SimpleRendererComponentFactory simpleRendererComponentFactory =
        new SimpleRendererComponentFactory();
    try {
      simpleRendererComponentFactory.init(mockRendererComponentFactoryDescriptor);
      fail("Expected exception");
    } catch (PluginParseException e) {
      assertTrue(e.getMessage().indexOf("is missing the required") > 0);
      assertTrue(e.getMessage().indexOf("pluginkey") > 0);
    }
  }
  @Test
  public void testInitInvalidClass() {
    MockControl mockRendererComponentFactoryDescriptorControl =
        MockClassControl.createControl(RendererComponentFactoryDescriptor.class);
    RendererComponentFactoryDescriptor mockRendererComponentFactoryDescriptor =
        (RendererComponentFactoryDescriptor)
            mockRendererComponentFactoryDescriptorControl.getMock();
    Mock mockPlugin = new Mock(Plugin.class);

    mockRendererComponentFactoryDescriptor.getPlugin();
    mockRendererComponentFactoryDescriptorControl.setReturnValue(null);
    Map params = new HashMap();
    params.put("rendererComponentClass", "com.test.invalid.class");
    mockRendererComponentFactoryDescriptor.getParams();
    mockRendererComponentFactoryDescriptorControl.setReturnValue(params);
    mockRendererComponentFactoryDescriptor.getCompleteKey();
    mockRendererComponentFactoryDescriptorControl.setReturnValue("pluginkey");
    mockRendererComponentFactoryDescriptor.getPlugin();
    mockRendererComponentFactoryDescriptorControl.setReturnValue(mockPlugin.proxy());
    mockPlugin.expectAndThrow(
        "loadClass",
        new Constraint[] {new IsEqual("com.test.invalid.class"), new IsAnything()},
        new ClassNotFoundException());
    mockRendererComponentFactoryDescriptorControl.replay();

    SimpleRendererComponentFactory simpleRendererComponentFactory =
        new SimpleRendererComponentFactory() {
          RendererComponent loadRendererComponent(Class rendererComponentClass)
              throws ClassNotFoundException {
            throw new ClassNotFoundException();
          }
        };

    try {
      simpleRendererComponentFactory.init(mockRendererComponentFactoryDescriptor);
      fail("Expected exception");
    } catch (PluginParseException e) {
      assertTrue(e.getMessage().indexOf("Could not load renderer") >= 0);
      assertTrue(e.getMessage().indexOf("pluginkey") > 0);
      assertTrue(e.getMessage().indexOf("com.test.invalid.class") > 0);
    }
  }