}
@Test
public void testOverridingInitializationTimeXslt()
{
IResource initXslt = resourceLocator.getFirst("/xsl/carrot2-identity.xsl");
initAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class, "xslt"),
initXslt);
@SuppressWarnings("unchecked")
Controller controller = getCachingController(initAttributes);
// Run with identity XSLT
{
IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
processingAttributes.put(AttributeUtils
.getKey(XmlDocumentSource.class, "xml"), xml);
final int documentCount = runQuery(controller);
assertEquals(2, documentCount);
assertEquals(Lists.newArrayList("Title 0", "Title 1"), Lists.transform(
getDocuments(), DOCUMENT_TO_TITLE));
assertEquals(Lists.newArrayList("Snippet 0", "Snippet 1"), Lists.transform(
getDocuments(), DOCUMENT_TO_SUMMARY));
}
// Run with swapping XSLT
{
IResource xml = resourceLocator.getFirst("/xml/carrot2-test.xml");
IResource xslt = resourceLocator.getFirst("/xsl/carrot2-title-snippet-switch.xsl");
processingAttributes.put(AttributeUtils
.getKey(XmlDocumentSource.class, "xml"), xml);
processingAttributes.put(AttributeUtils.getKey(XmlDocumentSource.class,
"xslt"), xslt);