Search in sources :

Example 6 with MuleSession

use of org.mule.runtime.core.privileged.event.MuleSession in project mule by mulesoft.

the class DefaultInterceptionEventTestCase method updateSession.

@Test
public void updateSession() throws MuleException {
    final InternalEvent event = this.<InternalEvent.Builder>getEventBuilder().message(of(TEST_PAYLOAD)).build();
    final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
    final MuleSession session = ((PrivilegedEvent) event).getSession();
    session.setProperty("myKey", "myValue");
    interceptionEvent.session(session);
    assertThat(((PrivilegedEvent) interceptionEvent.resolve()).getSession().getProperty("myKey"), is("myValue"));
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) DefaultInterceptionEvent(org.mule.runtime.core.internal.interception.DefaultInterceptionEvent) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) InternalEvent(org.mule.runtime.core.internal.message.InternalEvent) Test(org.junit.Test)

Example 7 with MuleSession

use of org.mule.runtime.core.privileged.event.MuleSession in project mule by mulesoft.

the class EventGroup method getMergedSession.

protected MuleSession getMergedSession(PrivilegedEvent[] events) throws ObjectStoreException {
    MuleSession session = new DefaultMuleSession(events[0].getSession());
    for (int i = 1; i < events.length - 1; i++) {
        addAndOverrideSessionProperties(session, events[i]);
    }
    addAndOverrideSessionProperties(session, events[events.length - 1]);
    return session;
}
Also used : DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession)

Example 8 with MuleSession

use of org.mule.runtime.core.privileged.event.MuleSession in project mule by mulesoft.

the class SplitterTestCase method testEmptySequence.

/**
 * Tests that an empty sequence can be routed properly
 */
@Test
public void testEmptySequence() throws Exception {
    Object payload = Collections.emptySet();
    MuleSession session = new DefaultMuleSession();
    Message toSplit = Message.of(payload);
    Splitter splitter = new Splitter();
    splitter.setMuleContext(muleContext);
    splitter.initialise();
    CoreEvent event = this.<PrivilegedEvent.Builder>getEventBuilder().message(toSplit).session(session).build();
    assertSame(event, splitter.process(event));
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Message(org.mule.runtime.api.message.Message) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) DefaultMuleSession(org.mule.runtime.core.privileged.event.DefaultMuleSession) Test(org.junit.Test)

Example 9 with MuleSession

use of org.mule.runtime.core.privileged.event.MuleSession in project mule by mulesoft.

the class DefaultInterceptionEventTestCase method addSession.

@Test
public void addSession() throws MuleException {
    final InternalEvent event = this.<InternalEvent.Builder>getEventBuilder().message(of(TEST_PAYLOAD)).build();
    final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
    final MuleSession session = mock(MuleSession.class);
    interceptionEvent.session(session);
    assertThat(((PrivilegedEvent) interceptionEvent.resolve()).getSession(), sameInstance(session));
}
Also used : DefaultInterceptionEvent(org.mule.runtime.core.internal.interception.DefaultInterceptionEvent) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) InternalEvent(org.mule.runtime.core.internal.message.InternalEvent) Test(org.junit.Test)

Example 10 with MuleSession

use of org.mule.runtime.core.privileged.event.MuleSession in project mule by mulesoft.

the class DefaultInterceptionEventTestCase method changeSession.

@Test
public void changeSession() throws MuleException {
    final InternalEvent event = this.<InternalEvent.Builder>getEventBuilder().message(of(TEST_PAYLOAD)).session(mock(MuleSession.class)).build();
    final DefaultInterceptionEvent interceptionEvent = new DefaultInterceptionEvent(event);
    final MuleSession session = mock(MuleSession.class);
    interceptionEvent.session(session);
    assertThat(((PrivilegedEvent) interceptionEvent.resolve()).getSession(), sameInstance(session));
}
Also used : DefaultInterceptionEvent(org.mule.runtime.core.internal.interception.DefaultInterceptionEvent) MuleSession(org.mule.runtime.core.privileged.event.MuleSession) InternalEvent(org.mule.runtime.core.internal.message.InternalEvent) Test(org.junit.Test)

Aggregations

MuleSession (org.mule.runtime.core.privileged.event.MuleSession)13 Test (org.junit.Test)11 DefaultMuleSession (org.mule.runtime.core.privileged.event.DefaultMuleSession)9 Message (org.mule.runtime.api.message.Message)7 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)7 EventContext (org.mule.runtime.api.event.EventContext)4 Flow (org.mule.runtime.core.api.construct.Flow)4 InternalEvent (org.mule.runtime.core.internal.message.InternalEvent)4 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)4 MuleTestUtils.createAndRegisterFlow (org.mule.tck.MuleTestUtils.createAndRegisterFlow)4 DefaultInterceptionEvent (org.mule.runtime.core.internal.interception.DefaultInterceptionEvent)3 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)3 ArrayList (java.util.ArrayList)2 MuleTestUtils.createFlow (org.mule.tck.MuleTestUtils.createFlow)2 Serializable (java.io.Serializable)1 Collections.singletonList (java.util.Collections.singletonList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Map (java.util.Map)1