@Test(expected = UnsupportedOperationException.class) public void testOutboundPropertyNamesImmutable() throws Exception { Message message = createMuleMessage(); ((InternalMessage) message).getOutboundPropertyNames().add("other"); }
@Test public void inboundAttachmentsRespectOrder() { InternalMessage message = InternalMessage.builder() .payload(TypedValue.of("test")) .mediaType(TEXT) .inboundAttachments(getAttachments()) .exceptionPayload(new DefaultExceptionPayload(new NullPointerException("error"))) .build(); validateAttachments(message.getInboundAttachmentNames()); }
@Test public void addingInboundAttachmentsRespectOrder() { InternalMessage message = InternalMessage.builder() .payload(TypedValue.of("test")) .mediaType(TEXT) .addInboundAttachment("another", new DataHandler(new ByteArrayDataSource("no".getBytes(), TEXT, "another"))) .addInboundAttachment("field1", new DataHandler(new ByteArrayDataSource("yes".getBytes(), TEXT, "field1"))) .exceptionPayload(new DefaultExceptionPayload(new NullPointerException("error"))) .build(); validateAttachments(message.getInboundAttachmentNames()); }
@Test public void testMessagePropertiesAccessors() { Map<String, Serializable> properties = createMessageProperties();
@Test public void addingOutboundAttachmentsRespectOrder() { InternalMessage message = InternalMessage.builder() .payload(TypedValue.of("test")) .mediaType(TEXT) .addOutboundAttachment("another", new DataHandler(new ByteArrayDataSource("no".getBytes(), TEXT, "another"))) .addOutboundAttachment("field1", new DataHandler(new ByteArrayDataSource("yes".getBytes(), TEXT, "field1"))) .exceptionPayload(new DefaultExceptionPayload(new NullPointerException("error"))) .build(); validateAttachments(message.getOutboundAttachmentNames()); }
@Test public void testMessagePropertiesAccessors() { Map<String, Serializable> properties = createMessageProperties();
@Test(expected = UnsupportedOperationException.class) public void testPropertyNamesImmutable() throws Exception { InternalMessage message = (InternalMessage) createMuleMessage(); message.getOutboundPropertyNames().add("other"); }
@Test public void outboundAttachmentsRespectOrder() { InternalMessage message = InternalMessage.builder() .payload(TypedValue.of("test")) .mediaType(TEXT) .outboundAttachments(getAttachments()) .exceptionPayload(new DefaultExceptionPayload(new NullPointerException("error"))) .build(); validateAttachments(message.getOutboundAttachmentNames()); }
@Test(expected = UnsupportedOperationException.class) public void testInboundPropertyNamesAddImmutable() throws Exception { InternalMessage message = (InternalMessage) createMuleMessage(); message.getOutboundPropertyNames().add("other"); }
@Test public void usesNullPayloadAsNull() throws Exception { Message message = InternalMessage.builder(createMuleMessage()).addOutboundProperty(FOO_PROPERTY, null).build(); assertThat(((InternalMessage) message).getOutboundProperty(FOO_PROPERTY), is(nullValue())); }
@Test public void testClearProperties() { InternalMessage payload = InternalMessage.builder(createMuleMessage()).addOutboundProperty(FOO_PROPERTY, "fooValue").build(); assertThat(payload.getOutboundPropertyNames(), hasSize(2)); assertThat(payload.getInboundPropertyNames(), empty()); payload = InternalMessage.builder(payload).outboundProperties(emptyMap()).build(); assertThat(payload.getOutboundPropertyNames(), empty()); // See http://www.mulesoft.org/jira/browse/MULE-4968 for additional test needed here }
@Test(expected = UnsupportedOperationException.class) public void testOutboundPropertyNamesImmutable() throws Exception { Message message = createMuleMessage(); ((InternalMessage) message).getOutboundPropertyNames().add("other"); }
@Test(expected = UnsupportedOperationException.class) public void testInboundPropertyNamesAddImmutable() throws Exception { InternalMessage message = (InternalMessage) createMuleMessage(); message.getOutboundPropertyNames().add("other"); }
@Test(expected = UnsupportedOperationException.class) public void testPropertyNamesImmutable() throws Exception { InternalMessage message = (InternalMessage) createMuleMessage(); message.getOutboundPropertyNames().add("other"); }
@Test public void usesNullPayloadAsNull() throws Exception { Message message = InternalMessage.builder(createMuleMessage()).addOutboundProperty(FOO_PROPERTY, null).build(); assertThat(((InternalMessage) message).getOutboundProperty(FOO_PROPERTY), is(nullValue())); }
@Test public void testClearProperties() { InternalMessage payload = InternalMessage.builder(createMuleMessage()).addOutboundProperty(FOO_PROPERTY, "fooValue").build(); assertThat(payload.getOutboundPropertyNames(), hasSize(2)); assertThat(payload.getInboundPropertyNames(), empty()); payload = InternalMessage.builder(payload).outboundProperties(emptyMap()).build(); assertThat(payload.getOutboundPropertyNames(), empty()); // See http://www.mulesoft.org/jira/browse/MULE-4968 for additional test needed here }