| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
package org.xwiki.rendering.macro.groovy; |
| 21 |
|
|
| 22 |
|
import javax.script.ScriptContext; |
| 23 |
|
import javax.script.SimpleScriptContext; |
| 24 |
|
|
| 25 |
|
import org.jmock.Expectations; |
| 26 |
|
import org.jmock.Mockery; |
| 27 |
|
import org.jmock.integration.junit4.JUnit4Mockery; |
| 28 |
|
import org.junit.runner.RunWith; |
| 29 |
|
import org.xwiki.rendering.macro.script.ScriptMockSetup; |
| 30 |
|
import org.xwiki.rendering.test.integration.RenderingTestSuite; |
| 31 |
|
import org.xwiki.script.ScriptContextManager; |
| 32 |
|
import org.xwiki.script.service.ScriptServiceManager; |
| 33 |
|
import org.xwiki.test.jmock.MockingComponentManager; |
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
@link |
| 38 |
|
|
| 39 |
|
@version |
| 40 |
|
@since |
| 41 |
|
|
| 42 |
|
@RunWith(RenderingTestSuite.class) |
| 43 |
|
@RenderingTestSuite.Scope(pattern = "macrogroovy.*") |
| |
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 2 |
Complexity Density: 0.22 |
|
| 44 |
|
public class IntegrationTests |
| 45 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
|
| 46 |
6 |
@RenderingTestSuite.Initialized... |
| 47 |
|
public void initialize(MockingComponentManager componentManager) throws Exception |
| 48 |
|
{ |
| 49 |
6 |
Mockery mockery = new JUnit4Mockery(); |
| 50 |
|
|
| 51 |
6 |
new ScriptMockSetup(mockery, componentManager); |
| 52 |
|
|
| 53 |
|
|
| 54 |
6 |
final ScriptContextManager scm = componentManager.registerMockComponent(mockery, ScriptContextManager.class); |
| 55 |
6 |
final SimpleScriptContext scriptContext = new SimpleScriptContext(); |
| 56 |
6 |
scriptContext.setAttribute("var", "value", ScriptContext.ENGINE_SCOPE); |
| 57 |
6 |
scriptContext.setAttribute("services", componentManager.getInstance(ScriptServiceManager.class), |
| 58 |
|
ScriptContext.ENGINE_SCOPE); |
| 59 |
|
|
| 60 |
6 |
mockery.checking(new Expectations() |
| 61 |
|
{ |
| |
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
| 62 |
6 |
{... |
| 63 |
6 |
allowing(scm).getScriptContext(); |
| 64 |
6 |
will(returnValue(scriptContext)); |
| 65 |
|
} |
| 66 |
|
}); |
| 67 |
|
} |
| 68 |
|
} |