Example usage for org.apache.wicket.util.tester WicketTesterHelper asLined

List of usage examples for org.apache.wicket.util.tester WicketTesterHelper asLined

Introduction

In this page you can find the example usage for org.apache.wicket.util.tester WicketTesterHelper asLined.

Prototype

public static String asLined(final Collection<?> objects) 

Source Link

Document

A toString method for the given Collection.

Usage

From source file:ca.travelagency.BaseWicketTester.java

License:Apache License

protected void assertNoSuccessMessage() {
    List<Serializable> messages = tester.getMessages(FeedbackMessage.SUCCESS);
    Assert.assertTrue("expect no success message, but contains\n" + WicketTesterHelper.asLined(messages),
            messages.isEmpty());/*from w ww. jav  a2  s.com*/
}

From source file:fiftyfive.wicket.test.WicketTestUtils.java

License:Apache License

/**
 * Assert that the last rendered page has a content-type of text/html
 * and is valid markup. Will autodetect whether the document is HTML5 or
 * XHTML and use the appropriate validator. An HTML5 document must start
 * with {@code <!DOCTYPE html>}, anything else is assumed to be XHTML.
 *
 * @param tester A WicketTester object that has just rendered a page.
 * @param linesContext The number of lines of context to include around
 *                     each validation error.
 *//* www .jav  a  2 s  .c  o m*/
public static void assertValidMarkup(WicketTester tester, int linesContext) throws IOException {
    String type = tester.getLastResponse().getContentType();
    Assert.assertNotNull("Content type of rendered Wicket page cannot be null", type);
    Assert.assertTrue("Content type of rendered Wicket page must be text/html",
            type.equals("text/html") || type.startsWith("text/html;"));

    String document = document(tester);
    AbstractDocumentValidator validator = validator(document);
    if (linesContext >= 0) {
        validator.setNumLinesContext(linesContext);
    }

    validator.parse(document);

    if (!validator.isValid()) {
        Assert.fail(String.format("Invalid HTML:%n%s", WicketTesterHelper.asLined(validator.getErrors())));
    }
}

From source file:gr.interamerican.wicket.test.WicketTest.java

License:Open Source License

/**
 * Common assertions when error message is expected.
 * @param errorMessagePortion /*from ww  w  . ja v a  2s .co m*/
 */
protected void commonAssertions_error(String errorMessagePortion) {
    String messages = WicketTesterHelper.asLined(tester.getMessages(FeedbackMessage.ERROR));
    Assert.assertNotNull(messages);
    Assert.assertTrue(messages.contains(errorMessagePortion));
    Assert.assertTrue(tester.getLastRenderedPage() instanceof TestPage);
    Assert.assertEquals(HttpServletResponse.SC_OK, tester.getResponse().getStatus());
}