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);
}
}
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);
}
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);
}
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"));
}
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);
}
Aggregations