use of org.xwiki.rendering.macro.rss.RssMacroParameters in project xwiki-platform by xwiki.
the class RssMacroTest method testInvalidDocument.
/**
* Tests the macro's behavior when the server hosting the feeds doesn't respond.
*/
@Test(expected = MacroExecutionException.class)
public void testInvalidDocument() throws Exception {
// Use a Mock SyndFeedInput to control what it returns for the test.
Mockery context = new Mockery();
final RomeFeedFactory mockFactory = context.mock(RomeFeedFactory.class);
final RssMacroParameters parameters = new RssMacroParameters();
context.checking(new Expectations() {
{
oneOf(mockFactory).createFeed(with(same(parameters)));
will(throwException(new MacroExecutionException("Error")));
}
});
this.macro.setFeedFactory(mockFactory);
// Dummy URL since a feed URL is mandatory
parameters.setFeed("http://www.xwiki.org");
this.macro.execute(parameters, null, null);
}
use of org.xwiki.rendering.macro.rss.RssMacroParameters in project xwiki-platform by xwiki.
the class RssMacroTest method testRequiredParameterMissing.
/**
* Tests whether the macro throws the appropriate exception
* in cases where the required 'feed' parameter is missing.
*/
@Test
public void testRequiredParameterMissing() throws Exception {
try {
this.macro.execute(new RssMacroParameters(), null, null);
Assert.fail("Should have thrown an exception");
} catch (MacroExecutionException expected) {
Assert.assertEquals("The required 'feed' parameter is missing", expected.getMessage());
}
}
Aggregations