1. Start Spring application context for your Tapestry unit tests

    Tapestry has a powerful tool to unit test your pages and services, but how to deal with it when your pages and services use Spring beans ?

    Tapestry PageTester can be extended like the TapestryFilter to provide your own ServiceModuleDef classes.  The tapestry-spring contribution already provides the one needed to load a Spring application context. Then, loading Spring for your unit tests will be as simple as extended the existing PageTester and provide the Tapestry Spring Module Definition class.

    Also, because this module definition uses the servlet application context to get the configuration files location, we will have to mock it. Let’s use Spring MockServletContext for this.

    • Update your maven dependencies to add spring web mock objects
      <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-test</artifactId>
        <version>${spring-version}</version>
      </dependency>
    
    • Extend Tapestry PageTester, adapt the code below to your needs if you want to provide mock versions of your spring beans or make it more configurable
    public class WookiPageTester extends PageTester
    {
    
     private MockServletContext servletContext;
    
     public WookiPageTester(String appPackage, String appName, String contextPath,
     Class... moduleClasses)
     {
       super(appPackage, appName, contextPath, moduleClasses);
       Registry registry = this.getRegistry();
       // Set Tapestry registry in mock servlet context
       servletContext.setAttribute(TapestryFilter.REGISTRY_CONTEXT_NAME, registry);
     }
    
     public WookiPageTester(String appPackage, String appName)
     {
       super(appPackage, appName);
     }
    
     @Override
     protected ModuleDef[] provideExtraModuleDefs()
     {
       // Set spring configuration files location
       servletContext = new MockServletContext();
       servletContext.addInitParameter("contextConfigLocation", "classpath*:mock-applicationContext.xml");
       return new ModuleDef[] { new SpringModuleDef(servletContext) };
     }
    
    }
    

    Thanks for reading !

  2. Wooki 0.3 is out !

    After a few months of hard work to extract re-usable components from Wooki, the version 0.3 is finally out !

    Along with Wooki improvements, we have created three major spin-off contributions that put the basis for a strong architecture that will make Wooki evolutive and ready for production soon:

    • tapestry5-spring-tx allows you to benefit from Spring Platform Transaction management inside Tapestry
    • tapestry5-installer provides a way to easily deploy and install tapestry 5 application
    • tapestry5-db-migration, inspired from rails migrations, allows you to get full control over your database schema through your Tapestry 5 application lifecycle

    All this work justifies this wooki version. It has been the opportunity to validate and polishing these different contributions in a real context.

    Also the global code of Wooki has been reviewed to ease future evolutions and current features maintenance

    • Move to Tapestry 5.2 that make development with Tapestry more and more confortable
    • Integration of spring-acl to handle authorization on wooki’s resources
    • Creation of an abstraction layer to handle DB query parameters like range, created since
    • Centralize activity lookup for RSS feeds and front display
    • Centralize application link management and improve the application security layer

    To conclude, one important news is that wooki has moved to spreadthesource organization on github

    We hope you will find inspiration from all these as a user or a Tapestry developer ! Give it a try !

    Thanks for reading.