use of org.apache.james.mime4j.message.DefaultMessageBuilder in project sling by apache.
the class MessageStoreImplRepositoryTest method assertSaveMessage.
private void assertSaveMessage(String messageFile) throws MimeException, IOException, FileNotFoundException {
MessageBuilder builder = new DefaultMessageBuilder();
Message msg = builder.parseMessage(new FileInputStream(new File(TU.TEST_FOLDER, messageFile)));
store.save(msg);
final Resource r = resolver.getResource(getResourcePath(msg, store));
assertNotNull("Expecting non-null Resource", r);
final ModifiableValueMap m = r.adaptTo(ModifiableValueMap.class);
File bodyFile = new File(TU.TEST_FOLDER, specialPathFromFilePath(messageFile, BODY_SUFFIX));
if (bodyFile.exists()) {
String expectedBody = readTextFile(bodyFile);
assertValueMap(m, "Body", expectedBody);
}
File headersFile = new File(TU.TEST_FOLDER, specialPathFromFilePath(messageFile, HEADERS_SUFFIX));
if (headersFile.exists()) {
MessageStoreImplRepositoryTestUtil.assertHeaders(headersFile, m);
}
// test at least something
assertTrue(headersFile.exists() || bodyFile.exists());
}
Aggregations