1. Project Clover database Sat Feb 2 2019 06:45:20 CET
  2. Package org.xwiki.rendering.internal.renderer.plain

File PlainTextChainingRendererTest.java

 

Code metrics

0
21
4
1
94
53
4
0.19
5.25
4
1

Classes

Class Line # Actions
PlainTextChainingRendererTest 40 21 0% 4 0
1.0100%
 

Contributing tests

No tests hitting this source file were found.

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.rendering.internal.renderer.plain;
21   
22    import java.util.Collections;
23   
24    import org.junit.Assert;
25    import org.junit.Before;
26    import org.junit.Test;
27    import org.xwiki.rendering.listener.reference.DocumentResourceReference;
28    import org.xwiki.rendering.listener.reference.ResourceReference;
29    import org.xwiki.rendering.listener.reference.ResourceType;
30    import org.xwiki.rendering.renderer.printer.DefaultWikiPrinter;
31    import org.xwiki.rendering.syntax.Syntax;
32    import org.xwiki.test.jmock.AbstractComponentTestCase;
33   
34    /**
35    * Unit tests for {@link PlainTextChainingRenderer} that cannot easily be performed using the Rendering Test framework.
36    *
37    * @version $Id: fe6db652c141bc8213d0174ba4c738dfcc11381e $
38    * @since 2.1M1
39    */
 
40    public class PlainTextChainingRendererTest extends AbstractComponentTestCase
41    {
42    private PlainTextRenderer renderer;
43   
 
44  3 toggle @Override
45    @Before
46    public void setUp() throws Exception
47    {
48  3 super.setUp();
49   
50    // Force the link label generator to be null
51  3 this.renderer = new PlainTextRenderer();
52  3 this.renderer.initialize();
53    }
54   
 
55  1 toggle @Test
56    public void testBeginLinkWhenLinkLabelGeneratorIsNull() throws Exception
57    {
58  1 DefaultWikiPrinter printer = new DefaultWikiPrinter();
59  1 this.renderer.setPrinter(printer);
60   
61  1 DocumentResourceReference reference = new DocumentResourceReference("reference");
62  1 reference.setAnchor("anchor");
63  1 reference.setQueryString("param=value");
64   
65  1 this.renderer.beginLink(reference, false, Collections.<String, String>emptyMap());
66  1 this.renderer.endLink(reference, false, Collections.<String, String>emptyMap());
67   
68  1 Assert.assertEquals("reference", printer.toString());
69    }
70   
 
71  1 toggle @Test
72    public void testBeginLinkWhenExternalLink() throws Exception
73    {
74  1 DefaultWikiPrinter printer = new DefaultWikiPrinter();
75  1 this.renderer.setPrinter(printer);
76   
77  1 ResourceReference reference = new ResourceReference("http://some/url", ResourceType.URL);
78  1 this.renderer.beginLink(reference, false, Collections.<String, String>emptyMap());
79  1 this.renderer.endLink(reference, false, Collections.<String, String>emptyMap());
80   
81  1 Assert.assertEquals("http://some/url", printer.toString());
82    }
83   
 
84  1 toggle @Test
85    public void testRawBlock()
86    {
87  1 DefaultWikiPrinter printer = new DefaultWikiPrinter();
88  1 this.renderer.setPrinter(printer);
89   
90  1 this.renderer.onRawText("raw content", Syntax.PLAIN_1_0);
91   
92  1 Assert.assertEquals("raw content", printer.toString());
93    }
94    }