Search in sources :

Example 31 with ActionExecutingEvent

use of org.xwiki.bridge.event.ActionExecutingEvent in project xwiki-platform by xwiki.

the class ActionExecutingEventTest method testDoesntEqualDifferentAction.

@Test
public void testDoesntEqualDifferentAction() {
    ActionExecutingEvent event = new ActionExecutingEvent("something");
    Assert.assertFalse("A different action was equal!", event.equals(new ActionExecutingEvent("else")));
}
Also used : ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 32 with ActionExecutingEvent

use of org.xwiki.bridge.event.ActionExecutingEvent in project xwiki-platform by xwiki.

the class ActionExecutingEventTest method testDoesntMatchWildcardAction.

@Test
public void testDoesntMatchWildcardAction() {
    ActionExecutingEvent event = new ActionExecutingEvent("something");
    Assert.assertFalse("Wildcard action was matched!", event.matches(new ActionExecutingEvent()));
}
Also used : ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 33 with ActionExecutingEvent

use of org.xwiki.bridge.event.ActionExecutingEvent in project xwiki-platform by xwiki.

the class ActionExecutingEventTest method testEmptyActionDoesntMatch.

@Test
public void testEmptyActionDoesntMatch() {
    ActionExecutingEvent event = new ActionExecutingEvent("something");
    Assert.assertFalse("Empty action behaves as wildcard!", new ActionExecutingEvent("").matches(event));
}
Also used : ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Example 34 with ActionExecutingEvent

use of org.xwiki.bridge.event.ActionExecutingEvent in project xwiki-platform by xwiki.

the class XWikiHibernateStoreTest method testLocksAreReleasedOnLogout.

@Test
public void testLocksAreReleasedOnLogout() throws Exception {
    // Capture the event listener.
    ObservationManager observationManager = getMocker().getInstance(ObservationManager.class);
    ArgumentCaptor<EventListener> eventListenerCaptor = ArgumentCaptor.forClass(EventListener.class);
    verify(observationManager).addListener(eventListenerCaptor.capture());
    assertEquals("deleteLocksOnLogoutListener", eventListenerCaptor.getValue().getName());
    Query query = mock(Query.class);
    when(session.createQuery("delete from XWikiLock as lock where lock.userName=:userName")).thenReturn(query);
    when(xcontext.getUserReference()).thenReturn(new DocumentReference("xwiki", "XWiki", "LoggerOutter"));
    when(xcontext.getUser()).thenReturn("XWiki.LoggerOutter");
    // Fire the logout event.
    eventListenerCaptor.getValue().onEvent(new ActionExecutingEvent("logout"), null, xcontext);
    verify(query).setString("userName", "XWiki.LoggerOutter");
    verify(query).executeUpdate();
    verify(this.hibernateStore).beginTransaction();
    verify(this.hibernateStore).endTransaction(true);
}
Also used : SQLQuery(org.hibernate.SQLQuery) Query(org.hibernate.Query) ObservationManager(org.xwiki.observation.ObservationManager) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) EventListener(org.xwiki.observation.EventListener) DocumentReference(org.xwiki.model.reference.DocumentReference) Test(org.junit.Test)

Example 35 with ActionExecutingEvent

use of org.xwiki.bridge.event.ActionExecutingEvent in project xwiki-platform by xwiki.

the class LESSExportActionListenerTest method onEventWhenHTMLExport.

@Test
public void onEventWhenHTMLExport() throws Exception {
    XWikiContext xcontext = mock(XWikiContext.class);
    XWikiRequest request = mock(XWikiRequest.class);
    when(xcontext.getRequest()).thenReturn(request);
    when(request.get("format")).thenReturn("html");
    this.mocker.getComponentUnderTest().onEvent(new ActionExecutingEvent("export"), null, xcontext);
    // The test is here: we verify that the cache is disabled!
    LESSContext lessContext = mocker.getInstance(LESSContext.class);
    verify(lessContext).setHtmlExport(true);
}
Also used : XWikiRequest(com.xpn.xwiki.web.XWikiRequest) LESSContext(org.xwiki.lesscss.internal.LESSContext) XWikiContext(com.xpn.xwiki.XWikiContext) ActionExecutingEvent(org.xwiki.bridge.event.ActionExecutingEvent) Test(org.junit.Test)

Aggregations

ActionExecutingEvent (org.xwiki.bridge.event.ActionExecutingEvent)37 Test (org.junit.Test)32 ActionExecutedEvent (org.xwiki.bridge.event.ActionExecutedEvent)9 XWikiContext (com.xpn.xwiki.XWikiContext)5 XWikiDocument (com.xpn.xwiki.doc.XWikiDocument)3 XWikiException (com.xpn.xwiki.XWikiException)2 XWikiRequest (com.xpn.xwiki.web.XWikiRequest)2 DocumentCreatedEvent (org.xwiki.bridge.event.DocumentCreatedEvent)2 DocumentCreatingEvent (org.xwiki.bridge.event.DocumentCreatingEvent)2 DocumentDeletedEvent (org.xwiki.bridge.event.DocumentDeletedEvent)2 DocumentDeletingEvent (org.xwiki.bridge.event.DocumentDeletingEvent)2 DocumentUpdatedEvent (org.xwiki.bridge.event.DocumentUpdatedEvent)2 DocumentUpdatingEvent (org.xwiki.bridge.event.DocumentUpdatingEvent)2 LESSContext (org.xwiki.lesscss.internal.LESSContext)2 DocumentReference (org.xwiki.model.reference.DocumentReference)2 ObservationManager (org.xwiki.observation.ObservationManager)2 XWiki (com.xpn.xwiki.XWiki)1 MonitorPlugin (com.xpn.xwiki.monitor.api.MonitorPlugin)1 XWikiNotificationManager (com.xpn.xwiki.notify.XWikiNotificationManager)1 FileUploadPlugin (com.xpn.xwiki.plugin.fileupload.FileUploadPlugin)1