1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.extension.xar.internal.job; |
21 |
|
|
22 |
|
import org.junit.Before; |
23 |
|
import org.junit.Test; |
24 |
|
import org.xwiki.extension.ExtensionId; |
25 |
|
import org.xwiki.extension.InstalledExtension; |
26 |
|
import org.xwiki.extension.repository.InstalledExtensionRepository; |
27 |
|
import org.xwiki.extension.test.AbstractExtensionHandlerTest; |
28 |
|
import org.xwiki.extension.xar.internal.handler.XarExtensionHandler; |
29 |
|
import org.xwiki.job.Job; |
30 |
|
import org.xwiki.logging.LogLevel; |
31 |
|
import org.xwiki.security.authorization.ContextualAuthorizationManager; |
32 |
|
|
33 |
|
import static org.junit.Assert.assertFalse; |
34 |
|
import static org.junit.Assert.assertTrue; |
35 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (25) |
Complexity: 5 |
Complexity Density: 0.25 |
|
36 |
|
public class RepairXarJobTest extends AbstractExtensionHandlerTest |
37 |
|
{ |
38 |
|
private InstalledExtensionRepository xarExtensionRepository; |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
40 |
3 |
@Override... |
41 |
|
@Before |
42 |
|
public void setUp() throws Exception |
43 |
|
{ |
44 |
3 |
super.setUp(); |
45 |
|
|
46 |
3 |
this.mocker.registerMockComponent(ContextualAuthorizationManager.class); |
47 |
|
|
48 |
3 |
this.xarExtensionRepository = |
49 |
|
this.mocker.getInstance(InstalledExtensionRepository.class, XarExtensionHandler.TYPE); |
50 |
|
} |
51 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
52 |
3 |
protected Job repair(ExtensionId extensionId, String[] namespaces, LogLevel failFrom) throws Throwable... |
53 |
|
{ |
54 |
3 |
return install(RepairXarJob.JOBTYPE, extensionId, namespaces, failFrom); |
55 |
|
} |
56 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
57 |
1 |
@Test... |
58 |
|
public void testRepairOnRoot() throws Throwable |
59 |
|
{ |
60 |
1 |
ExtensionId extensionId = new ExtensionId("test", "1.0"); |
61 |
|
|
62 |
1 |
repair(extensionId, null, LogLevel.WARN); |
63 |
|
|
64 |
1 |
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId); |
65 |
|
|
66 |
1 |
assertTrue(installedExtension.isValid(null)); |
67 |
|
|
68 |
1 |
installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0")); |
69 |
|
|
70 |
1 |
assertTrue(installedExtension.isValid(null)); |
71 |
|
} |
72 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
73 |
1 |
@Test... |
74 |
|
public void testRepairOnWiki() throws Throwable |
75 |
|
{ |
76 |
1 |
ExtensionId extensionId = new ExtensionId("test", "1.0"); |
77 |
|
|
78 |
1 |
repair(extensionId, new String[] {"wiki:wiki1"}, LogLevel.WARN); |
79 |
|
|
80 |
1 |
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId); |
81 |
|
|
82 |
1 |
assertTrue(installedExtension.isValid(null)); |
83 |
|
|
84 |
1 |
installedExtension = this.xarExtensionRepository.resolve(new ExtensionId("dependency", "1.0")); |
85 |
|
|
86 |
1 |
assertTrue(installedExtension.isValid(null)); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
1PASS
|
|
89 |
1 |
@Test... |
90 |
|
public void testRepairInvalidOnRoot() throws Throwable |
91 |
|
{ |
92 |
1 |
ExtensionId extensionId = new ExtensionId("invalid", "1.0"); |
93 |
|
|
94 |
1 |
repair(extensionId, null, LogLevel.ERROR); |
95 |
|
|
96 |
1 |
InstalledExtension installedExtension = this.xarExtensionRepository.resolve(extensionId); |
97 |
|
|
98 |
1 |
assertFalse(installedExtension.isValid(null)); |
99 |
|
} |
100 |
|
} |