On Jun 10, 2010, at 9:44 AM, Thomas Mortagne wrote:

> On Wed, Jun 9, 2010 at 20:12, Vincent Massol <[email protected]> wrote:
>> 
>> On Jun 9, 2010, at 6:01 PM, tmortagne (SVN) wrote:
>> 
>>> Author: tmortagne
>>> Date: 2010-06-09 18:01:08 +0200 (Wed, 09 Jun 2010)
>>> New Revision: 29377
>>> 
>>> Modified:
>>>   
>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/pom.xml
>>>   
>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/main/java/org/xwiki/rendering/internal/macro/include/IncludeMacro.java
>>>   
>>> platform/core/trunk/xwiki-rendering/xwiki-rendering-macros/xwiki-rendering-macro-include/src/test/java/org/xwiki/rendering/internal/macro/IncludeMacroTest.java
>>> Log:
>>> XWIKI-4115: Include macro should protect from recursive inclusion
>>> 
>> 
>> [snip]
>> 
>>> +
>>> +    @Test
>>> +    public void testIncludeMacroWithRecursiveInclude() throws Exception
>>> +    {
>>> +        this.mockSetup.mockery.checking(new Expectations() {{
>>> +            
>>> oneOf(mockSetup.documentReferenceResolver).resolve("wiki:Space.Page");
>>> +                will(returnValue(new DocumentReference("wiki", "Space", 
>>> "Page")));
>>> +            
>>> oneOf(mockSetup.documentReferenceResolver).resolve("Space.Page");
>>> +                will(returnValue(new DocumentReference("wiki", "Space", 
>>> "Page")));
>>> +        }});
>>> +
>>> +        this.includeMacro.setDocumentAccessBridge(mockSetup.bridge);
>>> +
>>> +        MacroBlock includeMacro = new  MacroBlock("include", 
>>> Collections.singletonMap("document", "wiki:Space.Page"), false);
>>> +        new MacroMarkerBlock("include", 
>>> Collections.singletonMap("document", "Space.Page"), 
>>> Collections.<Block>singletonList(includeMacro), false);
>>> +        MacroTransformationContext context = new 
>>> MacroTransformationContext();
>>> +        context.setCurrentMacroBlock(includeMacro);
>>> +
>>> +        IncludeMacroParameters parameters = new IncludeMacroParameters();
>>> +        parameters.setDocument("wiki:Space.Page");
>>> +        parameters.setContext(Context.CURRENT);
>>> +
>>> +        List<Block> blocks;
>>> +        try {
>>> +            blocks = this.includeMacro.execute(parameters, null, context);
>>> +
>>> +            Assert.fail("The include macro did not checked the recusive 
>>> inclusion");
>>> +        } catch (MacroExecutionException e) {
>> 
>> s/e/expected/ ?
> 
> Yep would be more clear.
> 
>> 
>>> +            if (!e.getMessage().startsWith("Found recursive inclusion")) {
>>> +                throw e;
>> 
>> I think you should do an Assert.assertTrue() instead here.
> 
> Actually i wanted to let the bad exception pass to see in the test log
> why the test failed instead of just it failed.

For the test to be correct it should generate a failure and not an error.

Thanks
-Vincent

_______________________________________________
devs mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/devs

Reply via email to