Search in sources :

Example 1 with QueryManagerScriptService

use of org.xwiki.query.script.QueryManagerScriptService in project xwiki-platform by xwiki.

the class HelpTest method verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection.

/**
 * The bug we're trying to prevent happening again was that there was that "$subHeading" was rendered when going to
 * the Links section (for example).
 * Note: It was working fine when displaying all sections though.
 * @see <a href="https://jira.xwiki.org/browse/XWIKI-13650">XWIKI-13650</a>
 */
@Test
public void verifySubHeadingVelocityVariableCorrectlyEvaluatedWhenUsedInSection() throws Exception {
    // URL that we're simulating:
    // http://localhost:8080/xwiki/bin/view/XWiki/XWikiSyntax?syntax=2.1&section=Links&xpage=print
    setOutputSyntax(Syntax.XHTML_1_0);
    request.put("section", "Links");
    request.put("xpage", "print");
    // Register the XWikiSyntaxLinks page with an XWikiSyntaxClass xobject in it so that it can be found later on
    // by XWiki.XWikiSyntax
    loadPage(new DocumentReference("xwiki", "XWiki", "XWikiSyntaxLinks"));
    // Register query script service since it's not registered by default and it's used in XWiki.XWikiSyntax to
    // find all syntax pages.
    QueryManagerScriptService qss = mock(QueryManagerScriptService.class);
    mocker.registerComponent(ScriptService.class, "query", qss);
    ScriptQuery sq = mock(ScriptQuery.class);
    when(qss.xwql(contains("from doc.object(XWiki.XWikiSyntaxClass)"))).thenReturn(sq);
    when(sq.addFilter((String) any())).thenReturn(sq);
    when(sq.execute()).thenReturn(Arrays.asList("XWiki.XWikiSyntaxLinks"));
    String result = renderPage(new DocumentReference("xwiki", "XWiki", "XWikiSyntax"));
    assertTrue("$subHeading should have been evaluated and replaced by '==='", result.contains("<h3 id=\"HXWikiSyntax2.1LinkSpecification\""));
    assertTrue("$subHeading should have been evaluated and replaced by '==='", !result.contains("$subHeading"));
}
Also used : QueryManagerScriptService(org.xwiki.query.script.QueryManagerScriptService) ScriptQuery(org.xwiki.query.internal.ScriptQuery) DocumentReference(org.xwiki.model.reference.DocumentReference) PageTest(org.xwiki.test.page.PageTest) Test(org.junit.Test)

Example 2 with QueryManagerScriptService

use of org.xwiki.query.script.QueryManagerScriptService in project xwiki-platform by xwiki.

the class WebRssTest method setUp.

@Before
public void setUp() throws Exception {
    setOutputSyntax(Syntax.PLAIN_1_0);
    request.put("outputSyntax", "plain");
    request.put("xpage", "plain");
    QueryManagerScriptService qmss = mock(QueryManagerScriptService.class);
    oldcore.getMocker().registerComponent(ScriptService.class, "query", qmss);
    query = mock(ScriptQuery.class);
    when(qmss.xwql("where 1=1 order by doc.date desc")).thenReturn(query);
}
Also used : QueryManagerScriptService(org.xwiki.query.script.QueryManagerScriptService) ScriptQuery(org.xwiki.query.internal.ScriptQuery) Before(org.junit.Before)

Aggregations

ScriptQuery (org.xwiki.query.internal.ScriptQuery)2 QueryManagerScriptService (org.xwiki.query.script.QueryManagerScriptService)2 Before (org.junit.Before)1 Test (org.junit.Test)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 PageTest (org.xwiki.test.page.PageTest)1