cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wojciech Biela <ilf...@gmail.com>
Subject Re: TDD with Cocoon?
Date Mon, 27 Jun 2005 12:08:58 GMT
> > Could you provide a pointer to this "Excalibur Test Suite" that you
> > mentioned?

OK, I dug some old code 
there's a 

import org.apache.avalon.excalibur.testcase.ExcaliburTestCase;
...
public class RegistrationDaoImplTest extends ExcaliburTestCase

which generally does the following

    public void testRegisterFail() throws Exception {
        HibernateHelper.clearDatabase();
        HibernateHelper.hibernateSave(createRegData());
        User existingData = createRegData();
        try {
            RegistrationDAO regDao = (RegistrationDAO)
lookup(RegistrationDAO.ROLE);
            regDao.register(existingData, new UserActivation(existingData));
            release((Component) regDao);
            fail();
        } catch (RegistrationException e) {
            /* it's OK */
        } 
    }

there is a .xtest file associated with this class: 

   <testcase>
     <annotation>RegistrationDaoTestCase !</annotation>

     <logkit log-level="DEBUG">
       <factories>
         <factory type="stream"
class="org.apache.avalon.excalibur.logger.factory.StreamTargetFactory"/>
       </factories>

       <targets>
         <stream id="root">
           <stream>System.out</stream>
           <format type="extended">
              %7.7{priority} %5.5{time}   [%8.8{category}]
(%{context}): %{message}\n%{throwable}
           </format>
         </stream>
         <stream id="console">
           <stream>System.out</stream>
           <format type="avalon">
             %7.7{priority} %23.23{time:yyyy-MM-dd' 'HH:mm:ss.SSS}
[%30.30{category}] (%{context}): %{message}\n%{throwable}
           </format>
         </stream>
       </targets>
       <categories>
         <category name="" log-level="DEBUG">
           <log-target id-ref="root"/>
         </category>
         <category name="test" log-level="DEBUG">
           <log-target id-ref="console"/>
         </category>
       </categories>
     </logkit>
     <contexts>
     </contexts>
     <roles>
     	<role name="net.sf.hibernate.avalon.HibernateService"
	    	 shorthand="hibernate"
default-class="pl.x.common.dao.ThreadSafeHibernateServiceImpl"/>
	    <role name="pl.x.account.dao.RegistrationDAO"
		    shorthand="reg-dao"
    		default-class="pl.x.account.dao.UserDAOImpl"/>
    </roles>
     <components>
     	<reg-dao id="reg-dao"  logger="test"/>
     	<hibernate id="hibernate"  logger="test"/>
     </components>
   </testcase>

as I see things are quite similar when extending the
SitemapComponentTestCase for our custom sitemap components.

hope that helps, as I recall we found our way through by patiently
exploring the Cocoon sources

-- 
Wojtek Biela

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message