01: // Copyright © 2006-2007 ASERT. Released under the Canoo Webtest license.
02: package com.canoo.webtest.plugins.emailtest;
03:
04: import java.io.IOException;
05:
06: import javax.mail.Message;
07: import javax.mail.MessagingException;
08: import javax.mail.Multipart;
09:
10: import org.apache.log4j.Logger;
11:
12: /**
13: * Stores a string representing the message type.
14: *
15: * @author Paul King, ASERT
16: * @webtest.step category="Email"
17: * name="emailStoreMessageType"
18: * description="Stores a string representing the message type, either '<em>Simple</em>' or '<em>MultiPart</em>'."
19: */
20: public class EmailStoreMessageType extends AbstractMessageStoreStep {
21: private static final Logger LOG = Logger
22: .getLogger(EmailStoreMessageType.class);
23:
24: /**
25: * Perform the operation.
26: *
27: * @param message
28: */
29: protected String performOperation(final Message message)
30: throws MessagingException {
31: try {
32: final Object content = message.getContent();
33: if (content instanceof Multipart) {
34: return "MultiPart";
35: } else {
36: return "Simple";
37: }
38: } catch (IOException e) {
39: LOG.error("Error processing email message: ", e);
40: throw new MessagingException(
41: "Error processing email message: " + e.getMessage());
42: }
43: }
44: }
|