| From | Sent On | Attachments |
|---|---|---|
| Dmitri Plotnikov | Apr 24, 2002 7:06 am | |
| Scott Sanders | Apr 24, 2002 6:33 pm | |
| Ivelin Ivanov | Apr 24, 2002 7:20 pm | |
| Jeff Turner | Apr 24, 2002 10:23 pm | |
| Craig R. McClanahan | Apr 24, 2002 10:25 pm | |
| Juozas Baliuka | Apr 24, 2002 11:14 pm | |
| di...@multitask.com.au | Apr 25, 2002 12:26 am | |
| Ivelin Ivanov | May 15, 2002 8:26 pm | |
| Jeff Turner | May 15, 2002 10:57 pm | |
| James Strachan | May 16, 2002 12:38 am | |
| Ivelin Ivanov | May 16, 2002 6:29 am | |
| Morgan Delagrange | May 16, 2002 8:31 am | |
| Morgan Delagrange | May 16, 2002 8:41 am | |
| Ovidiu Predescu | May 16, 2002 10:38 am | |
| Jeff Turner | May 16, 2002 4:21 pm | |
| Ivelin Ivanov | May 17, 2002 11:09 am | |
| Morgan Delagrange | May 17, 2002 11:17 am | |
| Ovidiu Predescu | May 17, 2002 11:26 am | |
| Ovidiu Predescu | May 17, 2002 11:32 am | |
| James Strachan | Oct 30, 2002 4:16 am | |
| Vincent Massol | Oct 30, 2002 4:26 am | |
| Janek Bogucki | Oct 30, 2002 6:17 am | |
| James Strachan | Oct 30, 2002 7:33 am | |
| Morgan Delagrange | Oct 30, 2002 8:54 am | |
| Ovidiu Predescu | Oct 30, 2002 12:04 pm | |
| di...@multitask.com.au | Oct 30, 2002 3:47 pm |
| Subject: | Re: Latka & Anteater | |
|---|---|---|
| From: | James Strachan (jame...@yahoo.co.uk) | |
| Date: | May 16, 2002 12:38:20 am | |
| List: | org.apache.commons.dev | |
Thanks for the heads up Jeff.
Incidentally I've been approaching the functional testing issue from a slightly different tack lately; using JSTL tags to perform XPath, XSLT, SQL, HTTP, JMS, soap calls etc. For example I'm building a bunch of SQL related unit tests, so that after various processes are run I can validate the contents of a database. So I can iterate through XML files containing the expected data and compare it to the database state. I can use the same mechanism for preloading the database with sample data.
I'm using Jelly as the processing engine; its kinda like a simple XML based JSP engine using custom tags to do all the work as well as supporting an expression language for doing things like ${a.b} or ${customer.orders[12].calculateTotal()} - the expression language is implemented by the Jexl project in the sandbox.
So writing the test scripts is not unlike building JSTL/JSP scripts. It also means we can reuse a large collection of standard tag definitions (JSTL) as well as using a standard expression language to make it easy to work with beans, and XPath for XML.
There's a Jelly Ant task which (like with Anteater) allows you to access all of Ant's properties using the usual ${foo.bar} style of expressions; though unlike Anteater non-string objects can be worked with too. For example to iterate over an SQL result set and output the results as SAX events you can use the following
<j:jelly xmlns:j="jelly:core" xmlns:sql="jelly:sql"> <sql:setDataSource url="${databaseUrl}" driver="${databaseDriver}" user="${databaseUser}"/>
<sql:query var="results"> select * from <j:expr value="${databaseTable}"/> </sql:query>
<dataSet> <j:forEach items="${results.rowsByIndex}" var="row"> <row> <j:forEach var="columnName" items="${results.columnNames}" indexVar="i"> <field column="${columnName}"><j:expr value="${row[i]}"/></field> </j:forEach> </row> </j:forEach> </dataSet> </j:jelly>
A tag is just a bean with a 'run' method; Jelly will set the various properties from XML attributes then evaluate the tag. So tags are quite like Tasks in Ant - so Jelly is similar to AntEater - though Jelly is based on the concept of XML output pipelining; one tag can emit XML events and its parent's tag can consume/transform them.
Also tags can be defined dynamically using Jelly script; so I could define a tag to represent a SOAP service call, which can transform the body and output, then I can pipeline the output into another tag to do XSLT, XPath, IO etc. So using the Jelly scripts is a neat way to process XML, SOAP & web services too.
e.g.
<file:write name="output.xml"> <!-- transform the output of a SOAP call --> <xsl:transform xslt="foo.xsl">
<!-- call a SOAP service ---> <babelfish:translate from="EN" to="FR"> <!-- maybe use other tags to produce the body --> <!-- e.g. from working with beans, XPath or SQL --> Jelly is cool stuff! </babelfish:translate>
</xsl:transform> <file:write>
I'd like to make Ant tasks available as tags within Jelly, then Jelly and Anteater could be mixed inside one script.
Its still a bit early days (and documentation is pretty much non existent) but hopefully given a bit of time Jelly might compare well with Latka and Anteater.
James
----- Original Message ----- From: "Jeff Turner" <je...@socialchange.net.au> To: "Jakarta Commons Developers List" <comm...@jakarta.apache.org> Sent: Thursday, May 16, 2002 6:57 AM Subject: Re: Latka & Anteater
On Wed, May 15, 2002 at 10:26:47PM -0500, Ivelin Ivanov wrote:
Can some of the Latka experts please comment on how Latka compares to Anteater (which emerged from Cocoon)?
I've worked on both projects, and like both for different reasons.
Latka pros: - Strong typing via a DTD. - Internally, it's got a very nice delegating-SAX-handler model for adding new elements. - Decent XML reporting. - After all Dion's work, it's docs are rather good.
Latka cons: - A PITA to compile, due to it's many dependencies. Hopefully that's changed with Maven. - The XML file is a bit hard to comprehend at first, due to the use of &entities; - Inflexible XML syntax (see below for definition of 'flexible':)
Anteater pros: - It's based on Ant (it's really a bunch of Ant tasks). This makes it wonderfully flexible: - I can parametrize tests, by defining variables like ${host}, ${port}, ${debuglevel} as properties, and reuse them throughout the script. - Through the use of targets, I can group tests together, and with the 'depends' attribute, can have common groups of tests. Latka's approach (entities) is workable but not half as nice & intuitive. - I can <echo> whenever I want, or <fail> halfway through a test. - I can use Ant's <parallel> to test multiple servers at once. - I can capture the matched <regexp> or <xpath> value as a property, and print it out for debugging. - I can do conditional logic, eg "If response code is 200, do a <regexp> test, else if response code is 404, set the ${failed} variable, else <fail> the test".
- It supports testing of interactive services like SOAP, which need to hold a 'conversation' with another HTTP server. It does this by launching an embedded Tomcat instance, and then registering 'listeners' which validate incoming requests and return specified responses. Apart from SOAP/web services testing, this allows one to 'unit test' a website: have an Ant script launch the webapp, test it and shut it down again.
Here's how you'd launch a Tomcat, and then send a query to it. Both the request and response are validated with <match> tags:
<servletContainer port="8101"/>
<http description="Test the regexp matcher"> <parallel> <listener path="/good.html"> <match> <method value="GET"/> <sendResponse href="test/responses/good.html" /> </match> </listener>
<sequential> <sleep seconds="1"/> <httpRequest path="/good.html"> <match> <regexp mustMatch="false" assign="n">exception</regexp> <!-- mustn't contain the text 'exception' --> <regexp assign="m"><![CDATA[.*<html>.*<body.*<p.*You sent the proper request.*</p>.*</body>.*</html>]]></regexp> </match> </httpRequest> </sequential> </parallel> </http>
Anteater cons: - Being based on Ant, Anteater is 'loosely typed', ie scripts aren't checked against a DTD. - It's not 1.0-quality yet. Ie, the README file is misleading, and you must symlink build/anteater-0.9.x to build/anteater in order to run the tests. The docs in CVS are rapidly approaching Latka quality, but not on the website yet, so it's best to learn by example (see test.xml). - I don't think there is any XML reporting mechanism beyond Ant's standard ability to attach project listeners, which may not provide sufficient detail (I haven't tested).
Btw, there's no reason why Anteater and Latka couldn't share a common API for 'validators'. I'd like to try this, but for now it's less effort just to duplicate them (there's not that many).
HTH,
--Jeff
_________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com





