ASF Bugzilla – Attachment 25968 Details for
Bug 49862
Improve the output of the SMTPSampler
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
Patch to for a nicer presentation of the request on SMTPSampler
clipboard.txt (text/plain), 4.79 KB, created by
Luciana Moreira
on 2010-09-02 07:15:09 UTC
(
hide
)
Description:
Patch to for a nicer presentation of the request on SMTPSampler
Filename:
MIME Type:
Creator:
Luciana Moreira
Created:
2010-09-02 07:15:09 UTC
Size:
4.79 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P jmeterSVN >Index: src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java >=================================================================== >--- src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (revision 991618) >+++ src/protocol/mail/org/apache/jmeter/protocol/smtp/sampler/SmtpSampler.java (working copy) >@@ -23,11 +23,15 @@ > import java.io.InputStream; > import java.util.ArrayList; > import java.util.Date; >+import java.util.Enumeration; > import java.util.List; > > import javax.mail.AuthenticationFailedException; >+import javax.mail.BodyPart; >+import javax.mail.Header; > import javax.mail.Message; > import javax.mail.MessagingException; >+import javax.mail.Multipart; > import javax.mail.internet.AddressException; > import javax.mail.internet.InternetAddress; > >@@ -206,11 +210,8 @@ > try { > instance.execute(message); > >- // Set up the sample result details >- res.setSamplerData( >- "To: " + receiverTo >- + "\nCC: " + receiverCC >- + "\nBCC: " + receiverBcc); >+ // Set up the sample result details >+ res.setSamplerData(getSamplerData(message)); > res.setDataType(SampleResult.TEXT); > res.setResponseCodeOK(); > /* >@@ -282,7 +283,104 @@ > return res; > } > >- /** >+ private String getSamplerData(Message message) throws MessagingException, IOException { >+ StringBuffer sb = new StringBuffer(); >+ >+ sb.append("------------ Message Headers ------------\n"); >+ Enumeration headers = message.getAllHeaders(); >+ writeHeaders(headers, sb); >+ String from = InternetAddress.toString(message.getFrom()); >+ if (from != null) { >+ sb.append("From: "); >+ sb.append(from); >+ sb.append("\n"); >+ } >+ >+ String replyTo = InternetAddress.toString(message.getReplyTo()); >+ if (replyTo != null) { >+ sb.append("Reply-to: "); >+ sb.append(replyTo); >+ sb.append("\n"); >+ } >+ String to = InternetAddress.toString(message.getRecipients(Message.RecipientType.TO)); >+ if (to != null) { >+ sb.append("To: "); >+ sb.append(to); >+ sb.append("\n"); >+ } >+ >+ String subject = message.getSubject(); >+ if (subject != null) { >+ sb.append("Subject: "); >+ sb.append(subject); >+ sb.append("\n"); >+ } >+ sb.append("\n------------ Message Content ------------\n"); >+ Object content = message.getContent(); >+ if (content instanceof Multipart) { >+ Multipart multipart = (Multipart) content; >+ sb.append("Content-Type: "); >+ sb.append(multipart.getContentType()); >+ sb.append("\n"); >+ for (int i = 0; i < multipart.getCount(); i++) { >+ BodyPart bodyPart = multipart.getBodyPart(i); >+ writeBodyPart(sb, bodyPart); >+ } >+ } else if(content instanceof BodyPart){ >+ BodyPart bodyPart = (BodyPart) content; >+ writeBodyPart(sb, bodyPart); >+ } >+ return sb.toString(); >+ } >+ >+ private void writeHeaders(Enumeration<Header> headers, StringBuffer sb) >+ throws MessagingException { >+ while (headers.hasMoreElements()) { >+ Header header = headers.nextElement(); >+ if("From".equals(header.getName()) >+ || "Reply-to".equals(header.getName()) >+ || "To".equals(header.getName()) >+ || "Subject".equals(header.getName()) >+ || "Content-Type".equals(header.getName())){ >+ continue; >+ } >+ sb.append(header.getName()); >+ sb.append(": "); >+ sb.append(header.getValue()); >+ sb.append("\n"); >+ } >+ } >+ >+ private void writeBodyPart(StringBuffer sb, BodyPart bodyPart) >+ throws MessagingException, IOException { >+ writeHeaders(bodyPart.getAllHeaders(), sb); >+ sb.append("ContentType = "); >+ sb.append(bodyPart.getContentType()); >+ sb.append("\n"); >+ String description = bodyPart.getDescription(); >+ if(description != null){ >+ sb.append("Description = "); >+ sb.append(description); >+ sb.append("\n"); >+ } >+ >+ String disposition = bodyPart.getDisposition(); >+ >+ if (disposition != null && (disposition.equals(BodyPart.ATTACHMENT))) { >+ sb.append("\n Attachment - "); >+ sb.append("Disposition = "); >+ sb.append(disposition); >+ sb.append("; FileName = "); >+ sb.append(bodyPart.getFileName()); >+ sb.append("; FileSize = "); >+ sb.append(bodyPart.getSize()); >+ } else { >+ sb.append("\n"); >+ sb.append(bodyPart.getContent()); >+ } >+ } >+ >+ /** > * Get the list of addresses or null. > * Null is treated differently from an empty list. > * @param propValue addresses separated by ";"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 49862
: 25968