<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
   <channel>
      <title>Arthur Bogaart</title>
      <link>http://blogs.onehippo.org/arthur/</link>
      <description>HIPPO \\ </description>
      <language>en</language>
      <copyright>Copyright 2009</copyright>
      <lastBuildDate>Mon, 16 Feb 2009 13:40:18 +0100</lastBuildDate>
      <generator>http://www.sixapart.com/movabletype/?v=3.35</generator>
      <docs>http://blogs.law.harvard.edu/tech/rss</docs> 

            <item>
         <title>HippoCMS 7 integration testing with Selenium</title>
         <description><![CDATA[<p>Integration tests are designed to check the functionality of an application as a whole, rather than focussing on the internal workings of individual software modules, which is the domain of normal unit testing.</p>

<p><strong>Selenium</strong><br />
<a href="http://seleniumhq.org/" title="Selenium HQ">Selenium</a> is such a toolkit to create and run automated integration tests. In our latest sprint (<a href="https://svn.hippocms.org/repos/hippo/hippo-ecm/tags/Tag-HREPTWO-v2_04_00">M11</a>) we've used it to implemented a few simple test-cases.</p>

<p>* log in and out with different users<br />
* perform some simple document editing <br />
* create a new user and check if it is able to login</p>

<p><strong>Creating new tests</strong><br />
New tests can be created using the Selenium IDE plugin (Firefox only); simply open HippoCMS 7 in Firefox, start test-recording in Selenium IDE and follow your test-script. These tests can than be replayed during integration-testing using the Selenium Remote Control, which takes care of creating a new Firefox instance, running the tests and shutting Firefox down again.</p>

<p><strong>Stable markup ids</strong><br />
For Selenium to identify which DOM-element should be clicked or which text-field should be edited, it depends heavily on the id attribute of DOM-elements. This makes the presence of stable markup ids a must, meaning that a test should <em>always</em> be run with the same HTML as when it was recorded, or else it will fail for the wrong reasons.</p>

<p>Wicket however, and therefore HippoCMS 7, generates markup ids on the fly for Wicket components meaning they will differ from request to request, making them unsuitable for identifying a component in the browser DOM. To work around this problem <a href="https://www.ohloh.net/p/hippocms/contributors/23100481633955">Berry van Halderen</a> wrote a <a href="http://svn.hippocms.org/repos/hippo/hippo-ecm/tags/Tag-HREPTWO-v2_04_00/tools/testutils/wicket-selenium.patch">patch</a> that modifies the Wicket core in order to make it generate stable markup ids.</p>

<p><strong>Handling Ajax requests</strong><br />
As a first attempt of handling Ajax requests, we've implemented a rather blunt  approach: after sending an Ajax request, test for n seconds if a condition is met, like isTextPresent('Welcome to Hippo CMS'), else fail. In next sprints this will change by integrating Selenium with Wicket-Ajax and making it possible for WicketAjax to notify Selenium when a request has been handled.</p>

<p><strong>Running the tests</strong><br />
We currently run our tests using the <a href="http://geronimo.apache.org/maven/server/maven-plugins/selenium-maven-plugin/usage.html">Apache Geronimo selenium-maven-plugin</a> which deploys the <a href="http://www.onehippo.org/cms7//delve_into/sysadmin/installation/in_application_server.html">quickstart-ear </a> into <a href="https://glassfish.dev.java.net/">Glassfish</a>, starts Selenium, runs the tests, stop Selenium and undeploys the ear.</p>

<p>To get a better feeling of how this works out you can check out this video Arje Cahn made:<br />
<object width="400" height="225"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=3224560&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=3224560&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="225"></embed></object><br /><a href="http://vimeo.com/3224560">Use case testing with Selenium</a> from <a href="http://vimeo.com/user1231815">Arje Cahn</a> on <a href="http://vimeo.com">Vimeo</a>.</p>

<p><strong>More info</strong><br />
If you like to run the tests on your local machine or create some yourself, be sure to read more on the <a href="http://www.onehippo.org/cms7/integration_tests.html">documentation page</a> once it is online.</p>]]></description>
         <link>http://blogs.onehippo.org/arthur/2009/02/hippoecm_integration_testing_w.html</link>
         <guid>http://blogs.onehippo.org/arthur/2009/02/hippoecm_integration_testing_w.html</guid>
         <category>Hippo CMS</category>
         <pubDate>Mon, 16 Feb 2009 13:40:18 +0100</pubDate>
      </item>
            <item>
         <title>Back to Basic, or flowscript actually</title>
         <description><![CDATA[<p>Doing (complex) eventcached DASL queries without the <a href="http://wiki.hippo.nl/display/CMS/HippoJXTemplate+Reference">HippoJX generator</a> can be a tedious task. <br />
Clearly, the Cocoon Jxtemplate generator is a nice mechanism for a) passing sitemap parameters into the query and/or b) changing the semantics of the query based on the paramters values, but since it doesn't handle caching natively, the programmer has to use flowscript to create a custom cache-key from sitemap parameters and pass it into the Jxtemplate, together with a <a href="http://excalibur.apache.org/apidocs/org/apache/excalibur/source/impl/validity/NOPValidity.html">NOPValidity</a> object. This means 2 matchers for every DASL (since most DASL's require custom parameters) and a lot of <strong><u>extra work == bad</u></strong>!</p>

<p>So we created the <a href="http://wiki.hippo.nl/display/CMS/HippoJXTemplate+Reference">HippoJX generator</a> which produces cache-keys automatically from the sitemap parameters passed to it, and always uses a <a href="http://excalibur.apache.org/apidocs/org/apache/excalibur/source/SourceValidity.html">SourceValidity</a>. We can even specify what parameters should/shouldn't be used in the cache-key! </p>

<p>I've been updating an existing website still using the <em>old</em> flowscript->dasl scheme, to the new HippoJx solution, and found it very usefull and easy to set up.<br />
Untill..  I had to use a java.util.StringTokenizer inside my JXtemplate.</p>

<p>(from cocoon-dev discussion '<a href="http://marc2.theaimsgroup.com/?t=113835981400002&r=1&w=2">Java objects in JX templates</a>')</p>

<blockquote>packages, classes, constructors, static methods, constants is available in jxtg via rhino
...
Unfortunatelly in 2.1.x those variables  are only properly initialized 
when flowscript is the controller. 2.2 artificialy creates those 
variables no matter if you already have rhino context available or not.

<p>One more thing: this construct  ${java.util.StringTokenizer(items, delims)}  will work only when .jx is invoked from flow. This is due to the fact that neither JEXL nor JXPath is able to reference packages/create java <br />
objects. The functionality in fact is provided by Rhino library.This is already fixed for 2.2-dev (still the dependency on Rhino remains).<br />
</blockquote><br />
So I gues I'm back to wrapping (some) of my DASL call's with flowscript again, untill 2.2 is released..<br />
       </p>]]></description>
         <link>http://blogs.onehippo.org/arthur/2006/04/back_to_basic_or_flowscript_ac.html</link>
         <guid>http://blogs.onehippo.org/arthur/2006/04/back_to_basic_or_flowscript_ac.html</guid>
         <category>Cocoon</category>
         <pubDate>Tue, 18 Apr 2006 12:32:52 +0100</pubDate>
      </item>
      
   </channel>
</rss>
