use of org.xwiki.skinx.SkinExtension in project xwiki-platform by xwiki.
the class IntegrationTest method initialize.
@RenderingTestSuite.Initialized
@SuppressWarnings("unchecked")
public void initialize(final MockingComponentManager componentManager) throws Exception {
Mockery mockery = new JUnit4Mockery();
// Since we have a dependency on XWiki Platform Oldcore the Context Component Manager will be found and the
// test will try to look up the Dashboard macro in the User and Wiki Component Manager and thus need a Current
// User and a Current Wiki. It's easier for this test to simply unregister the Context Component Manager rather
// than have to provide mocks for them.
componentManager.unregisterComponent(ComponentManager.class, "context");
final SkinExtension mockSsfx = componentManager.registerMockComponent(mockery, SkinExtension.class, "ssfx", "ssfxMock");
final SkinExtension mockJsfx = componentManager.registerMockComponent(mockery, SkinExtension.class, "jsfx", "jsfxMock");
mockery.checking(new Expectations() {
{
allowing(mockSsfx).use(with("uicomponents/container/columns.css"), with(any(Map.class)));
allowing(mockSsfx).use(with("uicomponents/dashboard/dashboard.css"), with(any(Map.class)));
allowing(mockJsfx).use(with("js/scriptaculous/dragdrop.js"));
allowing(mockJsfx).use(with("js/scriptaculous/effects.js"));
allowing(mockJsfx).use(with("uicomponents/dashboard/dashboard.js"), with(any(Map.class)));
}
});
final GadgetSource mockGadgetSource = componentManager.registerMockComponent(mockery, GadgetSource.class);
mockery.checking(new Expectations() {
{
// Mock gadget for macrodashboard_nested_velocity.test
allowing(mockGadgetSource).getGadgets(with("nested_velocity"), with(any(MacroTransformationContext.class)));
will(returnValue(Arrays.asList(new Gadget("0", Arrays.asList(new WordBlock("title")), Arrays.asList(new MacroMarkerBlock("velocity", Collections.emptyMap(), "someVelocityCodeHere", Collections.singletonList(new WordBlock("someVelocityOutputHere")), true)), "1,1"))));
// Mock gadget for macrodashboard1.test
allowing(mockGadgetSource).getGadgets(with(aNull(String.class)), with(any(MacroTransformationContext.class)));
will(returnValue(Arrays.asList(new Gadget("0", Arrays.<Block>asList(new WordBlock("title")), Arrays.<Block>asList(new WordBlock("content")), "1,1"))));
allowing(mockGadgetSource).getDashboardSourceMetadata(with(AnyOf.anyOf(aNull(String.class), any(String.class))), with(any(MacroTransformationContext.class)));
will(returnValue(Collections.<Block>emptyList()));
allowing(mockGadgetSource).isEditing();
// return true on is editing, to take as many paths possible
will(returnValue(true));
}
});
// Mock VelocityManager used in macrodashboard_nested_velocity.test because we do not have an XWikiContext
// instance in the ExecutionContext.
final VelocityManager mockVelocityManager = componentManager.registerMockComponentWithId(mockery, VelocityManager.class, "velocityManagerMock");
mockery.checking(new Expectations() {
{
allowing(mockVelocityManager).getVelocityContext();
will(returnValue(new VelocityContext()));
allowing(mockVelocityManager).getCurrentVelocityContext();
will(returnValue(new VelocityContext()));
allowing(mockVelocityManager).getVelocityEngine();
will(doAll(new CustomAction("mockGetVelocityEngine") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
VelocityEngine velocityEngine = componentManager.getInstance(VelocityEngine.class);
Properties properties = new Properties();
properties.setProperty("resource.loader", "file");
velocityEngine.initialize(properties);
return velocityEngine;
}
}));
allowing(mockVelocityManager).evaluate(with(any(Writer.class)), with(any(String.class)), with(any(Reader.class)));
will(doAll(new CustomAction("mockEvaluate") {
@Override
public Object invoke(Invocation invocation) throws Throwable {
VelocityEngine velocityEngine = mockVelocityManager.getVelocityEngine();
return velocityEngine.evaluate(mockVelocityManager.getVelocityContext(), (Writer) invocation.getParameter(0), (String) invocation.getParameter(1), (Reader) invocation.getParameter(2));
}
}));
}
});
componentManager.registerMockComponent(mockery, ContextualAuthorizationManager.class);
}
use of org.xwiki.skinx.SkinExtension in project xwiki-platform by xwiki.
the class IntegrationTests method initialize.
@RenderingTestSuite.Initialized
public void initialize(MockingComponentManager componentManager) throws Exception {
Mockery mockery = new JUnit4Mockery();
final SkinExtension ssfxMock = componentManager.registerMockComponent(mockery, SkinExtension.class, "ssfx");
mockery.checking(new Expectations() {
{
String cssPath = "uicomponents/container/columns.css";
allowing(ssfxMock).use(with(cssPath));
allowing(ssfxMock).use(with(cssPath), with(any(Map.class)));
}
});
}
use of org.xwiki.skinx.SkinExtension in project xwiki-platform by xwiki.
the class IntegrationTests method initialize.
@RenderingTestSuite.Initialized
public void initialize(MockingComponentManager componentManager) throws Exception {
Mockery mockery = new JUnit4Mockery();
final SkinExtension jsfx = componentManager.registerMockComponent(mockery, SkinExtension.class, "jsfx", "jsfx");
final SkinExtension ssfx = componentManager.registerMockComponent(mockery, SkinExtension.class, "ssfx", "ssfx");
mockery.checking(new Expectations() {
{
allowing(jsfx).use(with(aNonNull(String.class)), with(aNonNull(Map.class)));
allowing(ssfx).use(with(aNonNull(String.class)));
}
});
}
Aggregations