Search in sources :

Example 6 with PageTester

use of org.apache.tapestry5.test.PageTester in project tapestry-5 by apache.

the class HeadTest method display.

@Test
public void display() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage("TestPageForHead");
    assertTrue(doc.toString().contains("OK"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 7 with PageTester

use of org.apache.tapestry5.test.PageTester in project tapestry-5 by apache.

the class ASOTest method submit_aso.

@Test
public void submit_aso() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage("TestPageForASO");
    assertTrue(doc.toString().contains("bar"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 8 with PageTester

use of org.apache.tapestry5.test.PageTester in project tapestry-5 by apache.

the class PageTesterModule method setupTestableOverrides.

@Contribute(ServiceOverride.class)
public static void setupTestableOverrides(MappedConfiguration<Class, Object> configuration, @Local TestableRequest request, @Local TestableResponse response, final ObjectLocator locator) {
    configuration.add(Request.class, request);
    configuration.add(Response.class, response);
    TestableCookieSinkSource cookies = new TestableCookieSinkSource();
    configuration.add(CookieSink.class, cookies);
    configuration.add(CookieSource.class, cookies);
    // With the significant changes to the handling of assets in 5.4, we introduced a problem:
    // We were checking at page render time whether to generate URLs for normal or compressed
    // assets and that peeked at the HttpServletRequest global, which isn't set up by PageTester.
    // What we're doing here is using a hacked version of that code to force GZip support
    // on.
    configuration.add(ResponseCompressionAnalyzer.class, new ResponseCompressionAnalyzer() {

        public boolean isGZipEnabled(ContentType contentType) {
            return locator.getObject(CompressionAnalyzer.class, null).isCompressable(contentType.getMimeType());
        }

        public boolean isGZipSupported() {
            return true;
        }
    });
}
Also used : ContentType(org.apache.tapestry5.http.ContentType) ResponseCompressionAnalyzer(org.apache.tapestry5.http.services.ResponseCompressionAnalyzer) Contribute(org.apache.tapestry5.ioc.annotations.Contribute)

Example 9 with PageTester

use of org.apache.tapestry5.test.PageTester in project tapestry-5 by apache.

the class PageTesterTest method setupRequestFromURI_accepts_query_strings.

@Test
public void setupRequestFromURI_accepts_query_strings() {
    PageTester pageTester = new PageTester("org.example.app1", "app1");
    pageTester.setupRequestFromURI("/foo/somePage?param=value");
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Test(org.testng.annotations.Test)

Example 10 with PageTester

use of org.apache.tapestry5.test.PageTester in project tapestry5-hotel-booking by ccordenier.

the class BaseUnitTestSuite method setup.

@BeforeClass
public void setup() {
    pageTester = new PageTester("com.tap5.hotelbooking", "hotel-booking", "src/main/webapp");
    registry = pageTester.getRegistry();
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

PageTester (org.apache.tapestry5.test.PageTester)16 Test (org.testng.annotations.Test)14 Document (org.apache.tapestry5.dom.Document)12 Element (org.apache.tapestry5.dom.Element)2 BeforeClass (org.testng.annotations.BeforeClass)2 List (java.util.List)1 ContentType (org.apache.tapestry5.http.ContentType)1 ResponseCompressionAnalyzer (org.apache.tapestry5.http.services.ResponseCompressionAnalyzer)1 TestableResponse (org.apache.tapestry5.internal.test.TestableResponse)1 Contribute (org.apache.tapestry5.ioc.annotations.Contribute)1 SymbolSource (org.apache.tapestry5.ioc.services.SymbolSource)1 Test (org.junit.Test)1 BeforeMethod (org.testng.annotations.BeforeMethod)1