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

File BlogCategoriesTest.java

 

Code metrics

0
22
5
1
121
62
5
0.23
4.4
5
1

Classes

Class Line # Actions
BlogCategoriesTest 39 22 0% 5 0
1.0100%
 

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.blog.test.ui;
21   
22    import java.lang.Exception;import java.lang.String;import org.junit.Assert;
23   
24    import org.junit.Before;
25    import org.junit.Rule;
26    import org.junit.Test;
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    import org.xwiki.blog.test.po.ManageCategoriesPage;
32   
33    /**
34    * Test Blog categories. Tested features: add, rename, delete.
35    *
36    * @version $Id: 5c723193684a10fa7b842476d8e06742691056ed $
37    * @since 2.3M2
38    */
 
39    public class BlogCategoriesTest extends AbstractTest
40    {
41    @Rule
42    public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil());
43   
44    /**
45    * We make sure to have spaces and special chars to ensure categories can be named with any char.
46    */
47    private static final String CATEGORY = "The \"Do\"s & Don'ts";
48   
49    private static final String CATEGORY_RENAME = "New \"categor'y\"";
50   
51    private static final String CATEGORY_RENAME_2 =
52    "A category with [[//wiki// syntax]] # || onclick=\"alert('fail');return false;\"";
53   
 
54  1 toggle @Before
55    public void setUp() throws Exception
56    {
57    // clean up
58  1 getUtil().deletePage("Blog", CATEGORY);
59  1 getUtil().deletePage("Blog", CATEGORY_RENAME);
60  1 getUtil().deletePage("Blog", CATEGORY_RENAME_2);
61    }
62   
 
63  1 toggle @Test
64    @IgnoreBrowsers({
65    @IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"),
66    @IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177")
67    })
68    public void testCategoryAddRenameRemove()
69    {
70  1 categoryAdd(CATEGORY);
71  1 categoryRename(CATEGORY, CATEGORY_RENAME);
72  1 categoryRename(CATEGORY_RENAME, CATEGORY_RENAME_2);
73  1 categoryRemove(CATEGORY_RENAME_2);
74    }
75   
76    /**
77    * Helper method that adds a new category and checks for success
78    *
79    * @param name
80    */
 
81  1 toggle private void categoryAdd(String name)
82    {
83  1 ManageCategoriesPage categoriesPage = ManageCategoriesPage.gotoPage();
84  1 Assert.assertFalse(categoriesPage.isCategoryPresent(name));
85   
86  1 categoriesPage.clickAddCategory();
87  1 categoriesPage.addCategory(name);
88  1 Assert.assertTrue(categoriesPage.isCategoryPresent(name));
89    }
90   
91    /**
92    * Helper method that renames a category and checks for success
93    *
94    * @param fromName source name, must exist
95    * @param toName target name, must not exist
96    */
 
97  2 toggle private void categoryRename(String fromName, String toName)
98    {
99  2 ManageCategoriesPage categoriesPage = ManageCategoriesPage.gotoPage();
100  2 Assert.assertTrue(categoriesPage.isCategoryPresent(fromName));
101  2 Assert.assertFalse(categoriesPage.isCategoryPresent(toName));
102   
103  2 categoriesPage.renameCategory(fromName, toName);
104  2 Assert.assertFalse(categoriesPage.isCategoryPresent(fromName));
105  2 Assert.assertTrue(categoriesPage.isCategoryPresent(toName));
106    }
107   
108    /**
109    * Helper method that removes a category and checks for success
110    *
111    * @param name category name, must exist
112    */
 
113  1 toggle private void categoryRemove(String name)
114    {
115  1 ManageCategoriesPage categoriesPage = ManageCategoriesPage.gotoPage();
116  1 Assert.assertTrue(categoriesPage.isCategoryPresent(name));
117   
118  1 categoriesPage.deleteCategory(name);
119  1 Assert.assertFalse(categoriesPage.isCategoryPresent(name));
120    }
121    }