<?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>Shaaf's Blog &#187; Software Development</title>
	<atom:link href="http://www.shaafshah.com/category/software-development/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.shaafshah.com</link>
	<description>Another bit in the wall</description>
	<lastBuildDate>Wed, 12 Aug 2009 14:28:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Getting started with JBehave in 8 steps.</title>
		<link>http://www.shaafshah.com/2009/08/12/getting-started-with-jbehave-in-8-steps/</link>
		<comments>http://www.shaafshah.com/2009/08/12/getting-started-with-jbehave-in-8-steps/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 14:13:30 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jbehave]]></category>
		<category><![CDATA[unit testing]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=256</guid>
		<description><![CDATA[This post is about JBehave and how to quickly get started with it. If you would like to know about BDD please use the following link. What is Behavioral Driven Development? Today I have used JBehave for the first time. It does have some convincing factors for instance diving requirements into scenarios which map pretty [...]]]></description>
			<content:encoded><![CDATA[<p>This post is about JBehave and how to quickly get started with it. If you would like to know about BDD please use the following link.<br />
<a href="http://en.wikipedia.org/wiki/Behavior_Driven_Development">What is Behavioral Driven Development?</a></p>
<p>Today I have used JBehave for the first time. It does have some convincing factors for instance diving requirements into scenarios which map pretty nicely to the tests that are written with in the Steps. Thus it seems like it would be easier for Stakeholder/s to use it as a good guideline for the initial requirements. Its always quite usual to come up to some disagreements about the development however the tool does help to bring forth the ease for stake holders who really dont have to get into writing code but will have a technical jargon to communicate through to the developers in shape of scenarios.</p>
<p>So the first things come up.<br />
1. Create a Java project in Eclipse.<br />
2. Download the JBehave latest version from the <a href="http://jbehave.org/software/download/">website</a> and add the jar files to your project build classpath<br />
3. Create a scenario file and name it as user_wants_to_shop.scenario</p>
<p>Add the following text to the file</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">Given user Shaaf is logged in
Check <span style="color: #000000; font-weight: bold;">if</span> user shaaf is Allowed to shop
Then show shaaf his shopping cart</pre></td></tr></table></div>

<p>The lines above simply state the rules for the scenario we are about to create.</p>
<p>4. Now we will create a java file mapping to it.</p>
<p>Create a new class with the name corresponding to the same as the .scenario file<br />
UserWantsToShop.java</p>
<p>Add the following code to it</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.PropertyBasedConfiguration</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.Scenario</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.parser.ClasspathScenarioDefiner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.parser.PatternScenarioParser</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.parser.ScenarioDefiner</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.parser.UnderscoredCamelCaseResolver</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> UserWantsToShop <span style="color: #000000; font-weight: bold;">extends</span> Scenario <span style="color: #009900;">&#123;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// The usual constructor with default Configurations.</span>
	<span style="color: #000000; font-weight: bold;">public</span> UserWantsToShop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ShoppingSteps<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// Mapping .scenario files to the scenario. This is not by default.</span>
    <span style="color: #000000; font-weight: bold;">public</span> UserWantsToShop<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">final</span> <span style="color: #003399;">ClassLoader</span> classLoader<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> PropertyBasedConfiguration<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> ScenarioDefiner forDefiningScenarios<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> ClasspathScenarioDefiner<span style="color: #009900;">&#40;</span>
                    <span style="color: #000000; font-weight: bold;">new</span> UnderscoredCamelCaseResolver<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;.scenario&quot;</span><span style="color: #009900;">&#41;</span>, 
                    <span style="color: #000000; font-weight: bold;">new</span> PatternScenarioParser<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>, classLoader<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>, <span style="color: #000000; font-weight: bold;">new</span> ShoppingSteps<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>5. Just that we now have steps we need some place to put the logic for the Steps in the Scenarios. So we create a new Steps class ShoppingSteps.java</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.annotations.Given</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.annotations.Then</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.annotations.When</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">org.jbehave.scenario.steps.Steps</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ShoppingSteps <span style="color: #000000; font-weight: bold;">extends</span> Steps <span style="color: #009900;">&#123;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>6. Now you can run the Scenario by running it as a Junit Test.</p>
<p>Following should be the output</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">Scenario<span style="color: #339933;">:</span> 
&nbsp;
Given I am not logged in <span style="color: #009900;">&#40;</span>PENDING<span style="color: #009900;">&#41;</span>
When I log in as Shaaf with a password JBehaver <span style="color: #009900;">&#40;</span>PENDING<span style="color: #009900;">&#41;</span>
Then I should see my <span style="color: #0000ff;">&quot;Shopping Cart&quot;</span> <span style="color: #009900;">&#40;</span>PENDING<span style="color: #009900;">&#41;</span></pre></td></tr></table></div>

<p>This means that none of the scenario requirements have been implemented as yet. But the test result should be green to show there are no problems with our setup.</p>
<p>Now lets add the implementation to the tests.</p>
<p>7. Add the body to the ShoppingSteps. I have added the comments with the methods.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">        <span style="color: #666666; font-style: italic;">// Given that a user(param) is loggen in</span>
	@Given<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user $username is logged in&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> logIn<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		checkInSession<span style="color: #009900;">&#40;</span>userName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #666666; font-style: italic;">// Check if the user is allowed on the server</span>
	@When<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;if user $username is $permission to shop&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> isUserAllowed<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName, <span style="color: #003399;">String</span> permission<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		getUser<span style="color: #009900;">&#40;</span>userName<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">isUserAllowed</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>permission<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// finally then let him use the shopping cart.</span>
	@Then<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;show $username his Shopping cart&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> getMyCart<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> userName, <span style="color: #003399;">String</span> cart<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		getUserCart<span style="color: #009900;">&#40;</span>userName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>8. Now you should try to run the scenario again. And all of the test should be green. I have not implemented the actual methods so they will be red. <img src='http://www.shaafshah.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2009/08/12/getting-started-with-jbehave-in-8-steps/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Logging with log4J isDebugEnabled</title>
		<link>http://www.shaafshah.com/2009/08/12/logging-with-log4j-isdebugenabled/</link>
		<comments>http://www.shaafshah.com/2009/08/12/logging-with-log4j-isdebugenabled/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 12:39:52 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[Software Development]]></category>
		<category><![CDATA[best practise]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[log4j]]></category>
		<category><![CDATA[logging]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=248</guid>
		<description><![CDATA[Alot of times I have seen the questions popping up whether to use isDebugEnabled property or not. Arguably most of the times or rather always about performance. Some of the stuff that I feel important about using it follows.]]></description>
			<content:encoded><![CDATA[<p>Alot of times I have seen the questions popping up whether to use isDebugEnabled property or not. Arguably most of the times or rather always about performance. Some of the stuff that I feel important about using it follows.</p>
<p>The answer is simple. It is made to be used. However using it has to be with caution.</p>
<p>For instance<br />
If I am using the following line in my code.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I am there&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>Thats an example of a good practise</p>
<p>However I can really blow it out of proportions if I do the following.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Not good practise</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>log.<span style="color: #006633;">isDebugEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I am there&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>And why exactly is that so. This is because the method debug in the class Category i.e. extended by Logger in the log4j libraries explicitly checks the mode for the logging itself.</p>
<p>Extract from the class org.apache.log4j.Category is below</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> debug<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>repository.<span style="color: #006633;">isDisabled</span><span style="color: #009900;">&#40;</span>Level.<span style="color: #006633;">DEBUG_INT</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>Level.<span style="color: #006633;">DEBUG</span>.<span style="color: #006633;">isGreaterOrEqual</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">getEffectiveLevel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
forcedLog<span style="color: #009900;">&#40;</span>FQCN, Level.<span style="color: #006633;">DEBUG</span>, message, <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Okay so thats the case where we say dont use it. What about the one where we actually do use the isDebugEnabled property.</p>
<p>For instance you have a large parameter going in the debug.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Bad Practise</span>
 log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;XML &quot;</span><span style="color: #339933;">+</span>Tree.<span style="color: #006633;">getXMLText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>In such a case it can clearly be said &#8220;No dont do it!&#8221; If Tree.getXMLText is going to pull out all the hair out of the app then there is no use. As it will be constructed first and if the debug level is not enabled that would be a performance cost.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Good Practise</span>
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>log.<span style="color: #006633;">isDebugEnabled</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;XML &quot;</span><span style="color: #339933;">+</span>Tree.<span style="color: #006633;">getXMLText</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>Thus in the example above it would be wiser to use log.isDebugEnabled() just to make sure the mileage or cost stays lesser. </p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2009/08/12/logging-with-log4j-isdebugenabled/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Automation with Selenium,Junit, Ant</title>
		<link>http://www.shaafshah.com/2009/01/19/automation-with-seleniumjunit-ant/</link>
		<comments>http://www.shaafshah.com/2009/01/19/automation-with-seleniumjunit-ant/#comments</comments>
		<pubDate>Mon, 19 Jan 2009 14:31:52 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[automated-testing]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[CI]]></category>
		<category><![CDATA[continous]]></category>
		<category><![CDATA[engineering]]></category>
		<category><![CDATA[integration]]></category>
		<category><![CDATA[Junit]]></category>
		<category><![CDATA[scm]]></category>
		<category><![CDATA[selenium]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[testing]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=159</guid>
		<description><![CDATA[What is Selenium How does Selenium work History and how it started About Ant And Junit Much of the technologies above do not or will not need an introduction if you already know them or can read them from the links above. More over today&#8217;s article is more about how we can use all the [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://seleniumhq.org/">What is Selenium</a><br />
<a href="http://seleniumhq.org/about/how.html">How does Selenium work</a><br />
<a href="http://seleniumhq.org/about/history.html">History and how it started</a><br />
<a href="http://ant.apache.org/">About Ant</a><br />
<a href="http://www.junit.org/">And Junit</a></p>
<p>Much of the technologies above do not or will not need an introduction if you already know them or can read them from the links above.</p>
<p>More over today&#8217;s article is more about how we can use all the three selenium, ant and junit to come up with an automated solution for regressive testing.</p>
<p>Please refer to the documentation links above for the basic knowledge on any of the used tools.</p>
<p>I am assuming that you know how to record a test in selenium if you dont then go <a href="http://selenium-ide.seleniumhq.org/">here</a></p>
<p>Now that you do know how to record and save the tests simply save them in any directory structure you like as long as they follow the right package convention. like com.foo.bar<br />
this would mean the file should be in directory like com/foo/bar. Conventionally and logically today that is how the TestCase is compiled through the ant script. If the package is not the right path then compile time errors will occur.</p>
<p>My calling target for running the whole procedure should look like this</p>
<pre>
< target name="build_tests" depends="clean, compile, start-server,  tests, stop-server" / >
</pre>
<p>Details of the depending targets are as follows.<br />
<strong>clean:</strong> would clean the entire build directories etc to make sure nothing from our past is carried forward into the future.</p>
<p><strong>compile:</strong> should compile</p>
<p><strong>start-server:</strong> should start the selenium server.</p>
<p><strong>tests:</strong> should run the selenium tests.</p>
<p><strong>stop-server:</strong> should stop the selenium server once all tests have been executed.</p>
<p><strong>How to start a selenium server from Ant?</strong></p>
<pre>
    < target name="start-server" >
        < java jar="lib/selenium-server.jar" fork="true" spawn="true" >
            < arg line="-timeout 30" / >
            < jvmarg value="-Dhttp.proxyHost=proxy.proxyhost.com" / >
            < jvmarg value="-Dhttp.proxyPort=44444" / >
        < / java >
    < / target >
</pre>
<p> </p>
<p>The target above is simply taking the selenium-server.jar which is in the classpath and running the main-class from it. the proxy parameters are optional.</p>
<p><strong>How to stop the server from Ant?</strong></p>
<pre>
 < target name="stop-server" >
        < get taskname="selenium-shutdown"
            src="http://localhost:4444/selenium-server/driver/?cmd=shutDown"
            dest="result.txt" ignoreerrors="true" / >
        < echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" / >
    < / target >
 </pre>
<p>The selenium server starts on port 4444 by default and to tell it to shutdown is simple, the command in the src is passed to it. cmd=shutDown<br />
That should just shutdown the server.</p>
<p><strong>Executing the test cases?</strong><br />
Selenium Test cases are Junit tests cases and that&#8217;s how they are treated in this tutorial.<br />
Thus some of you will be very much familiar with the ant targets <a href="http://ant.apache.org/manual/OptionalTasks/junit.html">junit</a> and <a href="http://ant.apache.org/manual/OptionalTasks/junitreport.html">junitreport</a>. However I will describe how the following is working.<br />
the following target will run the selenium tests and print a summary report to the ${dir}<br />
The includes and excludes, simply tell the target which files to include or exclude while running the test cases. This is typically done when you don&#8217;t want some tests cases to be included or your source for tests and the application are in the same directory and you only want to include something like Test*.class. </p>
<pre>
  < target name="tests" depends="compileonly" description="runs JUnit tests" >
    < echo message="running JUnit tests" / >
    < junit printsummary="on" dir=".." haltonfailure="off" haltonerror="off" timeout="${junit.timeout}" fork="on" maxmemory="512m" showoutput="true" >
      < formatter type="plain" usefile="false" / >
      < formatter type="xml" usefile="true" / >
      < batchtest todir="${testoutput}" filtertrace="on" >
        < fileset dir="${src}" >
          < includesfile name="${tests.include}" / >
          < excludesfile name="${tests.exclude}" / >
        < / fileset >
      < / batchtest >
      < classpath >
        < pathelement path="${classes}" / >
        < pathelement path="${build.classpath}" / >
      < / classpath >
    < / junit >
</pre>
<p>The following will take the formatted output from the lines above and generate a report out of it in xml and html and place the results in the ${reports}/index.html<br />
A sample Junit test report might look like <a href="http://studios.thoughtworks.com/cruise-continuous-integration/1.0/help/resources/images/cruise/tab-with-junit.png">this</a>.</p>
<pre>
   < echo message="running JUnit Reports" / >
   < junitreport todir="${reports}" >
      < fileset dir="${reportdir}" >
        < include name="Test*.xml" / >
      < / fileset >
      < report format="frames" todir="${reports}" / >
    < / junitreport >
    < echo message="To see your Junit results, please open ${reports}/index.html}" / >
  < / target >
</pre>
<p>In general you can add all of this to your nightly build through any of the CI servers like Cruise Control. Also as a general practice you will need to do a  little more then just executing this target every night depending on your application. For instance cleaning up of resource centers like Databases etc.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2009/01/19/automation-with-seleniumjunit-ant/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Calling wsadmin scripts from ant</title>
		<link>http://www.shaafshah.com/2008/12/11/calling-wsadmin-scripts-from-ant/</link>
		<comments>http://www.shaafshah.com/2008/12/11/calling-wsadmin-scripts-from-ant/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 08:17:46 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Administrator]]></category>
		<category><![CDATA[ant]]></category>
		<category><![CDATA[IBM]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jdbc]]></category>
		<category><![CDATA[jython]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[sysadmin]]></category>
		<category><![CDATA[websphere]]></category>
		<category><![CDATA[wsadmin]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=148</guid>
		<description><![CDATA[You can simply add the following to a target. For the following wsadmin should be in your PATH env. < exec dir="." executable="wsadmin.bat" logError="true" failonerror="true" output="wsconfig.out" > < arg line="-lang jython -f ../../createQFactory.py"/ > < /exec > All output will be logged to wsconfig.out]]></description>
			<content:encoded><![CDATA[<p>You can simply add the following to a target.<br />
For the following wsadmin should be in your PATH env.</p>
<p>< exec dir="." executable="wsadmin.bat" logError="true" failonerror="true" output="wsconfig.out" ><br />
   < arg line="-lang jython -f ../../createQFactory.py"/ ><br />
< /exec ></p>
<p>All output will be logged to wsconfig.out</p>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/12/11/calling-wsadmin-scripts-from-ant/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Generate XML &#8211; DBMS_XMLGEN</title>
		<link>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/</link>
		<comments>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 14:58:04 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[DBMS_XMLGEN]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[tips]]></category>
		<category><![CDATA[utils]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=137</guid>
		<description><![CDATA[On my way to my solution store just found this nice to use, old and easy feature. Possibilities endless, usage typically very easy. I used the following to generate XML from sqlplus: select dbms_xmlgen.getxml('select * from user') from dual; Output: < ROWSET > < ROW > < TNAME >Employee< / TNAME > < TABTYPE > [...]]]></description>
			<content:encoded><![CDATA[<p>On my way to my solution store just found this nice to use, old and easy feature.<br />
Possibilities endless, usage typically very easy.</p>
<p>I used the following to generate XML from sqlplus:</p>
<pre lang="SQL" line=1> select dbms_xmlgen.getxml('select * from user') from dual; </pre>
<p><strong>Output:</strong></p>
<pre lang="XML" line=1>
< ROWSET >
 < ROW >
  < TNAME >Employee< / TNAME >
  < TABTYPE > TABLE < / TABTYPE >
 < / ROW >
< / ROWSET >
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.shaafshah.com/2008/12/10/generate-xml-dbms_xmlgen/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Command, Singleton, JMenuItem, JButton, AbstractButton &#8211; One Listener for the app</title>
		<link>http://www.shaafshah.com/2008/11/17/command-singleton-jmenuitem-jbutton-abstractbutton-one-listener-for-the-app/</link>
		<comments>http://www.shaafshah.com/2008/11/17/command-singleton-jmenuitem-jbutton-abstractbutton-one-listener-for-the-app/#comments</comments>
		<pubDate>Mon, 17 Nov 2008 19:17:24 +0000</pubDate>
		<dc:creator>Shaaf Shah</dc:creator>
				<category><![CDATA[HOWTO]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[AbstractButton]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[Computers]]></category>
		<category><![CDATA[Design]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[GOF]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JButton]]></category>
		<category><![CDATA[JMenuItem]]></category>
		<category><![CDATA[Patterns]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Singleton]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://www.shaafshah.com/?p=124</guid>
		<description><![CDATA[