FOEventHandler foEventHandler;
FOEventHandler overrideFOEventHandler;
ua = fopFactory.newFOUserAgent();
foEventHandler = factory.createFOEventHandler(
ua, MimeConstants.MIME_PDF, new NullOutputStream());
assertTrue(foEventHandler instanceof AreaTreeHandler);
ua = fopFactory.newFOUserAgent();
foEventHandler = factory.createFOEventHandler(
ua, MimeConstants.MIME_RTF, new NullOutputStream());
assertTrue(foEventHandler instanceof RTFHandler);
ua = fopFactory.newFOUserAgent();
try {
foEventHandler = factory.createFOEventHandler(
ua, "invalid/format", new NullOutputStream());
fail("Expected UnsupportedOperationException");
} catch (UnsupportedOperationException uoe) {
//expected
}
ua = fopFactory.newFOUserAgent();
try {
foEventHandler = factory.createFOEventHandler(
ua, MimeConstants.MIME_PDF, null);
fail("Expected FOPException because of missing OutputStream");
} catch (FOPException fe) {
//expected
}
ua = fopFactory.newFOUserAgent();
overrideFOEventHandler = new RTFHandler(ua, new NullOutputStream());
ua.setFOEventHandlerOverride(overrideFOEventHandler);
foEventHandler = factory.createFOEventHandler(
ua, null, null);
assertTrue(foEventHandler == overrideFOEventHandler);
}