Example usage for org.springframework.integration.mail ImapMailReceiver setEmbeddedPartsAsBytes

List of usage examples for org.springframework.integration.mail ImapMailReceiver setEmbeddedPartsAsBytes

Introduction

In this page you can find the example usage for org.springframework.integration.mail ImapMailReceiver setEmbeddedPartsAsBytes.

Prototype

public void setEmbeddedPartsAsBytes(boolean embeddedPartsAsBytes) 

Source Link

Document

When a header mapper is provided determine whether an embedded Part (e.g Message or Multipart content is rendered as a byte[] in the payload.

Usage

From source file:org.springframework.integration.mail.ImapMailReceiverTests.java

@Test
public void testAttachmentsWithMapping() throws Exception {
    final ImapMailReceiver receiver = new ImapMailReceiver("imap://foo");
    receiver.setHeaderMapper(new DefaultMailHeaderMapper());
    receiver.setEmbeddedPartsAsBytes(false);
    testAttachmentsGuts(receiver);//from w  w w  . j a  va2  s .com
    org.springframework.messaging.Message<?>[] messages = (org.springframework.messaging.Message<?>[]) receiver
            .receive();
    Object content = messages[0].getPayload();
    assertThat(content, instanceOf(Multipart.class));
    assertEquals("bar", ((Multipart) content).getBodyPart(0).getContent().toString().trim());
    assertEquals("foo", ((Multipart) content).getBodyPart(1).getContent().toString().trim());
}