Search in sources :

Example 1 with DelegateComponentManager

use of org.xwiki.component.internal.multi.DelegateComponentManager in project xwiki-platform by xwiki.

the class DateClassTest method setUp.

@Before
public void setUp() throws Exception {
    DelegateComponentManager contextCM = new DelegateComponentManager();
    contextCM.setComponentManager(mocker);
    mocker.registerComponent(ComponentManager.class, "context", contextCM);
    Utils.setComponentManager(mocker);
    localizationContext = mocker.registerMockComponent(LocalizationContext.class);
}
Also used : LocalizationContext(org.xwiki.localization.LocalizationContext) DelegateComponentManager(org.xwiki.component.internal.multi.DelegateComponentManager) Before(org.junit.Before)

Example 2 with DelegateComponentManager

use of org.xwiki.component.internal.multi.DelegateComponentManager in project xwiki-platform by xwiki.

the class WikiUIExtensionComponentBuilderTest method configure.

@Before
public void configure() throws Exception {
    // Required by BaseObjectReference
    DocumentReferenceResolver<String> resolver = this.mocker.registerMockComponent(DocumentReferenceResolver.TYPE_STRING);
    when(resolver.resolve("XWiki.UIExtension")).thenReturn(new DocumentReference("xwiki", "XWiki", "UIExtensionClass"));
    DelegateComponentManager wikiComponentManager = new DelegateComponentManager();
    wikiComponentManager.setComponentManager(this.mocker);
    this.mocker.registerComponent(ComponentManager.class, "wiki", wikiComponentManager);
    // Components accessed through dynamic lookup.
    VelocityManager velocityManager = this.mocker.registerMockComponent(VelocityManager.class);
    when(velocityManager.getVelocityEngine()).thenReturn(mock(VelocityEngine.class));
    when(velocityManager.getVelocityContext()).thenReturn(mock(VelocityContext.class));
    ModelContext modelContext = this.mocker.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(DOC_REF);
    this.mocker.registerMockComponent(RenderingContext.class);
    this.mocker.registerMockComponent(Transformation.class, "macro");
    this.mocker.registerMockComponent(ContentParser.class);
    // The document holding the UI extension object.
    this.componentDoc = mock(XWikiDocument.class, "xwiki:XWiki.MyUIExtension");
    when(this.componentDoc.getDocumentReference()).thenReturn(DOC_REF);
    when(this.componentDoc.getAuthorReference()).thenReturn(AUTHOR_REFERENCE);
    when(this.componentDoc.getContentAuthorReference()).thenReturn(AUTHOR_REFERENCE);
    when(this.componentDoc.getSyntax()).thenReturn(Syntax.XWIKI_2_1);
    this.oldcore.getDocuments().put(DOC_REF, componentDoc);
}
Also used : ModelContext(org.xwiki.model.ModelContext) VelocityEngine(org.xwiki.velocity.VelocityEngine) XWikiDocument(com.xpn.xwiki.doc.XWikiDocument) VelocityManager(org.xwiki.velocity.VelocityManager) VelocityContext(org.apache.velocity.VelocityContext) DelegateComponentManager(org.xwiki.component.internal.multi.DelegateComponentManager) DocumentReference(org.xwiki.model.reference.DocumentReference) Before(org.junit.Before)

Aggregations

Before (org.junit.Before)2 DelegateComponentManager (org.xwiki.component.internal.multi.DelegateComponentManager)2 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)1 VelocityContext (org.apache.velocity.VelocityContext)1 LocalizationContext (org.xwiki.localization.LocalizationContext)1 ModelContext (org.xwiki.model.ModelContext)1 DocumentReference (org.xwiki.model.reference.DocumentReference)1 VelocityEngine (org.xwiki.velocity.VelocityEngine)1 VelocityManager (org.xwiki.velocity.VelocityManager)1