@Test
  public void testCreationWihtSimpleDescriptor() throws Exception {
    InputStream generatorDescriptorIn =
        getClass()
            .getResourceAsStream("/opennlp/tools/util/featuregen/TestFeatureGeneratorConfig.xml");

    // If this fails the generator descriptor could not be found
    // at the expected location
    Assert.assertNotNull(generatorDescriptorIn);

    Collection<String> expectedGenerators = new ArrayList<String>();
    expectedGenerators.add(OutcomePriorFeatureGenerator.class.getName());

    AggregatedFeatureGenerator aggregatedGenerator =
        (AggregatedFeatureGenerator) GeneratorFactory.create(generatorDescriptorIn, null);

    for (AdaptiveFeatureGenerator generator : aggregatedGenerator.getGenerators()) {

      expectedGenerators.remove(generator.getClass().getName());

      // if of kind which requires parameters check that
    }

    // If this fails not all expected generators were found and
    // removed from the expected generators collection
    Assert.assertEquals(0, expectedGenerators.size());
  }
  /**
   * Tests the creation from a descriptor which contains an unkown element. The creation should fail
   * with an {@link InvalidFormatException}
   */
  @Test(expected = IOException.class)
  public void testCreationWithUnkownElement() throws IOException {
    InputStream descIn =
        getClass()
            .getResourceAsStream(
                "/opennlp/tools/util/featuregen/FeatureGeneratorConfigWithUnkownElement.xml");

    try {
      GeneratorFactory.create(descIn, null);
    } finally {
      descIn.close();
    }
  }
  @Test
  public void testCreationWithCustomGenerator() throws Exception {
    InputStream generatorDescriptorIn =
        getClass().getResourceAsStream("/opennlp/tools/util/featuregen/CustomClassLoading.xml");

    // If this fails the generator descriptor could not be found
    // at the expected location
    Assert.assertNotNull(generatorDescriptorIn);

    AggregatedFeatureGenerator aggregatedGenerator =
        (AggregatedFeatureGenerator) GeneratorFactory.create(generatorDescriptorIn, null);

    Collection<AdaptiveFeatureGenerator> embeddedGenerator = aggregatedGenerator.getGenerators();

    Assert.assertEquals(1, embeddedGenerator.size());

    for (AdaptiveFeatureGenerator generator : embeddedGenerator) {
      Assert.assertEquals(TokenFeatureGenerator.class.getName(), generator.getClass().getName());
    }
  }