@SuppressWarnings("deprecation")
  @Test
  public void tesLoadtLifecycleListener() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();

    PluginMessageLogger.clear();

    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    // first make sure Plugin 1 was loaded, otherwise our check for lifcycle class will never happen
    assertTrue(
        "plugin1 was not found",
        CollectionUtils.exists(plugins, new PluginNameMatcherPredicate("Plugin 1")));

    for (IPlatformPlugin plugin : plugins) {
      if (plugin.getId().equals("Plugin 1")) {
        assertEquals(
            "org.pentaho.test.platform.plugin.pluginmgr.FooInitializer",
            plugin.getLifecycleListenerClassname());
      }
      if (plugin.getId().equals("Plugin 2")) {
        // no listener defined to for Plugin 2
        assertNull(plugin.getLifecycleListenerClassname());
      }
    }
  }
  @SuppressWarnings("deprecation")
  @Test
  public void testLoadContentGenerators() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    IPlatformPlugin plugin =
        (IPlatformPlugin)
            CollectionUtils.find(
                plugins, new PluginNameMatcherPredicate("content-generator-plugin"));
    assertNotNull("content-generator-plugin should have been found", plugin);

    List<IContentInfo> contentTypes = plugin.getContentInfos();

    Object contentType =
        CollectionUtils.find(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo type = (IContentInfo) object;
                return type.getTitle().equals("Good Test Type");
              }
            });
    assertNotNull("\"Good Test Type\" should have been loaded", contentType);
    assertNotNull(
        "\"Good Test Type\" extension definition is incorrect",
        ((IContentInfo) contentType).getExtension().equals("good-content-type"));

    assertEquals(
        "\"Test Type Missing type\" should not have been loaded",
        0,
        CollectionUtils.countMatches(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo contentType = (IContentInfo) object;
                return contentType.getTitle().equals("Test Type Missing type");
              }
            }));

    assertEquals(
        "\"test-type-missing-title\" should not have been loaded",
        0,
        CollectionUtils.countMatches(
            contentTypes,
            new Predicate() {
              public boolean evaluate(Object object) {
                IContentInfo contentType = (IContentInfo) object;
                return contentType.getExtension().equals("test-type-missing-title");
              }
            }));
  }
  @SuppressWarnings("deprecation")
  @Test
  public void testLoadLifeCycleListener() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    IPlatformPlugin plugin =
        (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);

    assertEquals(
        "org.pentaho.test.platform.plugin.pluginmgr.FooInitializer",
        plugin.getLifecycleListenerClassname());
  }
  @SuppressWarnings("deprecation")
  @Test
  public void testLoadBeanDefinition() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();

    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    IPlatformPlugin plugin =
        (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);

    Collection<PluginBeanDefinition> beans = plugin.getBeans();

    assertEquals(
        "FooComponent was not loaded",
        1,
        CollectionUtils.countMatches(
            beans,
            new Predicate() {
              public boolean evaluate(Object object) {
                PluginBeanDefinition bean = (PluginBeanDefinition) object;
                return bean.getBeanId().equals("FooComponent")
                    && bean.getClassname()
                        .equals("org.pentaho.test.platform.plugin.pluginmgr.FooComponent");
              }
            }));
    assertEquals(
        "genericBean was not loaded",
        1,
        CollectionUtils.countMatches(
            beans,
            new Predicate() {
              public boolean evaluate(Object object) {
                PluginBeanDefinition bean = (PluginBeanDefinition) object;
                return bean.getBeanId().equals("genericBean")
                    && bean.getClassname().equals("java.lang.Object");
              }
            }));
  }
  @SuppressWarnings("deprecation")
  @Test
  public void testLoadWebservices() throws PlatformPluginRegistrationException {
    microPlatform.define(ISolutionRepository.class, FileBasedSolutionRepository.class).init();
    List<IPlatformPlugin> plugins = provider.getPlugins(new StandaloneSession());

    System.out.println(PluginMessageLogger.getAll());

    IPlatformPlugin plugin =
        (IPlatformPlugin) CollectionUtils.find(plugins, new PluginNameMatcherPredicate("Plugin 1"));
    assertNotNull("Plugin 1 should have been found", plugin);

    Collection<PluginServiceDefinition> webservices = plugin.getServices();

    Object wsobj =
        CollectionUtils.find(
            webservices,
            new Predicate() {
              public boolean evaluate(Object object) {
                PluginServiceDefinition ws = (PluginServiceDefinition) object;
                boolean ret = ws.getTitle().equals("%TestWS1.TITLE%");
                return ret;
              }
            });

    assertNotNull("Webservice \"%TestWS1.TITLE%\" should have been loaded", wsobj);

    PluginServiceDefinition wsDfn = (PluginServiceDefinition) wsobj;

    assertEquals("org.pentaho.test.platform.engine.core.EchoServiceBean", wsDfn.getServiceClass());
    assertEquals("xml", wsDfn.getTypes()[0]);
    assertEquals("gwt", wsDfn.getTypes()[1]);
    assertEquals("A test webservice", wsDfn.getDescription());
    assertEquals(1, wsDfn.getExtraClasses().size());
    assertEquals("java.lang.String", wsDfn.getExtraClasses().iterator().next());
  }