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

File ObjectAndClassEditorTest.java

 

Code metrics

0
18
6
1
114
67
6
0.33
3
6
1

Classes

Class Line # Actions
ObjectAndClassEditorTest 37 18 0% 6 0
1.0100%
 

Contributing tests

This file is covered by 4 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.test.escaping;
21   
22    import org.junit.AfterClass;
23    import org.junit.BeforeClass;
24    import org.junit.Test;
25    import org.xwiki.test.escaping.framework.AbstractEscapingTest;
26    import org.xwiki.test.escaping.framework.AbstractManualTest;
27    import org.xwiki.test.escaping.framework.XMLEscapingValidator;
28   
29   
30    /**
31    * Manual tests for the object editor and class editor. Some of these tests need an existing class with specific field
32    * names.
33    *
34    * @version $Id: 3f57ed63951465f7e526d8a2da370454df7f977b $
35    * @since 2.5M1
36    */
 
37    public class ObjectAndClassEditorTest extends AbstractManualTest
38    {
39    /**
40    * Set up the test class. The tests need a special class and a document containing objects of that class, we put
41    * both into the same document.
42    */
 
43  1 toggle @BeforeClass
44    public static void init()
45    {
46  1 String test = XMLEscapingValidator.getTestString();
47    // create a new class
48  1 AbstractEscapingTest.getUrlContent(createUrl("propadd", test, test, params(kv("propname", "test"),
49    kv("proptype", "com.xpn.xwiki.objects.classes.StringClass"))));
50    // add a new property to that class
51  1 AbstractEscapingTest.getUrlContent(createUrl("propupdate", test, test, params(kv("test_disabled", "0"),
52    kv("test_name", "test"),
53    kv("test_prettyName", test),
54    kv("test_validationRegExp", test),
55    kv("test_validationMessage", test),
56    kv("test_number", "1"),
57    kv("test_size", "30"),
58    kv("test_picker", "0"),
59    kv("xeditaction", "edit"))));
60    // add a new object of that class to the class document
61  1 AbstractEscapingTest.getUrlContent(createUrl("view", test, test, params(kv("xpage", "editobject"),
62    kv("xaction", "addObject"),
63    kv("className", test + "." + test))));
64    // set the property of that object
65  1 AbstractEscapingTest.getUrlContent(createUrl("save", test, test, params(kv("classname", "-"),
66    kv(escapeUrl(test + "." + test + "_0_test"), test),
67    kv("xeditaction", "edit"))));
68    }
69   
70    /**
71    * Clean up after the tests.
72    */
 
73  1 toggle @AfterClass
74    public static void shutdown()
75    {
76    // delete the created class
77  1 String test = XMLEscapingValidator.getTestString();
78  1 AbstractEscapingTest.getUrlContent(createUrl("delete", test, test, params(kv("confirm", "1"))));
79    }
80   
 
81  1 toggle @Test
82    public void testClassEditor()
83    {
84  1 skipIfIgnored("templates/editclass.vm");
85  1 String test = XMLEscapingValidator.getTestString();
86  1 checkUnderEscaping(createUrl("edit", test, test, params(kv("editor", "class"))), "XWIKI-5404");
87    }
88   
 
89  1 toggle @Test
90    public void testObjectEditor()
91    {
92  1 skipIfIgnored("templates/editobject.vm");
93  1 String test = XMLEscapingValidator.getTestString();
94  1 checkUnderEscaping(createUrl("edit", test, test, params(kv("editor", "object"))), "XWIKI-5242");
95    }
96   
 
97  1 toggle @Test
98    public void testObjectProperty()
99    {
100  1 skipIfIgnored("templates/editobject.vm");
101  1 String test = XMLEscapingValidator.getTestString();
102  1 checkUnderEscaping(createUrl("edit", test, test, params(kv("editor", "object"),
103    kv("classname", test + "." + test), test("property"))), "XWIKI-5242");
104    }
105   
 
106  1 toggle @Test
107    public void testObjectXMaximized()
108    {
109  1 skipIfIgnored("templates/editobject.vm");
110  1 checkUnderEscaping(createUrl("edit", "Blog", "WebHome", params(kv("editor", "object"),
111    test("x-maximized"))), "XWIKI-5242");
112    }
113    }
114