1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.test.ui; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Rule; |
24 |
|
import org.junit.Test; |
25 |
|
import org.openqa.selenium.By; |
26 |
|
import org.xwiki.test.ui.browser.IgnoreBrowser; |
27 |
|
import org.xwiki.test.ui.browser.IgnoreBrowsers; |
28 |
|
import org.xwiki.test.ui.po.editor.WikiEditPage; |
29 |
|
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
@version |
34 |
|
@since |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (30) |
Complexity: 7 |
Complexity Density: 0.32 |
|
36 |
|
public class TemplateTest extends AbstractTest |
37 |
|
{ |
38 |
|
@Rule |
39 |
|
public AdminAuthenticationRule adminAuthenticationRule = new AdminAuthenticationRule(getUtil()); |
40 |
|
|
41 |
|
|
42 |
|
private WikiEditPage editPage; |
43 |
|
|
44 |
|
|
45 |
|
|
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
1PASS
|
|
47 |
1 |
@Test... |
48 |
|
@IgnoreBrowsers({ |
49 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
50 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
51 |
|
}) |
52 |
|
public void testHelloVelocity() |
53 |
|
{ |
54 |
1 |
String hello = "Hello Velocity Test Test Test"; |
55 |
1 |
saveVelocity(hello); |
56 |
1 |
Assert.assertTrue(getDriver().findElement(By.id("xwikicontent")).getText().contains(hello)); |
57 |
|
} |
58 |
|
|
59 |
|
|
60 |
|
|
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
1PASS
|
|
62 |
1 |
@Test... |
63 |
|
@IgnoreBrowsers({ |
64 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
65 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
66 |
|
}) |
67 |
|
public void testCorrectTemplate() |
68 |
|
{ |
69 |
1 |
saveVelocity(includeTemplate("code.vm"), true); |
70 |
1 |
Assert.assertNotNull(getDriver().findElement( |
71 |
|
By.xpath("//div[@id='xwikicontent']//textarea[@class='wiki-code']"))); |
72 |
|
} |
73 |
|
|
74 |
|
|
75 |
|
|
76 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0.1 |
1PASS
|
|
77 |
1 |
@Test... |
78 |
|
@IgnoreBrowsers({ |
79 |
|
@IgnoreBrowser(value = "internet.*", version = "8\\.*", reason="See http://jira.xwiki.org/browse/XE-1146"), |
80 |
|
@IgnoreBrowser(value = "internet.*", version = "9\\.*", reason="See http://jira.xwiki.org/browse/XE-1177") |
81 |
|
}) |
82 |
|
public void testWrongTemplate() |
83 |
|
{ |
84 |
1 |
saveVelocity(includeTemplate("../../")); |
85 |
1 |
Assert.assertTrue("root directory", getDriver().findElement(By.id("xwikicontent")).getText().length() == 0); |
86 |
|
|
87 |
1 |
saveVelocity(includeTemplate("asdfasdf")); |
88 |
1 |
Assert.assertTrue("not existing template", |
89 |
|
getDriver().findElement(By.id("xwikicontent")).getText().length() == 0); |
90 |
|
|
91 |
1 |
saveVelocity(includeTemplate("../redirect")); |
92 |
1 |
Assert.assertTrue("file in the parent directory", getDriver().findElement(By.id("xwikicontent")).getText() |
93 |
|
.length() == 0); |
94 |
|
|
95 |
1 |
saveVelocity(includeTemplate("../WEB-INF/version.properties")); |
96 |
1 |
Assert.assertTrue("file in the wrong directory", getDriver().findElement(By.id("xwikicontent")).getText() |
97 |
|
.length() == 0); |
98 |
|
|
99 |
1 |
saveVelocity(includeTemplate("/chw/../../WEB-INF/../WEB-INF/lib/../version.properties")); |
100 |
1 |
Assert.assertTrue("file in the wrong directory, not normalized path", getDriver().findElement( |
101 |
|
By.id("xwikicontent")).getText().length() == 0); |
102 |
|
} |
103 |
|
|
104 |
|
|
105 |
|
@see |
106 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
107 |
6 |
private void saveVelocity(String code)... |
108 |
|
{ |
109 |
6 |
saveVelocity(code, false); |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@param |
117 |
|
@param |
118 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
119 |
7 |
private void saveVelocity(String code, boolean html)... |
120 |
|
{ |
121 |
7 |
this.editPage = WikiEditPage.gotoPage("Main", "TemplateTest"); |
122 |
7 |
if (html) { |
123 |
1 |
code = "{{html wiki=\"false\"}}\n" + code + "\n{{/html}}"; |
124 |
|
} |
125 |
7 |
this.editPage.setContent("{{velocity filter=\"none\"}}\n" + code + "\n{{/velocity}}\n"); |
126 |
7 |
this.editPage.clickSaveAndView(); |
127 |
|
} |
128 |
|
|
129 |
|
|
130 |
|
|
131 |
|
|
132 |
|
@param |
133 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
134 |
6 |
private String includeTemplate(String name)... |
135 |
|
{ |
136 |
6 |
return "#template(\"" + name + "\")\n"; |
137 |
|
} |
138 |
|
} |