Search in sources :

Example 1 with PageTester

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

the class TemplateInContextTest method template_in_web_context.

@Test
public void template_in_web_context() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
    Document doc = tester.renderPage("TestPageForTemplateInContext");
    assertTrue(doc.toString().contains("How are you?"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 2 with PageTester

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

the class UnlessTest method render.

@Test
public void render() {
    tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage("TestPageForUnless");
    assertNotNull(doc.getElementById("2"));
    assertNotNull(doc.getElementById("4"));
    assertNotNull(doc.getElementById("6"));
    assertNotNull(doc.getElementById("7"));
    assertNull(doc.getElementById("1"));
    assertNull(doc.getElementById("3"));
    assertNull(doc.getElementById("5"));
    assertNull(doc.getElementById("8"));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 3 with PageTester

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

the class PageTesterTest method setup.

@BeforeClass
public void setup() {
    nonEmptyAppNameTester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME, "src/test/app2");
    emptyAppNameTester = new PageTester(TestConstants.APP2_PACKAGE, "", "src/test/app2");
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with PageTester

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

the class PageTesterTest method on_activate_chain_is_followed.

@Test(dataProvider = "testers")
public void on_activate_chain_is_followed(PageTester tester) {
    Document launchDoc = tester.renderPage("Launch");
    Map<String, String> parameters = Collections.emptyMap();
    // Submit the form, which will then skip through Intermediate and
    // arrive at Final.
    Document finalDoc = tester.submitForm(launchDoc.getElementById("form"), parameters);
    assertEquals(finalDoc.getElementById("page-name").getChildMarkup(), "Final");
}
Also used : Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

Example 5 with PageTester

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

the class DTDTest method verify_correct_dtds.

@Test(dataProvider = "dtd_page_provider")
public void verify_correct_dtds(String pageName, String expectedDTD, String checkText) {
    PageTester tester = new PageTester(TestConstants.APP2_PACKAGE, TestConstants.APP2_NAME);
    Document doc = tester.renderPage(pageName);
    String txt = doc.toString();
    // use startsWith to make sure the DTD is getting into the right spot.
    assertTrue(txt.startsWith(expectedDTD));
    // we should also make sure that the other DTD's don't appear anywhere else...
    checkOtherDTD(txt, expectedDTD);
    // spot check the body of the pages to make sure they correctly rendered...
    // they should have, based on the unit tests for template rendering, but...
    assertTrue(txt.contains(checkText));
}
Also used : PageTester(org.apache.tapestry5.test.PageTester) Document(org.apache.tapestry5.dom.Document) Test(org.testng.annotations.Test)

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