| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.context.concurrent; |
| 21 |
|
|
| 22 |
|
import org.junit.Test; |
| 23 |
|
import org.mockito.Mockito; |
| 24 |
|
import org.xwiki.component.manager.ComponentLookupException; |
| 25 |
|
import org.xwiki.component.manager.ComponentManager; |
| 26 |
|
import org.xwiki.context.Execution; |
| 27 |
|
import org.xwiki.context.ExecutionContext; |
| 28 |
|
import org.xwiki.context.ExecutionContextException; |
| 29 |
|
import org.xwiki.context.ExecutionContextManager; |
| 30 |
|
|
| 31 |
|
import static org.mockito.ArgumentMatchers.any; |
| 32 |
|
|
| 33 |
|
|
| 34 |
|
@link |
| 35 |
|
|
| 36 |
|
@version |
| 37 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0.08 |
|
| 38 |
|
public class ExecutionContextRunnableTest |
| 39 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0.08 |
1PASS
|
|
| 40 |
1 |
@Test... |
| 41 |
|
public void initializedExecutionContext() throws InterruptedException, ComponentLookupException, |
| 42 |
|
ExecutionContextException |
| 43 |
|
{ |
| 44 |
1 |
ComponentManager componentMangerMock = Mockito.mock(ComponentManager.class); |
| 45 |
1 |
ExecutionContextManager executionContextManagerMock = Mockito.mock(ExecutionContextManager.class); |
| 46 |
1 |
Execution executionMock = Mockito.mock(Execution.class); |
| 47 |
|
|
| 48 |
1 |
Mockito.when(componentMangerMock.getInstance(ExecutionContextManager.class)).thenReturn( |
| 49 |
|
executionContextManagerMock); |
| 50 |
1 |
Mockito.when(componentMangerMock.getInstance(Execution.class)).thenReturn(executionMock); |
| 51 |
|
|
| 52 |
1 |
Runnable runnableMock = Mockito.mock(Runnable.class); |
| 53 |
|
|
| 54 |
1 |
Thread thread = new Thread(new ExecutionContextRunnable(runnableMock, componentMangerMock)); |
| 55 |
|
|
| 56 |
1 |
thread.start(); |
| 57 |
|
|
| 58 |
1 |
thread.join(10000); |
| 59 |
|
|
| 60 |
1 |
Mockito.verify(executionContextManagerMock).initialize(any(ExecutionContext.class)); |
| 61 |
1 |
Mockito.verify(executionMock).removeContext(); |
| 62 |
1 |
Mockito.verify(runnableMock).run(); |
| 63 |
|
} |
| 64 |
|
} |