<?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>Netuality &#187; junit</title>
	<atom:link href="http://www.netuality.ro/tag/junit/feed" rel="self" type="application/rss+xml" />
	<link>http://www.netuality.ro</link>
	<description>Taming the big, bad, nasty websites</description>
	<lastBuildDate>Mon, 07 Nov 2011 16:36:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Using HTTPUnit &apos;out of the box&apos;</title>
		<link>http://www.netuality.ro/using-httpunit-out-of-the-box/tools/20050202</link>
		<comments>http://www.netuality.ro/using-httpunit-out-of-the-box/tools/20050202#comments</comments>
		<pubDate>Wed, 02 Feb 2005 05:21:10 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.netoo.loco/using-httpunit-out-of-the-box/uncategorized/20050202</guid>
		<description><![CDATA[Recently, HTTPUnit project reached version 1.6. While this nifty API is mainly targeted at unit testing webapps, I have also succesfully used it for other purposes such as : HTTPUnit as a benchmarking tool There is a plethora of web benchmarking tools out there, both freeware and commercial. However, my customer requested some features for [...]]]></description>
			<content:encoded><![CDATA[<p>Recently, <a HREF="http://www.httpunit.org/" target="_new">HTTPUnit</a> project reached version 1.6. While this nifty API is mainly targeted at unit testing webapps, I have also succesfully used it for other purposes such as :</p>
<p><strong>HTTPUnit as a benchmarking tool</strong></p>
<p>There is a plethora of web benchmarking tools out there, both freeware and commercial. However, my customer requested some features for testing, that I&apos;ve had troubles satisfying simultaneously with the existing tools:
</p>
<ul>
<li>the tests must run on headless systems (console mode, non GUI)</li>
<li>load testing should simulate complex and realistic user interactions with the site</li>
</ul>
<p>AFAIK, all the testing tools that allow recording and replaying of  intricate web interaction scenarios are GUI-based. And then, command-line tools are also unfit for the job, take for instance <a HREF="http://jakarta.apache.org/jmeter/" target="_new">Apache Jmeter</a> which is basically a command-line tool with a Swing GUI slapped on it. While Jmeter is great when it comes to bombing a server (or a cluster, for that matter) with requests, it seriously lacks features when it comes to scripting complex interaction (you&apos;d better know your URL&apos;s and cookies by heart &#8230; well, almost).
</p>
<p>Another problem I see with existing automated testing solutions is with their error detection mechanisms. While the vast majority of tools are scanning for standard HTTP error codes such as 404 or 500 in order to find out if the response is erroneous or not, errors in complex Java apps might come as plain web pages containing strack traces and environment information (a good example is the error page in Apache Tapestry).
</p>
<p>So eventually I had to come up with an ad-hoc solution &#8211; basic idea was to leverage the existing HTTP unit tests for benchmarking purposes. I had to get out of the toolbox another rather under-rated open-source gem: <a HREF="http://www.clarkware.com/software/JUnitPerf.html" target="_new">JUnitPerf</a>, in fact a couple of decorators for Junit tests. LoadTest is the decorator I&apos;m interested in : it allows running a test in multithreaded mode, simulating any number of concurrent users. Thus, I am able to reproduce heavy loads of complex user interaction and precisely count the number of errors. The snippet of code is something like:
</p>
<pre>
SimpleWebTestPerf swtp = new SimpleWebTestPerf("testOfMyWebapp");
Test loadTest = new LoadTest(swtp, nbConcurrentThreads);
TestResult tr = TestRunner.run(loadTest);
int nbErr = tr.errorCount();
</pre>
<p>Now, we&apos;ll call this code with increasing values of nbConcurrentThreads and see where the errors start to appear. Might as well write the results in a log file and even create a nice PNG via JFreeChart. Alas, things become a little trickier when we want to measure the bandwidth; in our case we&apos;ll have to write something very lame in the TestCase; and it goes like that:
</p>
<pre>
private long bytes = 0;

private synchronized void addBytes(long b)
{
	bytes += b;
}

/**
 * After a test was run, returns the volume of HTTP data.
 * @return
 */
public long getBytes()
{
	return bytes;
}

public void testProdsPerformance() throws MalformedURLException,
  IOException, SAXException
{
	[...]
	WebConversation wc = new WebConversation();
	WebResponse resp = wc.getResponse(something);
	addBytes(resp.getContentLength());
	[...]
}
</pre>
<p>Then, in the benchmarking code, we&apos;ll do <em>swtp.getBytes()</em> in order to find out how many bytes passed between the server and the test client. It is still unclear for me if this value is correct if mod_gzip is activated on the server (we might actually measure the bandwidth of the &apos;deflated&apos; pages !?).
</p>
<p>In order to measure the elapsed time, we&apos;ll do a similar (lame) trick with a <em>private long time</em> member and a <em>private synchronized void addTime(long millis)</em>. Unfortunately, we do not [yet?] have a getElapsedTime() for the WebResponse, so we&apos;ll have to use the good old <em>System.currentTimeMillis()</em> before and after extraction of each WebResponse. Of course, this is also measuring the parsing time of WebResponse, but this isn&apos;t usually a problem when you are testing a large number of concurrent users, as the parsing time is much smaller when compared with the response time of a stressed server. But, you&apos;ll need a strong system for the client-side tests.
</p>
<p>Another tip I&apos;ve found: use Random in order to test different slices of data on different test runs. This way, when you run, let&apos;s say, the 20 threads test, you&apos;ll kick different data compared to the previous test, on 10 threads. In this manner, the results will be less influenced by the tested application cache(s). It&apos;s perfectly possible to launch LoadTest threads with delays between thread activation, which means that the Random seed could be different within each simulated client &#8211; if you&apos;re looking for even more realistic behavior.
</p>
<p><strong>HTTPUnit as a Web integration API</strong></p>
<p>Besides being a great testing tool, Httpunit is also a cool API for Web manipulation, you can use it to perform data integration with all sorts of websites. For instance, let&apos;s log on the public demo <a HREF="http://mantisbt.sourceforge.net/mantis/login_page.php" target="_new">instance</a> of <a HREF="http://www.mantisbt.org/" target="_new">MantisBT</a> bug tracking system, as user &apos;developer&apos;, and extract the descriptions of the first three bugs in the list.
</p>
<pre>
package webtests;

import java.io.IOException;
import java.net.MalformedURLException;

import org.xml.sax.SAXException;

import com.meterware.httpunit.WebConversation;
import com.meterware.httpunit.WebForm;
import com.meterware.httpunit.WebResponse;
import com.meterware.httpunit.WebTable;

/**
 * Simple demo class using httpunit to extract the description of
 * three most recent bugs from the MantisBT public demo,
 * logged as &apos;developer&apos;.
 * @author Adrian Spinei aspinei@yahoo.com
 * @version $Id: $
 */
public class MantisTest
{

	public static void main(String[] args) throws MalformedURLException, IOException, SAXException
	{
		WebConversation wc = new WebConversation();
		WebResponse resp = wc.getResponse("http://mantisbt.sourceforge.net/mantis/login_page.php");
		WebForm wForm = resp.getFormWithName("login_form");
		wForm.setParameter("username", "developer");
		wForm.setParameter("password", "developer");
		//submit login, conect to front page
		resp = wForm.submit();
		//&apos;click&apos; on the &apos;View Bugs&apos; link
		resp = resp.getLinkWith("View Bugs").click();
		//retrieve the table containing the bug list
		//you&apos;ll have to believe me on this one, I&apos;ve counted the tables !
		WebTable webTable = resp.getTables()[3];
		//first three rows are : navigation and header, then a blank formatting row

		//interesting data starts from the 4th column

		System.out.println(webTable.getCellAsText(3, webTable.getColumnCount() - 1));
		System.out.println(webTable.getCellAsText(4, webTable.getColumnCount() - 1));
		System.out.println(webTable.getCellAsText(5, webTable.getColumnCount() - 1));
	}
}
</pre>
<p>The code speaks for itself: HTTPUnit is beautiful, intuitive and easy to use.
</p>
<p>Other interesting HTTPUnit-related articles:</p>
<ul>
<li><a HREF="http://www.codeczar.com/technologies/httpunit/HttpUnitHowTo.html" target="_new">HttpUnit &#8211; how to write tests</a> on CodeCzar.</li>
<li><a HREF="http://jroller.com/page/oliv/20040910#get_started_with_http_unit" target="_new">Getting Started with HttpUnit and JDeveloper 10g</a></li>
<li><a HREF="http://www.javaworld.com/javaworld/jw-04-2004/jw-0419-httpunit_p.html" target="_new">Test Web applications with HttpUnit</a>, published on JavaWorld</li>
<li><a HREF="http://c2.com/cgi/wiki?HttpUnitTutorial" target="_new">HttpUnit tutorial</a> on C2 wiki, extracting a Dilbert cartoon (that&apos;s a cool integration example)</li>
<li><a HREF="http://jwebunit.sourceforge.net/" target="_new">JWebUnit</a> (suggested in the comments) is a wrapper around httpunit, offering an even higher level API and simpler usage. </li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.netuality.ro/using-httpunit-out-of-the-box/tools/20050202/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JUnit Recipes &#8211; for the gourmets of Java unit testing</title>
		<link>http://www.netuality.ro/junit-recipes-for-the-gourmets-of-java-unit-testing/books/20041121</link>
		<comments>http://www.netuality.ro/junit-recipes-for-the-gourmets-of-java-unit-testing/books/20041121#comments</comments>
		<pubDate>Sun, 21 Nov 2004 08:41:46 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Books]]></category>
		<category><![CDATA[book]]></category>
		<category><![CDATA[j2ee]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[velocity]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.netoo.loco/junit-recipes-for-the-gourmets-of-java-unit-testing/uncategorized/20041121</guid>
		<description><![CDATA[A mini-review The book already has stellar ratings on Amazon, JavaRanch and other select places, and after reading a few chapters, the only thing I can do is add this post on the praise list. Why only a few chapters ? Well, you see, this is not exactly the type of book that you read [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://www.jroller.com/resources/aspinei/junit.jpg" border="0" align="left" vspace="5" hspace="20"/> <b>A mini-review</b></p>
<p>The <a HREF="http://www.manning.com/rainsberger" target="_new">book</a> already has stellar ratings on Amazon, JavaRanch and other select places, and after reading a few chapters, the only thing I can do is add this post on the praise list.</p>
<p>Why only a few chapters ? Well, you see, this is not exactly the type of book that you read from cover to cover, it&apos;s in fact a 720-pages solid collection of JUnit best practices, the most comprehensive you&apos;ll ever found in organized, written form. Until now, I have found precise answers to all my JUnit questions.</p>
<p>The book is organized in three big sections weighting some 200-250 pages each. The first one (&apos;The building blocks&apos;) is hugely useful if you are a JUnit newbie or even an absolute beginner. It&apos;s a detailed introduction to everything you&apos;ll need to know in order to start using JUnit: basics, usage in mainstream IDEs, testing patterns, managing test suites, test data and troobleshooting advice. Even seasoned programmers will find useful pieces of advice. I especially liked the 5th chapter (&apos;Working with test data&apos;) : an exhaustive description of all the possible ways of organizing your test data. To be honest, it&apos;s one of the few chapters from the first section, that I&apos;ve really read.</p>
<p>The second part (&apos;Testing J2EE&apos;) covers testing of XML, JDBC, EJB, web components (JSP, servlets, Velocity templates, out-of-container testing &#038; such) and J2EE applications (security and again some webapp testing &#8211; pageflow, broken links, Struts navigation). I can&apos;t really pronounce upon this section since I&apos;ve read only a few subchapters (DBUnit and some related JDBC testing, as well as a few pages from the web testing chapter). But every piece of advice I&apos;ve got was rock solid.</p>
<p>I&apos;ve read in its entirety the third part (&apos;More JUnit techniques&apos;). Under this bland title you&apos;ll find a group of not-so-common JUnit info such as usage of GSBase addon (funny that I wasn&apos;t aware that such a useful addon exists). There&apos;s also an intriguing &apos;Odds and ends&apos; chapter containing some interesting recipes (here&apos;s a good one for the QA-freaks like me : &apos;verify that your test classes adhere to basic syntax rules of JUnit&apos; &#8211; sure, why not ?).</p>
<p>Something that I&apos;ve really missed is a chapter dedicated to mock objects recipes. Yes, there is a quick explanation in the first section &#8211; and a reference to Easy Mock or some other mocking API pops now and then in different chapters &#8211; there&apos;s even an essay about mocking at the end of the book. But the main mock objects dish isn&apos;t there. I would&apos;ve also loved to see some automated GUI-testing recipes (Abbot, Marathon &#038; related tools). But then again, it&apos;s a &gt;700-pages book so I&apos;m probably asking too much.</p>
<p>To conclude, &apos;JUnit Recipes&apos; is the best JUnit book I&apos;ve ever came into contact with and it supercedes on my list <a HREF="http://www.manning.com/massol" target="_new">&apos;JUnit in Action&apos;</a>. Which, interesting enough, was published by the same Manning almost a year ago. Can&apos;t have too many good JUnit books, don&apos;t they ?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netuality.ro/junit-recipes-for-the-gourmets-of-java-unit-testing/books/20041121/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Junit : it&apos;s not [only] about the API</title>
		<link>http://www.netuality.ro/junit-its-not-only-about-the-api/andeverythingelse/20040714</link>
		<comments>http://www.netuality.ro/junit-its-not-only-about-the-api/andeverythingelse/20040714#comments</comments>
		<pubDate>Wed, 14 Jul 2004 06:55:22 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[AndEverythingElse]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[Sun]]></category>

		<guid isPermaLink="false">http://www.netoo.loco/junit-its-not-only-about-the-api/uncategorized/20040714</guid>
		<description><![CDATA[Being extremely busy lately, I arrive a bit late at the Junit destruction feast. While it is probably true that some guys with a certain gift for writing blog articles may &#8220;come up with something far more useful in a couple of days&#8221;, I think the discussion is missing an important point: there&apos;s a whole [...]]]></description>
			<content:encoded><![CDATA[<p>
Being extremely busy lately, I arrive a bit late at the <a HREF="http://www.pyrasun.com/mike/mt/archives/2004/07/10/18.43.16/index.html" target="_new">Junit destruction feast</a>. While it is probably true that some guys with a certain gift for writing blog articles may &#8220;come up with something far more useful in a couple of days&#8221;, I think the discussion is missing an important point: there&apos;s a whole ecosystem living around Junit. We have Ant integration, we have the choice between code coverage tools (both <a HREF="http://www.cenqua.com/clover/" target="_new">commercial</a> and <a HREF="http://java-source.net/open-source/code-coverage" target="_new">open-source</a>), plugins for mainstream IDEs and <a HREF="http://www.junit.org/news/extension/index.htm" target="_new">a certain number</a> of useful or less-useful extensions. We have extensive documentation and a plethora of examples to feed the small fishes. Throwing Junit down the drain means throwing all these down the drain. Or, at least: write your own Ant integration, adapt a code coverage tool and rewrite the IDE integration, rewrite documentation and examples &#8211; <strong>this</strong> is not going to be done in &#8220;a couple of days&#8221;.
</p>
<p>
Another Junit advantage is that this little simplistic API is ubicuous. I mean, every developer heard about it and knows how to use it, unless of course he/she was living under a rock for the last few years. And I don&apos;t mean every <em>Java</em> developer, but just about every developer for a language under the xunit <a HREF="http://www.xprogramming.com/software.htm" target="_new">umbrella</a>. Meaning : all the programming languages (unless you consider &#8220;languages&#8221; such as Whitespace, Brainfuck and INTERCAL).
</p>
<p>
Beck and Gamma have not only written some &#8220;crappy&#8221; classes and put the few &#8220;laughable&#8221; chunks of code on Sourceforge, they have done it <strong>first</strong>. Now, there is some well-founded <a HREF="http://www.dehora.net/journal/archives/000295.html" target="_new">criticism</a> about the lack of evolution in Junit, but one thing is undeniable : it really did fill a niche, back then in 2000. The code may not be beautiful (and <strong>this</strong> is not good coming from XPers) but it serves its purpose : to provide a simple framework for unit testing.
</p>
<p>
Competition is the key here and <a HREF="http://www.beust.com/testng/" target="_new">smart newcomers</a> on this &#8220;market&#8221; are good news for us programmers. But, it&apos;s gonna take some time and a lot of work to build a similar ecosystem, a similar mindshare and usurp Junit&apos;s kingdom. That would be of course more interesting to see than denial of four years of Junit influence in a few well-rounded, but futile phrases.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.netuality.ro/junit-its-not-only-about-the-api/andeverythingelse/20040714/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Comparing FOP and JasperReports</title>
		<link>http://www.netuality.ro/comparing-fop-and-jasperreports/tools/20040525</link>
		<comments>http://www.netuality.ro/comparing-fop-and-jasperreports/tools/20040525#comments</comments>
		<pubDate>Tue, 25 May 2004 05:57:41 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[Sun]]></category>
		<category><![CDATA[velocity]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.netoo.loco/comparing-fop-and-jasperreports/uncategorized/20040525</guid>
		<description><![CDATA[Anybody looking for OSS reporting solutions in Java usually has to make a choice between Apache FOP and Jasper Reports*. While having somewhat different feature sets and addressing distinct reporting solutions, the two APIs boil down to the same basic thing : generate a report from an XML file (or stream/string/whatever). FOP has a clear [...]]]></description>
			<content:encoded><![CDATA[<p>Anybody looking for OSS reporting solutions in Java usually has to make a choice between <a HREF="http://xml.apache.org/fop/" target="_new">Apache FOP</a> and <a HREF="http://jasperreports.sourceforge.net/" target="_new">Jasper Reports</a>*. While having somewhat different feature sets and addressing distinct reporting solutions, the two APIs boil down to the same basic thing : generate a report from an XML file (or stream/string/whatever). FOP has a clear advantage of standardization (based on <a HREF="http://www.w3.org/TR/xsl/slice6.html#fo-section" target="_new" title="Relevant chapter from XSL specification">XSL-Formatting Objects</a>) while Jasper plays more in the pragmatic field of obtaining those 80% results with a minimum of effort and uses a proprietary XML format.</p>
<p>But FOP is not a standalone reporting solution : it&apos;s just a way of transforming XSL-FO files into a report. In order to fill the report with the necessary data, the obvious choice is a templating engine such as <a HREF="http://jakarta.apache.org/velocity/" target="_new">Jakarta Velocity</a>. Thus a FOP report creation is a two-step operation :</p>
<ul>
<li>create the XML report via Velocity</li>
<li>feed the XML stream to FOP</li>
</ul>
<p>Jasper alleviates this problem by including its own binding engine, the only restriction being that input data should support some constraints (such as putting your &apos;rows&apos; inside a JRDataSource).</p>
<p>Both Jasper and FOP allow inclusion of graphic files inside, usual formats (GIF, JPEG) are supported, however FOP has a nice bonus of rendering SVG inside reports. Unfortunately, this comes with the price of using <a HREF="http://xml.apache.org/batik/" target="_new">Batik SVG Toolkit</a>, which is a bulky (close to 2MB) and rather slow API. While processing your dynamic charts as XML files (Velocity again) is a seducing idea, the abysmal performance of SVG rendering will make you give up in no time. Unfortunately, I speak from experience.
</p>
<p>
At first sight, FOP has a lot more options for output format, compared to Jasper Reports. Of course there&apos;s PDF and direct printing via AWT, but also Postscript, PCL, MIF as well as SVG. These choices are quite intriguing, since Postscript and PCL are printing formats (easily obtained by redirecting the specific printer queue into a file), MIF is a rather obscure Adobe format (for Framemaker) and SVG &#8230; well, a SVG report is too darn slow to be useable (yes, I was foolish enough to try this, too). Jasper makes again a pragmatic choice by allowing really useful output formats such as HTML, CSV and XSL (never underestimate the power of Excel); and of course: direct printing via AWT and PDF.<br />
While FOP&apos;s latest version (0.20.5) was released almost a year ago (summer 2003), Jasper Reports is bubbling with activity &#8211; Teodor releases a minor version each one or two months (latest being 0.5.3 at 18.05.2004).</p>
<p>I&apos;ve decided to use as a &apos;lab rat&apos; one of the apps developed during my &apos;startup days&apos;: the client GUI is written in Swing and features a few mildly complex reports generated using Velocity+FOP. FOP version is 0.20.4 (the current version back in Q1-2003, when we had to quit dreaming about the &apos;next financing round&apos; and development halted) but as I already told you FOP has evolved little since then. Though, it&apos;s perfectly reasonable to use this implementation as a witness for comparison with Jasper (on the opposite, Jasper has evolved a great deal since Q1-2003).</p>
<p>Back then, the report development cycle was quite simplistic. In fact, the XSL-FO templates were written by hand inside a text editor and the application code was run (via a Junit testcase and some necessary configuration and business data mocking) in order to generate a PDF report. In the case of errors, we had feedback by examining the error traces. Visual feedback was given by the PDF output. While simple to perform, this cycle was extremely tiresome after a while as there was an important overhead : start a new JVM, initialize FOP, fire Acrobat Reader (plus we were using some crappy &#8211; even by the standards of 2003 &#8211; 1GHz machines w 256/512MB RAM). A WYSIWYG editor would have been nice, so one of my coworkers has made some research and the only solution he found was <a HREF="http://www.altova.com/dev_portal_xslfo.html" target="_new">XMLSpy</a> (Stylevision not available back then) &#8211; but, at 800USD/seat this was &apos;a bit&apos; pricey** for us (only the Enterprise flavor covers FO WYSIWYG editing !?). Another interesting idea was to use one of the conversion tools (from RTF to FOP) such as <a HREF="http://www.jfor.org/jfor-readme.html" target="_new">Jfor</a>, <a HREF="http://www.xmlmind.com/foconverter/persoedition.html" target="_new">XMLMind</a> or <a HREF="http://www.rtf2fo.com/help.html" target="_new">rtf2fo</a> (of these products, only Jfor is free, but feature-poor). What stopped us from doing it was that the generated FO was overly complex : we needed comprehensible cut_the_crap files because we were going to integrate inside Velocity templates. And when you have tens of tags and blocks inside blocks and not the slightest idea which one is a row, which one is a column and which one is a transparent dumbass artefact, it&apos;s a gruesome trial-and-error task to integrate even simple VTL loops. And you&apos;d have to do this each time you change something in the report : yikes ! Conclusion : the report development cycle was primitive for FOP and there was no way we could change it.</p>
<p>Things are quite different for Jasper Report : there are a lot of available report designers, and some of them are free. While the complete list is on Jasper Report site, I&apos;d like to note at least three of them :</p>
<ul>
<li><a HREF="http://ireport.sourceforge.net/" target="_new">iReport</a> is a Swing editor and very interesting because it&apos;s not only covering the basic Jasper functionality but also supplementary features such as barcode support (which is admittedly as easy as embedding a barcode font in Jasper with two lines of XML, but much easier to make it via a mouse click). iReport is free, which is excellent, but is a standalone app without IDE integration, and as any complex Swing app is quite slow and a memory hog.</li>
<li>if you are a developer using Eclipse, you&apos;d appreciate two graphical editors based on Eclipse GEF, available as Eclipse plugins : <a HREF="http://www.jasperassistant.com/" target="_new">JasperAssistant</a> and <a HREF="http://www.pratocity.com/index.jsp?mod=/sunshine/sunshine.jsp" target="_new">SunshineReports</a>. None of them is free and, at least on paper, the functionality seem identical, but SunshineReports has only the older 1.1 version downloadable, which is free but does NOT work with recent builds of Eclipse 3. How the heck am I supposed to test it ? On the contrary, Assistant has a much more relaxed attitude allowing the download of a free trial for the latest version of their product. Maybe too relaxed, though, because &#8211; even if (theoretically) limited in number of usages &#8211; you can use the trial as much as you want to***. But if you are serious about doing Jasper in Eclipse you should probably buy Assistant, available for a rather decent 59USD price tag. I am currently using it and it&apos;s a good tool.</li>
</ul>
<p>So much for the tools, let&apos;s get the job done. The bad part : if you&apos;re experienced with FO templates, don&apos;t expect to be immediately proficient with Jasper, even with a GUI editor. The structure of an FO document has powerful analogies with HTML : you have tables, rows, cells, stuff like that, inside special constructs called blocks. It&apos;s relatively easy to use a language such as VTL in order to create nested tables, alternating colors and other data layout tricks. You can even render a tree-organized data via a recursive <a HREF="http://jakarta.apache.org/velocity/user-guide.html#Velocity%20Template%20Language%20(VTL):%20An%20Introduction" target="_new" title="Velocity Template Language">VTL macro</a>, and everything is smooth and easy to understand. Jasper is completely different and at first sight you&apos;ll be shocked by its apparent lack of functionality : only rectangles, lines, ellipses, images, boilerplate text and fields (variable text). Each one of this elements has an extensive set of properties about when the element should be displayed, stretch type, associated expression for value and so on. Basically, you&apos;d have to write Java code instead of Velocity macros and call this code from the corresponding properties of various report elements. If at the beginning it feels a little awkward, after a while it comes quite natural and simple. As for nesting and other advanced layouts, there is a powerful concept of &apos;subreport&apos;. And yes I&apos;ve managed to render a tree using a recursive subreport, but given the poor performance the final choice was to flatten the data into a vector then feed it into a simple Jasper report. So pay attention to the depth of &apos;subreporting&apos;.
</p>
<p>
Once the reports were completely migrated, I&apos;ve benchmarked a simple one (without SVG, charts, barcodes or other &apos;exotic&apos; characteristics). The test machine is a 2.4GHz P4 w 512MB Toshiba Satellite laptop. In the case of FOP, the compiled velocity template and the FOP Driver are cached between successive runs. In the case of Jasper, the report is precompiled and loaded only on first run, then refilled with new data before each generation. The lazy loading and caching of reporting engines is the cause of important time differences between the generation of the first report and the subsequent reports. Delta memory is measured after garbage collection. The values presented are median for 10 runs of the &apos;benchmark report&apos;.</p>
<table width="100%" border="1" cellpadding="0" cellspacing="0" bordercolor="#CCCCCC">
<tr>
<td>&nbsp;</td>
<td>First run</td>
<td>Subsequent runs</td>
<td>Delta memory</td>
</tr>
<tr>
<td>Velocity + FOP</td>
<td>10365ms</td>
<td>381ms</td>
<td>850KB</td>
</tr>
<tr>
<td>Jasper Reports</td>
<td>1322ms</td>
<td>82ms</td>
<td>1012KB</td>
</tr>
</table>
<p>While I am totally pro-Jasper after this short experiment, it is important to note that commercial and well-maintained FO rendering engines such as <a HREF="http://www.renderx.com/" target="_new">RenderX XEP</a> claim improved performance upon FOP. Depending on your requirements, environment and reporting legacy apps, an FO-based solution might be better, especially when report generation is only on server-side.</p>
<p>Of course, usual disclaimer apply: this benchmark is valid only for my specific report in my specific application so YMMV.</p>
<p>* While I am aware that other OSS solutions do exist for Java, I consider these two as &apos;mainstream&apos;.<br/><br />
** Did I mentioned that we were a startup with financing problems ?<br/><br />
*** No, I&apos;m not going to explain here how it can be done.<br/></p>
]]></content:encoded>
			<wfw:commentRss>http://www.netuality.ro/comparing-fop-and-jasperreports/tools/20040525/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Exotic Eclipse plugins of the week</title>
		<link>http://www.netuality.ro/exotic-eclipse-plugins-of-the-week/tools/20040109</link>
		<comments>http://www.netuality.ro/exotic-eclipse-plugins-of-the-week/tools/20040109#comments</comments>
		<pubDate>Fri, 09 Jan 2004 07:24:09 +0000</pubDate>
		<dc:creator>Adrian</dc:creator>
				<category><![CDATA[Tools]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[junit]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[web]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.netoo.loco/exotic-eclipse-plugins-of-the-week/uncategorized/20040109</guid>
		<description><![CDATA[Currently developing Eclipse plugins, I am constantly searching for things on the net. Have to admit that PDE documentation is very scarce as soon as you enter into the depths of Eclipse such as tight integration with the search mechanism or extending JDT. Searching this kind of things, absolutely by pure chance I have found [...]]]></description>
			<content:encoded><![CDATA[<p>Currently developing Eclipse plugins, I am constantly searching for things on the net. Have to admit that PDE documentation is very scarce as soon as you enter into the depths of Eclipse such as tight integration with the search mechanism or extending JDT. Searching this kind of things, absolutely by pure chance I have  found two not very known Eclipse plugins.</p>
<table width="100%" border="0" cellpadding="5" cellspacing="5">
<tr>
<td ><img src="http://www.jroller.com/resources/aspinei/urbansim.gif" alt="Urbansim plugin" border="0"></td>
<td ><a HREF="http://www.urbansim.org/" target="_new">UrbanSim</a> is a &#8220;software-based simulation model for integrated planning and analysis of urban development&#8221;, and it&apos;s an Eclipse plugin ! Something like SimCity for geeks, without the fancy graphics. You can only log different urban evolution data and subsequently process it with your own tools if you want to. For real fun, computed data can be extracted from the database (yes, you have to install MySql) and viewed with a GIS tool such as ArcView. Not valuable <em>per se</em> for us Java developers but :<br/><br />
- all the code is downloadable (GPLed). Some of algorithms might be worth a look.<br/><br />
- UrbanSim includes a suite of acceptance tests derived from the <a HREF="http://fit.c2.com/" target="_new">FIT</a> framework. AFAIK this is the first time FIT is used in a large open-source project.<br/><br />
- (their own) continuous integration system <a HREF="http://trondheim.cs.washington.edu/cgi-bin/UrbanSim2/webpage_builder.cgi?page=superindex" target="_new">Fireman</a> is also visible on the net. Hey, where can I download <strong>that</strong> ?<br/><br />
A presentation of UrbanSim is in the program of EclipseCon 2004.</td>
</tr>
<tr>
<td ><img src="http://www.jroller.com/resources/aspinei/jupiter.gif" alt="Jupiter plugin" border="0"></td>
<td >From the Collaborative Software Development Laboratory Department of Information and Computer Sciences, University of Hawaii, a plugin called <a HREF="http://csdl.ics.hawaii.edu/Tools/Jupiter/" target="_new">Jupiter</a>, which is described as &#8220;a code review plug-in tool for Eclipse to facilitate review process&#8221;. The plugin allows management of code annotations, storing &#8220;reviews&#8221; in an XML file, which can be shared with your team by CVS. This makes it much more than a code review tool, since it is quite possible to use the Jupiter &#8220;reviews&#8221; in order to share bug reports, enhancement requirements etc. What&apos;s interesting is that you can relate the reviews to specific Java code, this is a great feature; AFAIK missing from the mainstream issue trackers. A missing feature from Jupiter are issue metrics, but computing them from the XML files shouldn&apos;t be a difficult task. I see Jupiter more as a complement to traditional issue databases more than as a replacement, for different reasons:<br/><br />
- is accessible only from Eclipse in Java development environment (would have been nice to be able to annotate other types of files)<br/><br />
- in bigger teams, the XML files containing the reports are probably subject to frequent CVS conflicts<br/><br />
- there is no review &#8220;history&#8221;, thus the project dynamics will not be available unless you process somehow all the CVS revisions of review files<br/><br />
To conclude, Jupiter is somewhere between a smarter, enriched TODO with filters and a a poor man issue tracker. Worth a try.<br/><br />
Also from CSDL, there is the <a HREF="http://hackydev.ics.hawaii.edu/hackyDevSite/about.do" target="_new">Hackystat</a> project which plays in a totally different league. Hackystat &#8220;provides automated support for collecting and analyzing metrics of the process and products of software development&#8221;. Technically, it&apos;s a server with a JSP frontoffice, aggregating data received via SOAP from various &#8220;sensors&#8221; installed in developer&apos;s tools : IDEs like Eclipse, build tools such as Ant, testing tools such as Junit. Something like a BigBrother approach for PSP, everything you do is tracked, measured and put in a chart or on a graph. I strongly suspect that this type of tools will soon be available commercially and used by management for performance evaluation of software engineers. NOT necessarily a good thing.<br/><br />
Note that CSDL teams are using their own, inhouse-developed, tool for code coverage, <a HREF="http://csdl.ics.hawaii.edu/Tools/JBlanket/" target="_new">JBlanket</a>.</td>
</tr>
</table>
]]></content:encoded>
			<wfw:commentRss>http://www.netuality.ro/exotic-eclipse-plugins-of-the-week/tools/20040109/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

