1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.observation; |
21 |
|
|
22 |
|
import org.junit.Test; |
23 |
|
import org.mockito.Mockito; |
24 |
|
import org.xwiki.observation.event.AllEvent; |
25 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (36) |
Complexity: 5 |
Complexity Density: 0.16 |
|
26 |
|
public class WrappedThreadEventListenerTest |
27 |
|
{ |
28 |
|
private EventListener listenermock = Mockito.mock(EventListener.class); |
29 |
|
|
30 |
|
|
31 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
32 |
1 |
@Test... |
33 |
|
public void testWrapp() |
34 |
|
{ |
35 |
1 |
WrappedThreadEventListener wrapper = new WrappedThreadEventListener(this.listenermock); |
36 |
|
|
37 |
1 |
wrapper.getName(); |
38 |
1 |
Mockito.verify(this.listenermock).getName(); |
39 |
|
|
40 |
1 |
wrapper.getEvents(); |
41 |
1 |
Mockito.verify(this.listenermock).getEvents(); |
42 |
|
} |
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
44 |
1 |
@Test... |
45 |
|
public void testOnEventOnCurrentThread() throws InterruptedException |
46 |
|
{ |
47 |
1 |
final WrappedThreadEventListener wrapper = new WrappedThreadEventListener(this.listenermock); |
48 |
|
|
49 |
1 |
Runnable runnable = new Runnable() |
50 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
51 |
2 |
@Override... |
52 |
|
public void run() |
53 |
|
{ |
54 |
2 |
wrapper.onEvent(AllEvent.ALLEVENT, null, null); |
55 |
|
} |
56 |
|
}; |
57 |
|
|
58 |
1 |
Thread thread = new Thread(runnable); |
59 |
1 |
thread.start(); |
60 |
1 |
thread.join(); |
61 |
1 |
Mockito.verify(this.listenermock, Mockito.times(0)).onEvent(AllEvent.ALLEVENT, null, null); |
62 |
|
|
63 |
1 |
wrapper.onEvent(AllEvent.ALLEVENT, null, null); |
64 |
1 |
Mockito.verify(this.listenermock).onEvent(AllEvent.ALLEVENT, null, null); |
65 |
|
|
66 |
1 |
thread = new Thread(runnable); |
67 |
1 |
thread.start(); |
68 |
1 |
thread.join(); |
69 |
1 |
Mockito.verify(this.listenermock).onEvent(AllEvent.ALLEVENT, null, null); |
70 |
|
} |
71 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
72 |
1 |
@Test... |
73 |
|
public void testOnEventOnPassedThread() throws InterruptedException |
74 |
|
{ |
75 |
1 |
final WrappedThreadEventListener wrapper = |
76 |
|
new WrappedThreadEventListener(this.listenermock, Thread.currentThread()); |
77 |
|
|
78 |
1 |
Runnable runnable = new Runnable() |
79 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
80 |
2 |
@Override... |
81 |
|
public void run() |
82 |
|
{ |
83 |
2 |
wrapper.onEvent(AllEvent.ALLEVENT, null, null); |
84 |
|
} |
85 |
|
}; |
86 |
|
|
87 |
1 |
Thread thread = new Thread(runnable); |
88 |
1 |
thread.start(); |
89 |
1 |
thread.join(); |
90 |
1 |
Mockito.verify(this.listenermock, Mockito.times(0)).onEvent(AllEvent.ALLEVENT, null, null); |
91 |
|
|
92 |
1 |
wrapper.onEvent(AllEvent.ALLEVENT, null, null); |
93 |
1 |
Mockito.verify(this.listenermock).onEvent(AllEvent.ALLEVENT, null, null); |
94 |
|
|
95 |
1 |
thread = new Thread(runnable); |
96 |
1 |
thread.start(); |
97 |
1 |
thread.join(); |
98 |
1 |
Mockito.verify(this.listenermock).onEvent(AllEvent.ALLEVENT, null, null); |
99 |
|
} |
100 |
|
} |