Search in sources :

Example 1 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class ExceptionTestCase method exceptionCausedBy.

@Test
public void exceptionCausedBy() throws Exception {
    CoreEvent event = createEvent();
    Message message = event.getMessage();
    MessagingException me = new MessagingException(CoreMessages.createStaticMessage(""), InternalEvent.builder(context).message(message).build(), new IllegalAccessException());
    when(mockError.getCause()).thenReturn(me);
    assertTrue((Boolean) evaluate("exception.causedBy(java.lang.IllegalAccessException)", event));
}
Also used : Message(org.mule.runtime.api.message.Message) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) MessagingException(org.mule.runtime.core.internal.exception.MessagingException) Test(org.junit.Test)

Example 2 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class MessagePropertiesTestCase method inboundKeySet.

@Test
public void inboundKeySet() throws Exception {
    Message message = event.getMessage();
    mock(DataHandler.class);
    event = CoreEvent.builder(event).message(InternalMessage.builder(message).addInboundProperty("foo", "abc").addInboundProperty("bar", "xyz").build()).build();
    assertThat((Iterable<String>) evaluate("message.inboundProperties.keySet()", event), hasItems("foo", "bar"));
}
Also used : Message(org.mule.runtime.api.message.Message) InternalMessage(org.mule.runtime.core.internal.message.InternalMessage) Test(org.junit.Test)

Example 3 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method localVariable.

@Test
public void localVariable() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).build();
    assertEquals("bar", evaluate("localVar='bar';localVar", event));
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Example 4 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method variableFromSessionScope.

@Test
public void variableFromSessionScope() throws Exception {
    Message message = of("");
    PrivilegedEvent event = (PrivilegedEvent) InternalEvent.builder(context).message(message).build();
    event.getSession().setProperty("foo", "bar");
    assertEquals(event.getSession().getProperty("foo"), evaluate("foo", event));
}
Also used : PrivilegedEvent(org.mule.runtime.core.privileged.event.PrivilegedEvent) Message(org.mule.runtime.api.message.Message) Test(org.junit.Test)

Example 5 with Message

use of org.mule.runtime.api.message.Message in project mule by mulesoft.

the class VariablesTestCase method updateVariableFromFlowScope.

@Test
public void updateVariableFromFlowScope() throws Exception {
    Message message = of("");
    CoreEvent event = InternalEvent.builder(context).message(message).addVariable("foo", "bar").build();
    assertEquals("bar_new", evaluate("foo='bar_new'", event));
}
Also used : Message(org.mule.runtime.api.message.Message) CoreEvent(org.mule.runtime.core.api.event.CoreEvent) Test(org.junit.Test)

Aggregations

Message (org.mule.runtime.api.message.Message)226 Test (org.junit.Test)189 CoreEvent (org.mule.runtime.core.api.event.CoreEvent)104 SmallTest (org.mule.tck.size.SmallTest)68 InternalMessage (org.mule.runtime.core.internal.message.InternalMessage)46 Transformer (org.mule.runtime.core.api.transformer.Transformer)35 DataType (org.mule.runtime.api.metadata.DataType)33 ArrayList (java.util.ArrayList)26 PrivilegedEvent (org.mule.runtime.core.privileged.event.PrivilegedEvent)26 Processor (org.mule.runtime.core.api.processor.Processor)25 List (java.util.List)20 Assert.assertThat (org.junit.Assert.assertThat)19 ExpectedException (org.junit.rules.ExpectedException)19 MuleContextUtils.eventBuilder (org.mule.tck.util.MuleContextUtils.eventBuilder)19 Map (java.util.Map)18 Rule (org.junit.Rule)18 MockConverterBuilder (org.mule.runtime.core.internal.transformer.builder.MockConverterBuilder)18 ExpectedException.none (org.junit.rules.ExpectedException.none)17 MockTransformerBuilder (org.mule.runtime.core.internal.transformer.builder.MockTransformerBuilder)17 TypedValue (org.mule.runtime.api.metadata.TypedValue)16