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