use of org.xwiki.properties.BeanManager in project xwiki-platform by xwiki.
the class DashboardMacroTest method executeWhenInsideDashboardMacro.
@Test
public void executeWhenInsideDashboardMacro() throws Exception {
BeanManager beanManager = this.mocker.getInstance(BeanManager.class);
BeanDescriptor descriptor = mock(BeanDescriptor.class);
when(beanManager.getBeanDescriptor(any())).thenReturn(descriptor);
when(descriptor.getProperties()).thenReturn(Collections.emptyList());
Execution execution = this.mocker.getInstance(Execution.class);
ExecutionContext ec = new ExecutionContext();
when(execution.getContext()).thenReturn(ec);
ec.setProperty("dashboardMacroCalls", 1);
DashboardMacroParameters parameters = new DashboardMacroParameters();
MacroTransformationContext macroContext = new MacroTransformationContext();
try {
this.mocker.getComponentUnderTest().execute(parameters, "", macroContext);
fail("Exception should have been raised here");
} catch (MacroExecutionException expected) {
assertEquals("Dashboard macro recursion detected. Don't call the Dashboard macro inside of itself...", expected.getMessage());
}
}
use of org.xwiki.properties.BeanManager in project xwiki-platform by xwiki.
the class DashboardMacroTest method executeWhenNotInsideDashboardMacro.
@Test
public void executeWhenNotInsideDashboardMacro() throws Exception {
BeanManager beanManager = this.mocker.getInstance(BeanManager.class);
BeanDescriptor descriptor = mock(BeanDescriptor.class);
when(beanManager.getBeanDescriptor(any())).thenReturn(descriptor);
when(descriptor.getProperties()).thenReturn(Collections.emptyList());
DashboardRenderer renderer = this.mocker.registerMockComponent(DashboardRenderer.class, "columns");
GadgetRenderer gadgetRenderer = this.mocker.registerMockComponent(GadgetRenderer.class);
Execution execution = this.mocker.getInstance(Execution.class);
ExecutionContext ec = new ExecutionContext();
when(execution.getContext()).thenReturn(ec);
DashboardMacroParameters parameters = new DashboardMacroParameters();
MacroTransformationContext macroContext = new MacroTransformationContext();
this.mocker.getComponentUnderTest().execute(parameters, "", macroContext);
// We verify that the counter ends up at 0 so that calls to subsequent dashboard macros can succeed.
assertEquals(0, ec.getProperty("dashboardMacroCalls"));
}
use of org.xwiki.properties.BeanManager in project xwiki-platform by xwiki.
the class SignableMacroTest method setUp.
@Before
public void setUp() throws Exception {
BeanManager beanManager = mocker.getInstance(BeanManager.class);
when(beanManager.getBeanDescriptor(Object.class)).thenReturn(new DefaultBeanDescriptor(Object.class));
store = mocker.registerMockComponent(SignatureStore.class);
when(store.retrieve(BLOCK_REFERENCE)).thenReturn(SIGNATURE);
BlockSignatureGenerator signer = mocker.registerMockComponent(BlockSignatureGenerator.class, "macro");
when(signer.generate(BLOCK, PARAMETERS)).thenReturn(SIGNATURE);
BlockSignatureVerifier verifier = mocker.registerMockComponent(BlockSignatureVerifier.class, "macro");
when(verifier.verify(SIGNATURE, BLOCK, null)).thenReturn(VERIFIED);
BlockReferenceResolver<Block> resolver = mocker.registerMockComponent(new DefaultParameterizedType(null, BlockReferenceResolver.class, Block.class), "currentsignedmacro");
when(resolver.resolve(BLOCK)).thenReturn(BLOCK_REFERENCE);
macro = mocker.getComponentUnderTest();
}
use of org.xwiki.properties.BeanManager in project xwiki-platform by xwiki.
the class ContextMacroTest method setUp.
@Before
public void setUp() throws Exception {
// Macro Descriptor set up
BeanManager beanManager = this.mocker.getInstance(BeanManager.class);
BeanDescriptor descriptor = mock(BeanDescriptor.class);
when(descriptor.getProperties()).thenReturn(Collections.emptyList());
when(beanManager.getBeanDescriptor(any())).thenReturn(descriptor);
}
use of org.xwiki.properties.BeanManager in project xwiki-platform by xwiki.
the class VelocityMacroSecurityTest method setUp.
@Before
public void setUp() throws Exception {
authorizationManager = mocker.registerMockComponent(ContextualAuthorizationManager.class);
BeanDescriptor mockBeanDescriptor = mock(BeanDescriptor.class);
when(mockBeanDescriptor.getProperties()).thenReturn(Collections.EMPTY_LIST);
BeanManager beanManager = mocker.getInstance(BeanManager.class);
when(beanManager.getBeanDescriptor(any(Class.class))).thenReturn(mockBeanDescriptor);
Macro velocityMacro = mocker.getComponentUnderTest();
MacroManager mockMacroManager = mocker.registerMockComponent(MacroManager.class);
when(mockMacroManager.getMacro(any(MacroId.class))).thenReturn(velocityMacro);
}
Aggregations