1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.activeinstalls.test.ui; |
21 |
|
|
22 |
|
import org.junit.*; |
23 |
|
import org.xwiki.activeinstalls.test.po.ActiveInstallsHomePage; |
24 |
|
import org.xwiki.panels.test.po.ApplicationsPanel; |
25 |
|
import org.xwiki.test.ui.AbstractTest; |
26 |
|
import org.xwiki.test.ui.SuperAdminAuthenticationRule; |
27 |
|
import org.xwiki.test.ui.po.ViewPage; |
28 |
|
|
29 |
|
import static org.junit.Assert.*; |
30 |
|
import static com.github.tlrx.elasticsearch.test.EsSetup.*; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 98.2% |
Uncovered Elements: 1 (57) |
Complexity: 4 |
Complexity Density: 0.08 |
|
38 |
|
public class ActiveInstallsTest extends AbstractTest |
39 |
|
{ |
40 |
|
@Rule |
41 |
|
public SuperAdminAuthenticationRule authenticationRule = new SuperAdminAuthenticationRule(getUtil()); |
42 |
|
|
|
|
| 98.2% |
Uncovered Elements: 1 (56) |
Complexity: 4 |
Complexity Density: 0.08 |
1PASS
|
|
43 |
1 |
@Test... |
44 |
|
public void verifyActiveInstalls() throws Exception |
45 |
|
{ |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
1 |
if (ElasticSearchRunner.esSetup != null) { |
50 |
|
|
51 |
|
|
52 |
|
|
53 |
|
|
54 |
|
|
55 |
|
|
56 |
1 |
long count = 0; |
57 |
1 |
long time = System.currentTimeMillis(); |
58 |
2 |
while (count != 1 && (System.currentTimeMillis() - time) < 5000L) { |
59 |
1 |
count = ElasticSearchRunner.esSetup.countAll(); |
60 |
1 |
Thread.sleep(100L); |
61 |
|
} |
62 |
|
|
63 |
|
|
64 |
|
|
65 |
1 |
ElasticSearchRunner.esSetup.execute(index("installs", "install", "156231f3-705b-44c6-afe3-e191bcc4b746") |
66 |
|
.withSource("{ \"formatVersion\": \"1.0\", \"distributionVersion\": \"5.2\", " |
67 |
|
+ "\"distributionId\": \"org.xwiki.platform:xwiki-platform-web\", " |
68 |
|
+ "\"date\": \"2013-09-16T20:00:34.277Z\", \"extensions\": [ ] }")); |
69 |
|
} |
70 |
|
|
71 |
|
|
72 |
|
|
73 |
|
|
74 |
1 |
ApplicationsPanel applicationPanel = ApplicationsPanel.gotoPage(); |
75 |
1 |
ViewPage vp = applicationPanel.clickApplication("Active Installs"); |
76 |
|
|
77 |
|
|
78 |
1 |
Assert.assertEquals(ActiveInstallsHomePage.getSpace(), vp.getMetaDataValue("space")); |
79 |
1 |
Assert.assertEquals(ActiveInstallsHomePage.getPage(), vp.getMetaDataValue("page")); |
80 |
|
|
81 |
|
|
82 |
1 |
getUtil().updateObject("ActiveInstalls", "ActiveInstallsConfig", "ActiveInstalls.ActiveInstallsConfig", 0, |
83 |
|
"distributionId", "org.xwiki.*"); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
1 |
getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue2"); |
89 |
1 |
vp = new ViewPage(); |
90 |
1 |
assertEquals("0", vp.getContent()); |
91 |
|
|
92 |
|
|
93 |
1 |
getUtil().gotoPage("ActiveInstalls", "TotalCounterValue2"); |
94 |
1 |
vp = new ViewPage(); |
95 |
1 |
assertEquals("0", vp.getContent()); |
96 |
|
|
97 |
|
|
98 |
|
|
99 |
1 |
getUtil().updateObject("ActiveInstalls", "ActiveInstallsConfig", "ActiveInstalls.ActiveInstallsConfig", 0, |
100 |
|
"snapshots", true); |
101 |
|
|
102 |
|
|
103 |
1 |
getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue2"); |
104 |
1 |
vp = new ViewPage(); |
105 |
1 |
assertEquals("1", vp.getContent()); |
106 |
|
|
107 |
|
|
108 |
1 |
getUtil().gotoPage("ActiveInstalls", "ActiveCounterValue1"); |
109 |
1 |
vp = new ViewPage(); |
110 |
1 |
assertEquals("0", vp.getContent()); |
111 |
|
|
112 |
|
|
113 |
1 |
getUtil().gotoPage("ActiveInstalls", "TotalCounterValue2"); |
114 |
1 |
vp = new ViewPage(); |
115 |
1 |
assertEquals("1", vp.getContent()); |
116 |
|
|
117 |
|
|
118 |
1 |
getUtil().gotoPage("ActiveInstalls", "TotalCounterValue1"); |
119 |
1 |
vp = new ViewPage(); |
120 |
1 |
assertEquals("1", vp.getContent()); |
121 |
|
|
122 |
|
|
123 |
1 |
getUtil().gotoPage("ActiveInstalls", "JavaVersionsData"); |
124 |
1 |
vp = new ViewPage(); |
125 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
126 |
|
vp.getContent().matches("Java Version Active Installs Count\\r?\\n1\\.[0-9_\\.]* 1")); |
127 |
|
|
128 |
|
|
129 |
1 |
getUtil().gotoPage("ActiveInstalls", "DatabasesData"); |
130 |
1 |
vp = new ViewPage(); |
131 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
132 |
|
vp.getContent().matches("Database Active Installs Count\\r?\\nHSQL Database Engine 1")); |
133 |
|
|
134 |
|
|
135 |
1 |
getUtil().gotoPage("ActiveInstalls", "DistributionData"); |
136 |
1 |
vp = new ViewPage(); |
137 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
138 |
|
vp.getContent().matches("Distributions Active Installs Count\\r?\\n" |
139 |
|
+ "org.xwiki.platform:xwiki-platform-web 1")); |
140 |
|
|
141 |
|
|
142 |
1 |
getUtil().gotoPage("ActiveInstalls", "XWikiVersionsData"); |
143 |
1 |
vp = new ViewPage(); |
144 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
145 |
|
vp.getContent().matches("XWiki Version Active Installs Count\\r?\\n[0-9]\\.[0-9].* 1")); |
146 |
|
|
147 |
|
|
148 |
1 |
getUtil().gotoPage("ActiveInstalls", "XWikiVersionsCycleData"); |
149 |
1 |
vp = new ViewPage(); |
150 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
151 |
|
vp.getContent().matches("XWiki Version Active Installs Count\\r?\\n[0-9]+\\.x 1")); |
152 |
|
|
153 |
|
|
154 |
1 |
getUtil().gotoPage("ActiveInstalls", "ServletContainersData"); |
155 |
1 |
vp = new ViewPage(); |
156 |
1 |
assertTrue("Got [" + vp.getContent() + "]", |
157 |
|
vp.getContent().matches("Servlet Container Active Installs Count\\r?\\njetty 1")); |
158 |
|
|
159 |
|
|
160 |
|
|
161 |
1 |
String content = "{{include reference=\"ActiveInstalls.ExtensionCount\"/}}\n" |
162 |
|
+ "\n" |
163 |
|
+ "{{velocity}}\n" |
164 |
|
+ "#set ($extensionIds = [\n" |
165 |
|
+ " 'org.xwiki.contrib:xwiki-totem-application',\n" |
166 |
|
+ " 'jsimard:event-reporter-application',\n" |
167 |
|
+ " 'mouhb:likeapplication'\n" |
168 |
|
+ "])\n" |
169 |
|
+ "|=Extension Id|=Count\n" |
170 |
|
+ "#foreach($extensionId in $extensionIds)\n" |
171 |
|
+ " #countActiveInstallsUsingExtension($extensionId $count)\n" |
172 |
|
+ " |$extensionId|$count\n" |
173 |
|
+ "#end\n" |
174 |
|
+ "{{/velocity}}"; |
175 |
1 |
vp = getUtil().createPage(getTestClassName(), "ExtensionCountExample", content, "Example"); |
176 |
1 |
assertTrue("Got [" + vp.getContent() + "]", vp.getContent().matches("Extension Id Count\n" |
177 |
|
+ "org.xwiki.contrib:xwiki-totem-application 0\n" |
178 |
|
+ "jsimard:event-reporter-application 0\n" |
179 |
|
+ "mouhb:likeapplication 0")); |
180 |
|
} |
181 |
|
} |