<?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>Xebia Blog &#187; Saket Vishal</title>
	<atom:link href="http://blog.xebia.com/author/saket_vishal/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.xebia.com</link>
	<description>Software development done right!</description>
	<lastBuildDate>Wed, 01 Feb 2012 00:30:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>JEE to PHPEE</title>
		<link>http://blog.xebia.com/2008/12/22/jee-to-phpee/</link>
		<comments>http://blog.xebia.com/2008/12/22/jee-to-phpee/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 07:38:50 +0000</pubDate>
		<dc:creator>Saket Vishal</dc:creator>
		<br />
<b>Warning</b>:  Invalid argument supplied for foreach() in <b>/home/blog.xebia.com/www/wp-content/plugins/autometa/autometa.php</b> on line <b>303</b><br />
		<category><![CDATA[Testing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[TDD]]></category>

	<!-- AutoMeta Start -->
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/?p=849</guid>
		<description><![CDATA[PHP is becoming better day by day. As I proceed in my path of catching up with recent developments in PHP, I see more and more of adaption in PHP from JEE(Java Enterprise Edition) world. To begin with, I stumbled upon the unit testing framework PHPUnit. The amount of familiarity with the J2EE world is [...]]]></description>
			<content:encoded><![CDATA[<p>PHP is becoming better day by day. As I proceed in my path of catching up with recent developments in PHP, I see more and more of adaption in PHP from JEE(Java Enterprise Edition) world. To begin with, I stumbled upon the unit testing framework <a href="http://www.phpunit.de/">PHPUnit</a>. The amount of familiarity with the J2EE world is simply amazing.<br />
<span id="more-849"></span></p>
<p>Following table highlights this on various aspects of PHPUnit.<br />
<a href='http://blog.xebia.com/wp-content/uploads/2008/12/diagram.gif'><img src="http://blog.xebia.com/wp-content/uploads/2008/12/diagram.gif" title="comparison" class="aligncenter size-medium wp-image-851" /></a></p>
<p>PHPUnit belongs to xUnit family, same as that of the jUnit. PHPUnit not only provides various functions to assert values but also allows many complex operations possible through annotations. PHPUnit provides a lot of extensions, such as for database testing, performance testing. The Database testing extension provided by PHPUnit is very similar to that of what is provided by <a href="http://dbunit.sourceforge.net/">Dbunit</a>. Both follow similar approaches of seeding the database initially, and then after code execution ensuring that expected data is found in the database. If one has some experience with mocking frameworks in Java such as <a href="http://www.easymock.org/">EasyMock</a>, then working with mock testing with PHPUnit would be a cakewalk. The comfort of migration extends to the level of acceptance testing, when one uses <a href="http://seleniumhq.org/">Selenium</a> with PHPUnit.</p>
<p>PHPUnit is one of the many available testing frameworks in PHP world, and testing is one of the many areas where I see commonality between the two worlds(J2EE and PHP). The major reason of the commonality has come because of the inclusion of the best practices in the PHP world and also adapting helpful frameworks from the J2EE world. As I proceed further on my path ahead, I would be sharing my learning with you all. </p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2008/12/22/jee-to-phpee/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2008%2F12%2F22%2Fjee-to-phpee%2F&amp;title=JEE%20to%20PHPEE" id="wpa2a_2"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2008/12/22/jee-to-phpee/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Sharpen up your DbUnit testing</title>
		<link>http://blog.xebia.com/2007/09/21/sharpen-up-your-dbunit-testing/</link>
		<comments>http://blog.xebia.com/2007/09/21/sharpen-up-your-dbunit-testing/#comments</comments>
		<pubDate>Fri, 21 Sep 2007 09:08:04 +0000</pubDate>
		<dc:creator>Saket Vishal</dc:creator>
				<category><![CDATA[Java]]></category>

	<!-- AutoMeta Start -->
	<category>dataset</category>
	<category>tablenames</category>
	<category>expecteddataset</category>
	<category>expectedtables</category>
	<category>dbunit</category>
	<category>filename</category>
	<category>actualdataset</category>
	<category>flatxmldataset</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/2007/09/21/sharpen-up-your-dbunit-testing/</guid>
		<description><![CDATA[DbUnit is a JUnit extension and is very popular among developers for unit testing database-driven projects. In this blog I will discuss some of the tips to make your life easier and beautiful for DbUnit testing. Using same connection for entire test suite If you are extending DatabaseTestCase then this class creates a connection to [...]]]></description>
			<content:encoded><![CDATA[<p>DbUnit is a JUnit extension and is very popular among developers for unit testing database-driven projects. In this blog I will discuss some of the tips to make your life easier and beautiful for DbUnit testing.<br />
<span id="more-288"></span></p>
<p><strong>Using same connection for entire test suite</strong><br />
If you are extending DatabaseTestCase then this class creates a connection to the database in setUp() and closes it in teardown() this can prove to be a big overhead and can cause considerable slowdown in running tests as the number of test cases increase. Maintaining a single connection for the entire test suite can prove to be beneficial in such cases.</p>
<p>If you are using JUnit 4 then you can use annotations for performing initial operations (@BeforeClass) and thus there is no need to extend the DatabaseTestCase and finally handling the closing of database connection.</p>
<pre class="brush: java; title: ; notranslate">@BeforeClass
public static void setUpBeforeClass() throws Exception {
handleSetUpOperation();
}
</pre>
<p>If several test cases are using a read only dataset as expected state of the database after running the test cases then loading this expected dataset file only once for all the test cases can help up in speeding up things.</p>
<p><strong>Specifying a DTD for the dataset can act as a cure for some of the things</strong><br />
You can create a DTD by using the following code in DbUnit.</p>
<pre class="brush: java; title: ; notranslate">FlatDtdDataSet.write(connection.createDataSet(),
new FileOutputStream(&quot;test.dtd&quot;)); </pre>
<p>This DTD can be used now to<br />
-    Validate a dataset file against it.<br />
-    Providing null values to a column by omitting it for a row in dataset.</p>
<p><strong>Keeping some reusable methods</strong><br />
A few reusable methods like asserting the database state after running tests with an expected state dataset file can be very useful. I am mentioning one of such methods here</p>
<pre class="brush: java; title: ; notranslate">    protected void assertTables(String filename, String[] tableNames)
    throws SQLException, Exception, DataSetException, IOException,
    DatabaseUnitException {
    IDataSet expectedDataSet = null;
    if (tableNames == null) {
    // Load expected data from an XML data set
    expectedDataSet = new FlatXmlDataSet(new File(filename));
    tableNames = expectedDataSet.getTableNames();
    } else {
    // Load subset of the complete dataset
    expectedDataSet = new FilteredDataSet(tableNames,
    new FlatXmlDataSet(new File(filename)));
    }
    // Fetch database data after executing your code
    IDataSet actualDataSet = getConnection().createDataSet(tableNames);
    ITable[] expectedTables = new CompositeTable[tableNames.length];
    for (int i = 0; i &lt;tableNames.length; i++) {
    expectedTables[i] = new CompositeTable(expectedDataSet
    .getTableMetaData(tableNames[i]), actualDataSet
    .getTable(tableNames[i]));
    }
    Assertion.assertEquals(expectedDataSet, new CompositeDataSet(
    expectedTables));
    }
</pre>
<p>Above method assertTables can assert the current state of the database after running test cases with the state provided in the dataset file. This method is intelligent enough to handle both cases of asserting the database state with the expected dataset file by supplying table names (might be a subset of all the tables provided in the dataset file) or without the table names in which case all the tables provided in the dataset files are used. The method uses table meta-data provided in the dataset file to get state of the corresponding table from the database, thus to ignore column such as auto-generated column can be automatically avoided in comparison by not mentioning them in the dataset file.</p>
<p><strong>Happy Red-Green-Refactor-ing.</strong></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2007/09/21/sharpen-up-your-dbunit-testing/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2007%2F09%2F21%2Fsharpen-up-your-dbunit-testing%2F&amp;title=Sharpen%20up%20your%20DbUnit%20testing" id="wpa2a_4"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2007/09/21/sharpen-up-your-dbunit-testing/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Do You Log from JavaScript? – Part I</title>
		<link>http://blog.xebia.com/2007/04/30/do-you-log-from-javascript-%e2%80%93-part-i/</link>
		<comments>http://blog.xebia.com/2007/04/30/do-you-log-from-javascript-%e2%80%93-part-i/#comments</comments>
		<pubDate>Mon, 30 Apr 2007 10:03:11 +0000</pubDate>
		<dc:creator>Saket Vishal</dc:creator>
				<category><![CDATA[Javascript]]></category>

	<!-- AutoMeta Start -->
	<category>javascript</category>
	<category>loggers</category>
	<category>boxes</category>
	<category>alert</category>
	<category>breed</category>
	<category>appending</category>
	<category>troubleshooting</category>
	<category>technique</category>
	<!-- AutoMeta End -->
	
		<guid isPermaLink="false">http://blog.xebia.com/2007/04/30/do-you-log-from-javascript-%e2%80%93-part-i/</guid>
		<description><![CDATA[Why do so many Java web applications write log messages from the Java code? A normal answer would be, to capture the information about operation of an application. This captured information can further be used for debugging, troubleshooting and auditing. JavaScript continues to prosper as top scripting language and AJAX has acted as icing on [...]]]></description>
			<content:encoded><![CDATA[<p class="MsoNormal" style="text-align: justify">Why do so many<span lang="EN-GB"> Java web applications write log messages from the Java code?</span><span lang="EN-GB"> </span><span lang="EN-GB">A normal answer would be, to capture the information about operation of an application. This captured information can further be used for debugging, troubleshooting and auditing<strong>. JavaScript continues to prosper as top scripting language and AJAX has acted as icing on the cake</strong>.</p>
<p><span id="more-222"></span></p>
<p>JavaScript is also a popular scripting language to be used with Java web applications. At times the JavaScript becomes too complex and messy as its contribution increases in an application, making it difficult to assimilate. Things like debugging and troubleshooting get bit difficult and time consuming.</span> The paramount question on this situation to come up would be “<span lang="EN-GB">How many of these Java web applications write log messages from the JavaScript</span>?” I will leave the last question unanswered and instead I will raise some more questions. How do you feel when you see an application throwing a JavaScript error in production or even during development phase? Isn’t it annoying? Doesn’t it hurt? Many times we are unaware of solutions that exist for a problem which can make our life so much easier. Is there exists a simple solution to log from a JavaScript code? In the following part of this blog I will try to answer some of these questions.</p>
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">Many developers are not even aware of the availability of JavaScript loggers. However, various tools available for debugging JavaScript such as plugins for Firefox are used heavily by JavaScript developers these days. Are these tools really suppressing the need for JavaScript Loggers? I have tried to cover up the various techniques used by the available loggers for JavaScript followed up by their Pros &#038; Cons.</p>
<p class="MsoNormal">
<p class="MsoNormal" style="text-align: justify"><strong># Alert boxes</strong></p>
<p class="MsoNormal" style="text-align: justify">Many developers will argue on including this as a logging technique but as this is the most frequently used way for JavaScript debugging, so I have to mention it. This involves simply placing a number of alert boxes to view the status of a variable or to act as a notification.</p>
<p class="MsoNormal" style="text-align: justify">
<blockquote>
<p class="MsoNormal" style="text-align: justify">+ Very easy to use, suitable for simple scripts.<br />
-  No control of output.<br />
-  Requires multiple clicks on alert boxes which can be annoying.</p></blockquote>
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify"><strong># Plugins and Browser included tools</strong></p>
<p class="MsoNormal" style="text-align: justify">Another technique which is currently very popular in the developer community is the various plugins available for browsers like JavaScript console for Firefox and others. These plugins or add-ons generally get integrated with the browser and provide useful information related to our code.</p>
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">
<blockquote>
<p class="MsoNormal" style="text-align: justify">+ Quick overview of errors.<br />
-  Time required in learning, some debuggers can be very complex.<br />
-  Portability issues as these tools are browser dependent.<br />
-  Fail to provide the knowledge of flow of the code.<br />
-  Lacks the ability to log from the code.</p></blockquote>
<p class="MsoNormal" style="text-align: justify"><strong># Logging by appending to the DOM</strong></p>
<p class="MsoNormal" style="text-align: justify">A nice replacement to the alert boxes is logging by appending messages to DOM in the HTML page. There are tons of JavaScript loggers of this breed offering logging with certain levels with indicating colors (using css). The common working pattern of these loggers involves a JavaScript function that appends log messages to a predefined HTML element in the page or by creating an element by itself.</p>
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">
<blockquote>
<p class="MsoNormal" style="text-align: justify">+ Very helpful in development phase.<br />
-  Messages by this logger can’t be persisted.</p></blockquote>
<p class="MsoNormal" style="text-align: justify"><strong> # Logging with AJAX pattern</strong></p>
<p class="MsoNormal">Loggers of this breed use the well known AJAX pattern to solve the log persistence problem raised by DOM manipulators or appenders, in this the error messages are communicated to the server through JavaScript where they can be persisted for further use.</p>
<blockquote><p>+ Allows persistence of error messages.<br />
+ Allows gathering of client-side usage statistics, this can prove to be valuable information for the websites with rich user interfaces.<br />
-  Raises an issue of user privacy as this technique can easily be quoted as used for spying on users.</p></blockquote>
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">
<p class="MsoNormal" style="text-align: justify">Unaware of existence of such JavaScript loggers a developer gets a natural inclination for writing one of their own, but why to reinvent the wheel? There are logging libraries such as log4javascript and log4js which have nearly all the above stated techniques incorporated and depending upon his needs a developer can use one or many of them. I will try to cover one such library in my next blog and will show how beneficial in can be. Till then Happy Logging!</p>
<p><span style="font-size: 12pt" /></p>
<div name="googleone_share_1" style="position:relative;z-index:5;float: right; margin-left: 10px;"><g:plusone size="small" count="1" href="http://blog.xebia.com/2007/04/30/do-you-log-from-javascript-%e2%80%93-part-i/"></g:plusone></div><p><a class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fblog.xebia.com%2F2007%2F04%2F30%2Fdo-you-log-from-javascript-%25e2%2580%2593-part-i%2F&amp;title=Do%20You%20Log%20from%20JavaScript%3F%20%E2%80%93%20Part%20I" id="wpa2a_6"><img src="http://blog.xebia.com/wp-content/plugins/add-to-any/share_save_171_16.png" width="171" height="16" alt="Share"/></a></p>]]></content:encoded>
			<wfw:commentRss>http://blog.xebia.com/2007/04/30/do-you-log-from-javascript-%e2%80%93-part-i/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
<!-- This Quick Cache file was built for (  blog.xebia.com/author/saket_vishal/feed/ ) in 0.48281 seconds, on Feb 9th, 2012 at 5:36 pm UTC. -->
<!-- This Quick Cache file will automatically expire ( and be re-built automatically ) on Feb 9th, 2012 at 6:36 pm UTC -->
