private LuceneIndex generateAndParseXml(LuceneService service) {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    PrintWriter pw = new PrintWriter(baos);
    CacheXmlGenerator.generate(cache, pw, false, false);
    pw.flush();

    cache.close();
    cache = new CacheFactory().set(MCAST_PORT, "0").create();

    byte[] bytes = baos.toByteArray();
    cache.loadCacheXml(new ByteArrayInputStream(bytes));

    LuceneService service2 = LuceneServiceProvider.get(cache);
    assertNotSame(service, service2);

    LuceneIndex index = service2.getIndex("index", "region");
    assertNotNull(index);
    return index;
  }
Generate an xml configuration from the LuceneService and parse it, returning the index that was
created from the xml.
geode-lucene/src/integrationTest/java/org/apache/geode/cache/lucene/internal/xml/LuceneIndexXmlGeneratorIntegrationJUnitTest.java