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

File WebRssTest.java

 
webRssDisplay: Failed to lookup default document displayer.
webRssFiltersHiddenDocuments: Failed to lookup default document displayer.
 

Code metrics

0
20
3
1
97
54
3
0.15
6.67
3
1

Classes

Class Line # Actions
WebRssTest 49 20 0% 3 15
0.347826134.8%
 

Contributing tests

This file is covered by 2 tests. .

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.activitystream;
21   
22    import java.util.Arrays;
23   
24    import org.junit.Before;
25    import org.junit.Test;
26    import org.xwiki.model.reference.DocumentReference;
27    import org.xwiki.query.internal.ScriptQuery;
28    import org.xwiki.query.script.QueryManagerScriptService;
29    import org.xwiki.rendering.syntax.Syntax;
30    import org.xwiki.script.service.ScriptService;
31    import org.xwiki.test.page.PageTest;
32    import org.xwiki.test.page.XHTML10ComponentList;
33    import org.xwiki.test.page.XWikiSyntax20ComponentList;
34   
35    import com.xpn.xwiki.plugin.feed.FeedPlugin;
36    import com.xpn.xwiki.plugin.feed.FeedPluginApi;
37   
38    import static org.mockito.Mockito.*;
39    import static org.junit.Assert.*;
40   
41    /**
42    * Unit tests for testing the {@code Main.WebRss} wiki page.
43    *
44    * @version $Id: 4414b7cdbf528d2dbf101fddc2377f05fc21c195 $
45    * @since 7.3M1
46    */
47    @XWikiSyntax20ComponentList
48    @XHTML10ComponentList
 
49    public class WebRssTest extends PageTest
50    {
51    private ScriptQuery query;
52   
 
53  2 toggle @Before
54    public void setUp() throws Exception
55    {
56  2 setOutputSyntax(Syntax.PLAIN_1_0);
57  2 request.put("outputSyntax", "plain");
58  2 request.put("xpage", "plain");
59   
60  2 QueryManagerScriptService qmss = mock(QueryManagerScriptService.class);
61  2 oldcore.getMocker().registerComponent(ScriptService.class, "query", qmss);
62  2 query = mock(ScriptQuery.class);
63  2 when(qmss.xwql("where 1=1 order by doc.date desc")).thenReturn(query);
64    }
65   
 
66  0 toggle @Test
67    public void webRssFiltersHiddenDocuments() throws Exception
68    {
69    // Render the page to test
70  0 Test failure here renderPage(new DocumentReference("xwiki", "Main", "WebRss"));
71   
72    // This is the real test!!
73    // We want to verify that the hidden document filter is called when executing the XWQL
74    // query to get the list of modified pages
75  0 verify(query).addFilter("hidden/document");
76    }
77   
 
78  0 toggle @Test
79    public void webRssDisplay() throws Exception
80    {
81  0 when(query.addFilter(anyString())).thenReturn(query);
82  0 when(query.setLimit(20)).thenReturn(query);
83  0 when(query.setOffset(0)).thenReturn(query);
84  0 when(query.execute()).thenReturn(Arrays.<Object>asList("Space1.Page1", "Space2.Page2"));
85   
86  0 FeedPlugin plugin = new FeedPlugin("feed", FeedPlugin.class.getName(), context);
87  0 FeedPluginApi pluginApi = new FeedPluginApi(plugin, context);
88  0 doReturn(pluginApi).when(xwiki).getPluginApi("feed", context);
89   
90    // Render the page to test
91  0 Test failure here String xml = renderPage(new DocumentReference("xwiki", "Main", "WebRss"));
92   
93  0 assertTrue(xml.contains("<title>activity.rss.feed.description</title>"));
94  0 assertTrue(xml.contains("<title>Page1</title>"));
95  0 assertTrue(xml.contains("<title>Page2</title>"));
96    }
97    }