Differences between revisions 1 and 2
Revision 1 as of 2009-04-10 13:04:10
Size: 1696
Editor: 86
Revision 2 as of 2009-09-20 23:20:02
Size: 1696
Editor: localhost
Comment: converted to 1.6 markup
No differences found!

You need a new version of org.apache.tapestry5.test.PageTester which creates the SpringContext itself.

package mypackage.test;

import org.apache.tapestry5.test.PageTester;
import org.apache.tapestry5.internal.spring.SpringModuleDef;
import org.apache.tapestry5.ioc.def.ModuleDef;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class PageTesterSpring extends PageTester {

    public PageTesterSpring(String appPackage, String appName) {
        super(appPackage, appName);

    public PageTesterSpring(String appPackage, String appName, String contextPath, Class... moduleClasses){
        super(appPackage, appName, contextPath, moduleClasses);

    protected ModuleDef[] provideExtraModuleDefs() {
        ApplicationContext springContext = new ClassPathXmlApplicationContext(new String[]{"applicationContext.xml"});
        return new ModuleDef[]{ new SpringModuleDef(springContext) };

Then you can use your PageTesterSpring just like the PageTester:

package mypackage.test.frontend.pages;

import org.apache.tapestry5.dom.Document;
import mypackage.PageTesterSpring;
import org.testng.Assert;
import org.testng.annotations.Test;

public class Index extends Assert {

    public void test1() {       
        String appPackage = "mypackage.frontend";
        String appName = "app";
        PageTesterSpring tester = new PageTesterSpring(appPackage, appName, "WebContent");

        Document doc = tester.renderPage("Index");
        assertEquals(doc.getElementById("id1").getChildMarkup(), "hello");

Tapestry5-TestWithTapestry-Spring (last edited 2009-09-20 23:20:02 by localhost)