Obviously make sure the page comes up in your web browser correctly first. Then I'd try to test and make sure it is able to load the page correctly. Something like:

                String appPackage = "or.test.test.myapp";
                String appName = "App";                                         
                                              
                PageTester tester = new PageTester(appPackage, appName);
        
                Document doc = tester.renderPage("TestPage1");
                assertNotNull(doc);
assertTrue(doc.toString().contains("test")); //Or any text you know is on the page

Also, if you are trying to run your test from within Eclipse, try running them directly in Maven (mvn test). I have some tests that won't run using the TestNG plugin, but work fine when done in Maven.

Mark

On Feb 23, 2008, at 12:06 AM, Angelo Chen wrote:


Hi,

I have this simple page that I'd like to test:

TestPage1.java:

public class TestPage1 {
        private String test;
        // getter/setter omitted
   TextStreamResponse onSuccess() {
      return new TextStreamResponse("text/html", test);
   }
}

TestPage1.tml:

<t:form >
   <input t:type="textField" t:id="test"/><br/>
        <input t:type="submit" t:id="submit" />
</t:form>

here is the test code:

        String appPackage = "org.test.test.myapp";
        String appName = "App";
        PageTester tester = new PageTester(appPackage, appName,
"src/main/webapp");

        Document doc = tester.renderPage("TestPage1");
        Element submitButton = doc.getElementById("submit");

        Map<String, String> fieldValues = new HashMap<String, String>();
        fieldValues.put("test", "abcdefg");
        doc = tester.clickSubmit(submitButton, fieldValues);

I got exception:
org.apache.tapestry.runtime.ComponentEventException: TestableResponse:
Method getOutputStream() not yet implemented. [at context:TestPage1.tml,
line 9, column 14]
        at
org .apache .tapestry .internal .structure .ComponentPageElementImpl .triggerContextEvent(ComponentPageElementImpl.java:1021)
        at
org .apache .tapestry .internal .services .ComponentEventRequestHandlerImpl .handle(ComponentEventRequestHandlerImpl.java:62)
        at org.apache...
        
How to make this work? Thanks,

A.C.
        
--
View this message in context: 
http://www.nabble.com/T5%3A-PageTester-and-TextStreamResponse-tp15648800p15648800.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to