Search in sources :

Example 6 with ScriptMockSetup

use of org.xwiki.rendering.macro.script.ScriptMockSetup in project xwiki-platform by xwiki.

the class CacheMacroTest method registerComponents.

@Override
protected void registerComponents() throws Exception {
    super.registerComponents();
    this.mockSetup = new ScriptMockSetup(getMockery(), getComponentManager());
    this.cacheMacro = getComponentManager().getInstance(Macro.class, "cache");
    this.rendererFactory = getComponentManager().getInstance(PrintRendererFactory.class, "event/1.0");
}
Also used : ScriptMockSetup(org.xwiki.rendering.macro.script.ScriptMockSetup) Macro(org.xwiki.rendering.macro.Macro) PrintRendererFactory(org.xwiki.rendering.renderer.PrintRendererFactory)

Example 7 with ScriptMockSetup

use of org.xwiki.rendering.macro.script.ScriptMockSetup in project xwiki-platform by xwiki.

the class IntegrationTests method initialize.

@RenderingTestSuite.Initialized
public void initialize(MockingComponentManager componentManager) throws Exception {
    Mockery mockery = new JUnit4Mockery();
    new ScriptMockSetup(mockery, componentManager);
    // Script Context Mock
    final ScriptContextManager scm = componentManager.registerMockComponent(mockery, ScriptContextManager.class);
    final SimpleScriptContext scriptContext = new SimpleScriptContext();
    scriptContext.setAttribute("var", "value", ScriptContext.ENGINE_SCOPE);
    scriptContext.setAttribute("services", componentManager.getInstance(ScriptServiceManager.class), ScriptContext.ENGINE_SCOPE);
    mockery.checking(new Expectations() {

        {
            allowing(scm).getScriptContext();
            will(returnValue(scriptContext));
        }
    });
}
Also used : Expectations(org.jmock.Expectations) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) ScriptMockSetup(org.xwiki.rendering.macro.script.ScriptMockSetup) SimpleScriptContext(javax.script.SimpleScriptContext) ScriptServiceManager(org.xwiki.script.service.ScriptServiceManager) ScriptContextManager(org.xwiki.script.ScriptContextManager) JUnit4Mockery(org.jmock.integration.junit4.JUnit4Mockery) Mockery(org.jmock.Mockery)

Aggregations

ScriptMockSetup (org.xwiki.rendering.macro.script.ScriptMockSetup)7 Expectations (org.jmock.Expectations)3 Macro (org.xwiki.rendering.macro.Macro)3 PrintRendererFactory (org.xwiki.rendering.renderer.PrintRendererFactory)3 ScriptContextManager (org.xwiki.script.ScriptContextManager)3 SimpleScriptContext (javax.script.SimpleScriptContext)2 Mockery (org.jmock.Mockery)2 JUnit4Mockery (org.jmock.integration.junit4.JUnit4Mockery)2 AuthorizationManager (org.xwiki.security.authorization.AuthorizationManager)2 Before (org.junit.Before)1 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)1 Execution (org.xwiki.context.Execution)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 SpaceReference (org.xwiki.model.reference.SpaceReference)1 WikiReference (org.xwiki.model.reference.WikiReference)1 MacroBlock (org.xwiki.rendering.block.MacroBlock)1 IncludeMacro (org.xwiki.rendering.internal.macro.include.IncludeMacro)1 WikiMacroManager (org.xwiki.rendering.macro.wikibridge.WikiMacroManager)1 WikiMacroVisibility (org.xwiki.rendering.macro.wikibridge.WikiMacroVisibility)1 MacroTransformationContext (org.xwiki.rendering.transformation.MacroTransformationContext)1