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

File AnnotationsTest.java

 

Code metrics

0
21
2
1
116
64
2
0.1
10.5
2
1

Classes

Class Line # Actions
AnnotationsTest 38 21 0% 2 0
1.0100%
 

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.annotation.test.ui;
21   
22    import java.lang.String;
23    import org.junit.Assert;
24    import org.junit.Rule;
25    import org.junit.Test;
26    import org.xwiki.annotation.test.po.AnnotatableViewPage;
27    import org.xwiki.test.ui.AbstractTest;
28    import org.xwiki.test.ui.SuperAdminAuthenticationRule;
29    import org.xwiki.test.ui.browser.IgnoreBrowser;
30    import org.xwiki.test.ui.browser.IgnoreBrowsers;
31   
32    /**
33    * Annotation Test.
34    *
35    * @version $Id: 6912a3f0d56689b0252c15ab3fa96ea32b50e884 $
36    * @since 2.7RC1
37    */
 
38    public class AnnotationsTest extends AbstractTest
39    {
40    @Rule
41    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
42   
43    // Note: Make sure Annotations and Comments are merged (this is not the default ATM!) by setting the
44    // $showannotation velocity variable to false in the page content
45    private static final String CONTENT = "{{velocity}}#set ($showannotations = false){{/velocity}}"
46    + "It's an easy-to-edit website that will help you work better together. This Wiki is made of pages "
47    + "sorted by spaces. You're currently in the Main space, looking at its home page (WebHome).";
48   
49    private static final String ANNOTATED_TEXT_1 = "work better together";
50   
51    private static final String ANNOTATION_TEXT_1 = "XWiki motto";
52   
53    private static final String ANNOTATED_TEXT_2 = "WebHome";
54   
55    private static final String ANNOTATION_TEXT_2 = "Every Space has it's own webhome";
56   
57    private static final String ANNOTATED_TEXT_3 = "Main space";
58   
59    private static final String ANNOTATION_TEXT_3 = "Each XWiki instance has a Main space";
60   
61    private static final String ANNOTATED_TEXT_4 = "easy-to-edit website";
62   
63    private static final String ANNOTATION_TEXT_4 = "Yes, we have our WYSIWYG";
64   
 
65  1 toggle @Test
66    @IgnoreBrowsers({
67    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
68    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
69    })
70    public void addAndDeleteAnnotations()
71    {
72  1 getUtil().deletePage(getTestClassName(), getTestMethodName());
73  1 AnnotatableViewPage annotatableViewPage = new AnnotatableViewPage(
74    getUtil().createPage(getTestClassName(), getTestMethodName(), CONTENT, null));
75   
76  1 annotatableViewPage.addAnnotation(ANNOTATED_TEXT_1, ANNOTATION_TEXT_1);
77  1 Assert.assertEquals(ANNOTATION_TEXT_1, annotatableViewPage.getAnnotationContentByText(ANNOTATED_TEXT_1));
78  1 annotatableViewPage.addAnnotation(ANNOTATED_TEXT_2, ANNOTATION_TEXT_2);
79  1 Assert.assertEquals(ANNOTATION_TEXT_2, annotatableViewPage.getAnnotationContentByText(ANNOTATED_TEXT_2));
80  1 annotatableViewPage.addAnnotation(ANNOTATED_TEXT_3, ANNOTATION_TEXT_3);
81  1 Assert.assertEquals(ANNOTATION_TEXT_3, annotatableViewPage.getAnnotationContentByText(ANNOTATED_TEXT_3));
82  1 annotatableViewPage.addAnnotation(ANNOTATED_TEXT_4, ANNOTATION_TEXT_4);
83  1 Assert.assertEquals(ANNOTATION_TEXT_4, annotatableViewPage.getAnnotationContentByText(ANNOTATED_TEXT_4));
84   
85    // It seems that there are some issues refreshing content while this tab is not open. This might be a bug in the
86    // Annotations Application
87  1 annotatableViewPage.showAnnotationsPane();
88  1 annotatableViewPage.deleteAnnotationByText(ANNOTATED_TEXT_1);
89  1 annotatableViewPage.deleteAnnotationByText(ANNOTATED_TEXT_2);
90  1 annotatableViewPage.deleteAnnotationByText(ANNOTATED_TEXT_3);
91  1 annotatableViewPage.deleteAnnotationByText(ANNOTATED_TEXT_4);
92    }
93   
94    /**
95    * This test creates a XWiki 1.0 syntax page, and tries to add annotations to it, and checks if the warning messages
96    * are shown This test is against XAANNOTATIONS-17
97    */
 
98  1 toggle @Test
99    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
100    public void annotationsShouldNotBeShownInXWiki10Syntax()
101    {
102  1 getUtil().deletePage(getTestClassName(), getTestMethodName());
103    // Note: Make sure Annotations and Comments are merged (this is not the default ATM!) by setting the
104    // $showannotation velocity variable to false in the page content
105  1 AnnotatableViewPage annotatableViewPage = new AnnotatableViewPage(
106    getUtil().createPage(getTestClassName(), getTestMethodName(),
107    "#set ($showannotations = false)\nSome content",
108    "AnnotationsTest in XWiki 1.0 Syntax", "xwiki/1.0"));
109   
110  1 annotatableViewPage.showAnnotationsPane();
111    // Annotations are disabled in 1.0 Pages. This element should no be here
112  1 Assert.assertTrue(annotatableViewPage.checkIfAnnotationsAreDisabled());
113  1 annotatableViewPage.simulateCTRL_M();
114  1 annotatableViewPage.waitforAnnotationWarningNotification();
115    }
116    }