1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.job.internal; |
21 |
|
|
22 |
|
import org.junit.Assert; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.extension.ResolveException; |
25 |
|
import org.xwiki.extension.TestResources; |
26 |
|
import org.xwiki.extension.handler.ExtensionHandler; |
27 |
|
import org.xwiki.extension.test.AbstractExtensionHandlerTest; |
28 |
|
import org.xwiki.extension.test.TestExtensionHandler; |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (52) |
Complexity: 8 |
Complexity Density: 0.18 |
|
30 |
|
public class UninstallJobTest extends AbstractExtensionHandlerTest |
31 |
|
{ |
32 |
|
private TestResources resources; |
33 |
|
|
34 |
|
private TestExtensionHandler handler; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
|
36 |
6 |
@Override... |
37 |
|
public void setUp() throws Exception |
38 |
|
{ |
39 |
6 |
super.setUp(); |
40 |
|
|
41 |
|
|
42 |
|
|
43 |
6 |
this.handler = (TestExtensionHandler) this.mocker.getInstance(ExtensionHandler.class, "test"); |
44 |
|
|
45 |
|
|
46 |
|
|
47 |
6 |
this.resources = new TestResources(); |
48 |
6 |
this.resources.init(this.installedExtensionRepository); |
49 |
|
} |
50 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
51 |
1 |
@Test... |
52 |
|
public void testUninstall() throws Throwable |
53 |
|
{ |
54 |
1 |
uninstall(TestResources.INSTALLED_ID, null); |
55 |
|
|
56 |
1 |
Assert.assertFalse(this.handler.getExtensions().get(null).contains(this.resources.installed)); |
57 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
58 |
|
null)); |
59 |
|
|
60 |
1 |
Assert.assertTrue(this.handler.getExtensions().get(null).contains(this.resources.installedDependency)); |
61 |
1 |
Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension( |
62 |
|
TestResources.INSTALLED_DEPENDENCY_ID.getId(), null)); |
63 |
|
} |
64 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
65 |
1 |
@Test... |
66 |
|
public void testUninstallWithBackwarDepencency() throws Throwable |
67 |
|
{ |
68 |
1 |
uninstall(TestResources.INSTALLED_DEPENDENCY_ID, null); |
69 |
|
|
70 |
1 |
Assert.assertFalse(this.handler.getExtensions().get(null).contains(this.resources.installed)); |
71 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
72 |
|
null)); |
73 |
|
|
74 |
1 |
Assert.assertFalse(this.handler.getExtensions().get(null).contains(this.resources.installedDependency)); |
75 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension( |
76 |
|
TestResources.INSTALLED_DEPENDENCY_ID.getId(), null)); |
77 |
|
} |
78 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 2 |
Complexity Density: 0.67 |
1PASS
|
|
79 |
1 |
@Test... |
80 |
|
public void testUninstallTwice() throws Throwable |
81 |
|
{ |
82 |
1 |
uninstall(TestResources.INSTALLED_ID, null); |
83 |
|
|
84 |
1 |
try { |
85 |
1 |
uninstall(TestResources.INSTALLED_ID, null); |
86 |
|
} catch (ResolveException expected) { |
87 |
|
|
88 |
|
} |
89 |
|
} |
90 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
91 |
1 |
@Test... |
92 |
|
public void testUninstallFromNamespace() throws Throwable |
93 |
|
{ |
94 |
|
|
95 |
|
|
96 |
1 |
uninstall(TestResources.INSTALLED_DEPENDENCY_ID, null); |
97 |
1 |
install(TestResources.INSTALLED_ID, "namespace1"); |
98 |
1 |
install(TestResources.INSTALLED_ID, "namespace2"); |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
1 |
uninstall(TestResources.INSTALLED_ID, "namespace1"); |
103 |
|
|
104 |
1 |
Assert.assertFalse(this.handler.getExtensions().get("namespace1").contains(this.resources.installed)); |
105 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
106 |
|
"namespace1")); |
107 |
|
|
108 |
1 |
Assert.assertTrue(this.handler.getExtensions().get("namespace2").contains(this.resources.installed)); |
109 |
1 |
Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension( |
110 |
|
TestResources.INSTALLED_ID.getId(), "namespace2")); |
111 |
|
} |
112 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
113 |
1 |
@Test... |
114 |
|
public void testUninstallFromNamespaceWithBackwarDepencency() throws Throwable |
115 |
|
{ |
116 |
|
|
117 |
|
|
118 |
1 |
uninstall(TestResources.INSTALLED_DEPENDENCY_ID, null); |
119 |
1 |
install(TestResources.INSTALLED_ID, "namespace1"); |
120 |
1 |
install(TestResources.INSTALLED_ID, "namespace2"); |
121 |
|
|
122 |
|
|
123 |
|
|
124 |
1 |
uninstall(TestResources.INSTALLED_DEPENDENCY_ID, "namespace1"); |
125 |
|
|
126 |
1 |
Assert.assertFalse(this.handler.getExtensions().get("namespace1").contains(this.resources.installed)); |
127 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
128 |
|
"namespace1")); |
129 |
1 |
Assert.assertFalse(this.handler.getExtensions().get("namespace1").contains(this.resources.installedDependency)); |
130 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension( |
131 |
|
TestResources.INSTALLED_DEPENDENCY_ID.getId(), "namespace1")); |
132 |
|
|
133 |
1 |
Assert.assertTrue(this.handler.getExtensions().get("namespace2").contains(this.resources.installed)); |
134 |
1 |
Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension( |
135 |
|
TestResources.INSTALLED_ID.getId(), "namespace2")); |
136 |
1 |
Assert.assertTrue(this.handler.getExtensions().get("namespace2").contains(this.resources.installed)); |
137 |
1 |
Assert.assertNotNull(this.installedExtensionRepository.getInstalledExtension( |
138 |
|
TestResources.INSTALLED_ID.getId(), "namespace2")); |
139 |
|
} |
140 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
141 |
1 |
@Test... |
142 |
|
public void testUninstallFromAllNamespaces() throws Throwable |
143 |
|
{ |
144 |
|
|
145 |
|
|
146 |
1 |
uninstall(TestResources.INSTALLED_DEPENDENCY_ID, null); |
147 |
1 |
install(TestResources.INSTALLED_ID, "namespace1"); |
148 |
1 |
install(TestResources.INSTALLED_ID, "namespace2"); |
149 |
|
|
150 |
|
|
151 |
|
|
152 |
1 |
uninstall(TestResources.INSTALLED_ID, null); |
153 |
|
|
154 |
1 |
Assert.assertFalse(this.handler.getExtensions().get("namespace1").contains(this.resources.installed)); |
155 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
156 |
|
"namespace1")); |
157 |
|
|
158 |
1 |
Assert.assertFalse(this.handler.getExtensions().get("namespace2").contains(this.resources.installed)); |
159 |
1 |
Assert.assertNull(this.installedExtensionRepository.getInstalledExtension(TestResources.INSTALLED_ID.getId(), |
160 |
|
"namespace2")); |
161 |
|
} |
162 |
|
} |