1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.help

File HelpTest.java

 
verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection: Failed to lookup default document displayer.
 

Code metrics

0
13
1
1
81
37
1
0.08
13
1
1

Classes

Class Line # Actions
HelpTest 45 13 0% 1 14
0.00%
 

Contributing tests

This file is covered by 1 test. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.help;
21   
22    import java.util.Arrays;
23   
24    import org.junit.Test;
25    import org.xwiki.model.reference.DocumentReference;
26    import org.xwiki.query.internal.ScriptQuery;
27    import org.xwiki.query.script.QueryManagerScriptService;
28    import org.xwiki.rendering.syntax.Syntax;
29    import org.xwiki.script.service.ScriptService;
30    import org.xwiki.test.page.PageTest;
31    import org.xwiki.test.page.XHTML10ComponentList;
32    import org.xwiki.test.page.XWikiSyntax21ComponentList;
33   
34    import static org.mockito.Mockito.*;
35    import static org.junit.Assert.*;
36   
37    /**
38    * Unit tests for testing the {@code XWiki.XWikiSyntax} wiki page.
39    *
40    * @version $Id: fdaeac5bd26ec67a66c109ab8b4949deb5636e7f $
41    * @since 8.3M2
42    */
43    @XWikiSyntax21ComponentList
44    @XHTML10ComponentList
 
45    public class HelpTest extends PageTest
46    {
47    /**
48    * The bug we're trying to prevent happening again was that there was that "$subHeading" was rendered when going to
49    * the Links section (for example).
50    * Note: It was working fine when displaying all sections though.
51    * @see <a href="http://jira.xwiki.org/browse/XWIKI-13650">XWIKI-13650</a>
52    */
 
53  0 toggle @Test
54    public void verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection() throws Exception
55    {
56    // URL that we're simulating:
57    // http://localhost:8080/xwiki/bin/view/XWiki/XWikiSyntax?syntax=2.1&section=Links&xpage=print
58  0 setOutputSyntax(Syntax.XHTML_1_0);
59  0 request.put("section", "Links");
60  0 request.put("xpage", "print");
61   
62    // Register the XWikiSyntaxLinks page with an XWikiSyntaxClass xobject in it so that it can be found later on
63    // by XWiki.XWikiSyntax
64  0 loadPage(new DocumentReference("xwiki", "XWiki", "XWikiSyntaxLinks"));
65   
66    // Register query script service since it's not registered by default and it's used in XWiki.XWikiSyntax to
67    // find all syntax pages.
68  0 QueryManagerScriptService qss = mock(QueryManagerScriptService.class);
69  0 mocker.registerComponent(ScriptService.class, "query", qss);
70  0 ScriptQuery sq = mock(ScriptQuery.class);
71  0 when(qss.xwql(contains("from doc.object(XWiki.XWikiSyntaxClass)"))).thenReturn(sq);
72  0 when(sq.addFilter((String)any())).thenReturn(sq);
73  0 when(sq.execute()).thenReturn(Arrays.asList("XWiki.XWikiSyntaxLinks"));
74   
75  0 Test failure here String result = renderPage(new DocumentReference("xwiki", "XWiki", "XWikiSyntax"));
76  0 assertTrue("$subHeading should have been evaluated and replaced by '==='", result.contains(
77    "<h3 id=\"HXWikiSyntax2.1LinkSpecification\" class=\"wikigeneratedheader\">"
78    + "<span>XWiki Syntax 2.1 Link Specification</span></h3>"));
79  0 assertTrue("$subHeading should have been evaluated and replaced by '==='", !result.contains("$subHeading"));
80    }
81    }