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 java.lang.annotation.ElementType; |
23 |
|
import java.lang.annotation.Retention; |
24 |
|
import java.lang.annotation.RetentionPolicy; |
25 |
|
import java.lang.annotation.Target; |
26 |
|
import java.lang.reflect.Method; |
27 |
|
|
28 |
|
import org.junit.runners.model.InitializationError; |
29 |
|
import org.junit.runners.model.RunnerBuilder; |
30 |
|
import org.xwiki.test.integration.XWikiExecutorSuite; |
31 |
|
|
32 |
|
|
33 |
|
@link@link |
34 |
|
|
35 |
|
@version |
36 |
|
@since |
37 |
|
|
|
|
| 85.7% |
Uncovered Elements: 4 (28) |
Complexity: 9 |
Complexity Density: 0.45 |
|
38 |
|
public class PageObjectSuite extends XWikiExecutorSuite |
39 |
|
{ |
40 |
|
@Retention(RetentionPolicy.RUNTIME) |
41 |
|
@Target(ElementType.METHOD) |
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 0 |
Complexity Density: - |
|
42 |
|
public static @interface PostStart |
43 |
|
{ |
44 |
|
} |
45 |
|
|
46 |
|
private PersistentTestContext context; |
47 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
48 |
15 |
public PageObjectSuite(Class< ? > suiteClass, RunnerBuilder builder) throws InitializationError... |
49 |
|
{ |
50 |
15 |
super(suiteClass, builder); |
51 |
|
} |
52 |
|
|
|
|
| 83.3% |
Uncovered Elements: 2 (12) |
Complexity: 3 |
Complexity Density: 0.3 |
|
53 |
15 |
@Override... |
54 |
|
protected void beforeTests() |
55 |
|
{ |
56 |
|
|
57 |
15 |
super.beforeTests(); |
58 |
|
|
59 |
15 |
try { |
60 |
15 |
initializePersistentTestContext(); |
61 |
|
|
62 |
|
|
63 |
15 |
for (Method method : getTestClass().getJavaClass().getMethods()) { |
64 |
146 |
PostStart postStartAnnotation = method.getAnnotation(PostStart.class); |
65 |
146 |
if (postStartAnnotation != null) { |
66 |
|
|
67 |
4 |
Object instance = getTestClass().getJavaClass().newInstance(); |
68 |
4 |
method.invoke(instance, this.context); |
69 |
|
} |
70 |
|
} |
71 |
|
} catch (Exception e) { |
72 |
|
|
73 |
0 |
afterTests(); |
74 |
|
|
75 |
0 |
throw new RuntimeException("Failed to initialize PO suite", e); |
76 |
|
} |
77 |
|
} |
78 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.4 |
|
79 |
15 |
private void initializePersistentTestContext()... |
80 |
|
{ |
81 |
15 |
try { |
82 |
15 |
this.context = new PersistentTestContext(getExecutors()); |
83 |
15 |
AbstractTest.initializeSystem(this.context.getUnstoppable()); |
84 |
|
|
85 |
|
|
86 |
|
|
87 |
|
|
88 |
15 |
AbstractTest.context.getUtil().recacheSecretToken(); |
89 |
|
} catch (Exception e) { |
90 |
0 |
throw new RuntimeException("Failed to initialize PersistentTestContext", e); |
91 |
|
} |
92 |
|
} |
93 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 3 |
Complexity Density: 0.75 |
|
94 |
15 |
@Override... |
95 |
|
protected void afterTests() |
96 |
|
{ |
97 |
15 |
if (context != null) { |
98 |
15 |
try { |
99 |
15 |
context.shutdown(); |
100 |
|
} catch (Exception e) { |
101 |
1 |
throw new RuntimeException("Failed to shutdown PersistentTestContext", e); |
102 |
|
} |
103 |
|
} |
104 |
|
|
105 |
|
|
106 |
|
} |
107 |
|
} |