use of org.xwiki.bridge.event.ApplicationReadyEvent 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.bridge.event.ApplicationReadyEvent 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.bridge.event.ApplicationReadyEvent in project xwiki-platform by xwiki.
the class DefaultWikiComponentManagerEventListenerTest method onApplicationReady.
@Test
public void onApplicationReady() throws Exception {
mocker.getComponentUnderTest().onEvent(new ApplicationReadyEvent(), null, null);
verify(this.wikiComponentManagerEventListenerHelper, times(1)).registerComponentList(any());
}
use of org.xwiki.bridge.event.ApplicationReadyEvent in project xwiki-platform by xwiki.
the class DefaultWikiComponentManagerEventListenerTest method onDocumentCreatedOrUpdated.
private void onDocumentCreatedOrUpdated(Event event) throws Exception {
DocumentModelBridge componentDocument = mock(DocumentModelBridge.class);
when(componentDocument.getDocumentReference()).thenReturn(DOC_REFERENCE);
/**
* Here, {@link WikiComponentManagerEventListenerHelper#registerComponentList(List)} is called two times
* because we have to "initialize" the tested event listener with an ApplicationReadyEvent() before sending
* our custom event. Therefore, the tested WikiComponent will be registered two times.
*/
mocker.getComponentUnderTest().onEvent(new ApplicationReadyEvent(), null, null);
mocker.getComponentUnderTest().onEvent(event, componentDocument, null);
}
use of org.xwiki.bridge.event.ApplicationReadyEvent in project xwiki-platform by xwiki.
the class UntypedEventListenerTest method onEventWithWrongEvent.
@Test
public void onEventWithWrongEvent() throws Exception {
// Mocks
mockDescriptor();
// Test
mocker.getComponentUnderTest().onEvent(new ApplicationReadyEvent(), mock(Object.class), null);
// Verify
verify(this.observationManager, never()).notify(any(), any(), any());
assertNull(answer.getSentEvent());
}
Aggregations