assertEquals("", num, attachmentsMsg.size());
final Resource r = resolver.getResource(getResourcePath(msg, store));
assertNotNull("Expecting non-null Resource", r);
for (Resource aRes : r.getChildren()) {
final ModifiableValueMap aMap = aRes.adaptTo(ModifiableValueMap.class);
BodyPart aMsg = attachmentsMsg.poll();
assertNotNull("JCR contains more attachments", aMsg);
for (Field f : aMsg.getHeader().getFields()) {
String name = f.getName();
assertEquals("Field "+name+" is different", (aMap.get(name, String.class)), f.getBody());
}
if (aMsg.getBody() instanceof TextBody) {
assertEquals("Content is not the same", MessageStoreImpl.getTextPart(aMsg), aMap.get(CONTENT, String.class));
} else if (aMsg.getBody() instanceof BinaryBody) {
assertEquals("Content is not the same", getBinPart(aMsg), aMap.get(CONTENT, String.class));
} else {
fail("Unknown type of attachment body");
}
}
assertEquals("Message contains more attachments", attachmentsMsg.poll(), null);