MimePartSplitter extends MessageSplitterImp { @Override public List<AdaptrisMessage> splitMessage(AdaptrisMessage msg) throws CoreException { List<AdaptrisMessage> result = new ArrayList<AdaptrisMessage>(); AdaptrisMessageFactory fac = selectFactory(msg); try (BodyPartIterator mp = MimeHelper.createBodyPartIterator(msg)) { while (mp.hasNext()) { AdaptrisMessage splitMsg = fac.newMessage(); MimeBodyPart part = mp.next(); copy(part, splitMsg); copyMetadata(msg, splitMsg); result.add(splitMsg); } } catch (Exception e) { throw new CoreException(e); } logR.trace("Split gave " + result.size() + " messages"); return result; }  @Override List<AdaptrisMessage> splitMessage(AdaptrisMessage msg); Boolean getPreserveHeaders(); void setPreserveHeaders(Boolean b); boolean preserveHeaders(); void setHeaderPrefix(String s); String getHeaderPrefix();  }
@Test public void testSplitMessage() throws Exception { Object obj = "ABCDEFG"; AdaptrisMessage msg = create(); msg.getObjectHeaders().put(obj, obj); MimePartSplitter m = new MimePartSplitter(); List<AdaptrisMessage> result = m.splitMessage(msg); assertEquals(3, result.size()); for (AdaptrisMessage smsg : result) { assertFalse("Should not contain object metadata", smsg.getObjectHeaders().containsKey(obj)); } }
@Test public void testSplitMessageWithObjectMetadata() throws Exception { Object obj = "ABCDEFG"; AdaptrisMessage msg = create(); msg.getObjectHeaders().put(obj, obj); MimePartSplitter m = new MimePartSplitter(); m.setCopyObjectMetadata(true); List<AdaptrisMessage> result = m.splitMessage(msg); assertEquals(3, result.size()); for (AdaptrisMessage smsg : result) { assertTrue("Should contain object metadata", smsg.getObjectHeaders().containsKey(obj)); assertEquals(obj, smsg.getObjectHeaders().get(obj)); } }