Search in sources :

Example 1 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class EditorWikiComponent method initialize.

private void initialize(BaseObject editorObject) throws WikiComponentException {
    this.descriptorBuilder.setId(editorObject.getStringValue("roleHint"));
    this.descriptorBuilder.setIcon(editorObject.getStringValue("icon"));
    this.descriptorBuilder.setCategory(editorObject.getStringValue("category"));
    this.scope = WikiComponentScope.fromString(editorObject.getStringValue("scope"));
    String dataTypeName = editorObject.getStringValue("dataType");
    try {
        Type dataType = ReflectionUtils.unserializeType(dataTypeName, Thread.currentThread().getContextClassLoader());
        this.roleType = new DefaultParameterizedType(null, Editor.class, dataType);
    } catch (ClassNotFoundException e) {
        throw new WikiComponentException(String.format("The [%s] data type does not exist.", dataTypeName), e);
    }
}
Also used : DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Type(java.lang.reflect.Type) WikiComponentException(org.xwiki.component.wiki.WikiComponentException) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Editor(org.xwiki.edit.Editor) AbstractEditor(org.xwiki.edit.AbstractEditor)

Example 2 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class AuthenticatingIntegrationTest method initialize.

@Before
public void initialize() throws Exception {
    // Create a user in the SMTP server.
    this.mail.setUser("peter@doe.com", "peter", "password");
    this.defaultBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class));
    this.sender = this.componentManager.getInstance(MailSender.class);
    // Simulate receiving the Application Ready Event to start the mail threads
    MailSenderInitializerListener listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
    listener.onEvent(new ApplicationReadyEvent(), null, null);
}
Also used : ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) MailSender(org.xwiki.mail.MailSender) DefaultMailSender(org.xwiki.mail.internal.DefaultMailSender) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) MailSenderInitializerListener(org.xwiki.mail.internal.thread.MailSenderInitializerListener) Before(org.junit.Before)

Example 3 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class JavaIntegrationTest method initialize.

@Before
public void initialize() throws Exception {
    this.defaultBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class));
    this.htmlBodyPartFactory = this.componentManager.getInstance(new DefaultParameterizedType(null, MimeBodyPartFactory.class, String.class), "text/html");
    this.sender = this.componentManager.getInstance(MailSender.class);
    // Set the EC
    Execution execution = this.componentManager.getInstance(Execution.class);
    ExecutionContext executionContext = new ExecutionContext();
    XWikiContext xContext = new XWikiContext();
    xContext.setWikiId("wiki");
    executionContext.setProperty(XWikiContext.EXECUTIONCONTEXT_KEY, xContext);
    when(execution.getContext()).thenReturn(executionContext);
    Copier<ExecutionContext> executionContextCloner = this.componentManager.getInstance(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    // Just return the same execution context
    when(executionContextCloner.copy(executionContext)).thenReturn(executionContext);
    // Simulate receiving the Application Ready Event to start the mail threads
    MailSenderInitializerListener listener = this.componentManager.getInstance(EventListener.class, MailSenderInitializerListener.LISTENER_NAME);
    listener.onEvent(new ApplicationReadyEvent(), null, null);
}
Also used : Execution(org.xwiki.context.Execution) ExecutionContext(org.xwiki.context.ExecutionContext) Copier(org.xwiki.mail.internal.thread.context.Copier) ApplicationReadyEvent(org.xwiki.bridge.event.ApplicationReadyEvent) XWikiContext(com.xpn.xwiki.XWikiContext) MailSender(org.xwiki.mail.MailSender) DefaultMailSender(org.xwiki.mail.internal.DefaultMailSender) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) MailSenderInitializerListener(org.xwiki.mail.internal.thread.MailSenderInitializerListener) Before(org.junit.Before)

Example 4 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class JavaIntegrationTest method registerConfiguration.

@BeforeComponent
public void registerConfiguration() throws Exception {
    this.configuration = new TestMailSenderConfiguration(this.mail.getSmtp().getPort(), null, null, new Properties());
    this.componentManager.registerComponent(MailSenderConfiguration.class, this.configuration);
    // Set the current wiki in the Context
    ModelContext modelContext = this.componentManager.registerMockComponent(ModelContext.class);
    when(modelContext.getCurrentEntityReference()).thenReturn(new WikiReference("wiki"));
    XWikiContext xcontext = mock(XWikiContext.class);
    when(xcontext.getWikiId()).thenReturn("wiki");
    Provider<XWikiContext> xwikiContextProvider = this.componentManager.registerMockComponent(XWikiContext.TYPE_PROVIDER);
    when(xwikiContextProvider.get()).thenReturn(xcontext);
    this.componentManager.registerMockComponent(ExecutionContextManager.class);
    this.componentManager.registerMockComponent(Execution.class);
    this.componentManager.registerMockComponent(new DefaultParameterizedType(null, Copier.class, ExecutionContext.class));
    EnvironmentConfiguration environmentConfiguration = this.componentManager.registerMockComponent(EnvironmentConfiguration.class);
    when(environmentConfiguration.getPermanentDirectoryPath()).thenReturn(System.getProperty("java.io.tmpdir"));
}
Also used : ModelContext(org.xwiki.model.ModelContext) ExecutionContext(org.xwiki.context.ExecutionContext) EnvironmentConfiguration(org.xwiki.environment.internal.EnvironmentConfiguration) Copier(org.xwiki.mail.internal.thread.context.Copier) XWikiContext(com.xpn.xwiki.XWikiContext) Properties(java.util.Properties) WikiReference(org.xwiki.model.reference.WikiReference) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) BeforeComponent(org.xwiki.test.annotation.BeforeComponent)

Example 5 with DefaultParameterizedType

use of org.xwiki.component.util.DefaultParameterizedType in project xwiki-platform by xwiki.

the class XWikiEventTypesEnablerTest method setUp.

@Before
public void setUp() throws Exception {
    notificationPreferenceManager = mocker.getInstance(NotificationPreferenceManager.class);
    documentAccessBridge = mocker.getInstance(DocumentAccessBridge.class);
    targetableNotificationPreferenceBuilderProvider = mock(Provider.class);
    when(targetableNotificationPreferenceBuilderProvider.get()).thenReturn(new DefaultTargetableNotificationPreferenceBuilder());
    mocker.registerComponent(new DefaultParameterizedType(null, Provider.class, TargetableNotificationPreferenceBuilder.class), targetableNotificationPreferenceBuilderProvider);
    when(documentAccessBridge.getCurrentUserReference()).thenReturn(currentUser);
}
Also used : NotificationPreferenceManager(org.xwiki.notifications.preferences.NotificationPreferenceManager) TargetableNotificationPreferenceBuilder(org.xwiki.notifications.preferences.TargetableNotificationPreferenceBuilder) DocumentAccessBridge(org.xwiki.bridge.DocumentAccessBridge) DefaultParameterizedType(org.xwiki.component.util.DefaultParameterizedType) Provider(javax.inject.Provider) Before(org.junit.Before)

Aggregations

DefaultParameterizedType (org.xwiki.component.util.DefaultParameterizedType)104 Test (org.junit.Test)44 Before (org.junit.Before)32 Provider (javax.inject.Provider)27 DocumentReference (org.xwiki.model.reference.DocumentReference)24 XWikiContext (com.xpn.xwiki.XWikiContext)19 ComponentManager (org.xwiki.component.manager.ComponentManager)19 ExecutionContext (org.xwiki.context.ExecutionContext)17 ExtendedURL (org.xwiki.url.ExtendedURL)15 Execution (org.xwiki.context.Execution)14 HashMap (java.util.HashMap)13 DocumentAccessBridge (org.xwiki.bridge.DocumentAccessBridge)13 ComponentLookupException (org.xwiki.component.manager.ComponentLookupException)12 ResourceReferenceSerializer (org.xwiki.resource.ResourceReferenceSerializer)10 VfsResourceReference (org.xwiki.vfs.VfsResourceReference)10 Properties (java.util.Properties)9 MimeBodyPartFactory (org.xwiki.mail.MimeBodyPartFactory)9 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)8 XWiki (com.xpn.xwiki.XWiki)7 File (java.io.File)7