<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>romenov.com &#187; confirmation url</title>
	<atom:link href="http://blog.romenov.com/tag/confirmation-url/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.romenov.com</link>
	<description></description>
	<lastBuildDate>Fri, 16 Jul 2010 23:04:42 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Read mails through JMeter</title>
		<link>http://blog.romenov.com/read-mails-through-jmeter</link>
		<comments>http://blog.romenov.com/read-mails-through-jmeter#comments</comments>
		<pubDate>Tue, 21 Jul 2009 15:33:46 +0000</pubDate>
		<dc:creator>Valerie</dc:creator>
				<category><![CDATA[jmeter]]></category>
		<category><![CDATA[Beanshell postprocessor]]></category>
		<category><![CDATA[confirmation url]]></category>
		<category><![CDATA[Mail reader sampler]]></category>

		<guid isPermaLink="false">http://blog.romenov.com/?p=3</guid>
		<description><![CDATA[JMeter is a free java-based tool that can be used for monitoring.
In my case I needed to check the activation URL in a confirmation mail.
To read mails JMeter uses the Mail Reader Sampler. Before you can use this sampler you need to place the Java Mail.jar in the JMeter lib directory.
But the Mail Reader Sampler [...]]]></description>
			<content:encoded><![CDATA[<p>JMeter is a free java-based tool that can be used for monitoring.<br />
In my case I needed to check the activation URL in a confirmation mail.<br />
To read mails JMeter uses the Mail Reader Sampler. Before you can use this sampler you need to place the Java Mail.jar in the JMeter lib directory.<br />
But the Mail Reader Sampler treats all the mails as subsamples, and most post processors cannot use them.</p>
<p><span id="more-3"></span><br />
So, to get the activation URL I used a BeanShell PostProcessor. If you use BeanShell you need to place bsh-2.0b4.jar in the JMeter lib directory.<br />
The URL I needed to check was from the following format: https://www.[domain].be/Action.do?URL=[Activation Code]"<br />
I only needed the Activation Code. This is the BeanShell PostProcessor code I used:</p>
<pre><code>import org.apache.jmeter.samplers.SampleResult;

counter = 1;
temp=null;
newVal = "INVALID";

//get all mails
results = prev.getSubResults();
	for(SampleResult result: results) {
		mail = result.getResponseDataAsString();
                //check sender and subject
		if(mail.contains("From: [Sender]") &amp;&amp; mail.contains("Subject: [Subject]")) {
                        //get URL
			temp = mail.split("URL=");
			temp = temp[1].split(”\”&gt;”);
			newVal = temp[0];
		}
        //put url in JMeter variable
	vars.put("activationCode", newVal);
	counter++;
	}
</code></pre>
<p>The Activation code is now in the JMeter variable: $[activationCode] which can be accessed from Samplers, Pre &amp; Post-Processors,...<br />
To access this variable, you need to define it in JMeters User Defined Variables first. Otherwise JMeter doesn't know about it existence.</p>
<p>I used a split to get the activation code out of the URL, you could also use a regex which would be something like this: .*URL=([^"]*).*</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.romenov.com/read-mails-through-jmeter/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
