Example usage for org.apache.wicket.util.tester DiffUtil validatePage

List of usage examples for org.apache.wicket.util.tester DiffUtil validatePage

Introduction

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

Prototype

public static boolean validatePage(String document, final Class<?> clazz, final String file,
        boolean failWithAssert) throws IOException 

Source Link

Document

Compare the output generated by Wicket ("document") with the a previously generated file which contains the expected result.

Usage

From source file:org.wicketstuff.datetime.extensions.yui.calendar.DatePickerTest.java

License:Apache License

/**
 * Use <code>-Dwicket.replace.expected.results=true</code> to automatically replace the expected
 * output file.//from   w  w w . j a va  2s.  c  o  m
 * 
 * @param <T>
 * 
 * @param pageClass
 * @param filename
 * @throws Exception
 */
protected <T extends Page> void myTestExecution(final Class<T> pageClass, final String filename)
        throws Exception {
    System.out.println("=== " + pageClass.getName() + " ===");

    tester.getSession().setLocale(Locale.ITALIAN);
    tester.startPage(pageClass);
    tester.assertRenderedPage(pageClass);

    String document = tester.getLastResponseAsString();
    document = document.replaceAll("\\d\\d\\.\\d\\d\\.\\d\\d", "xx.xx.xx");
    document = document.replaceAll("\\d\\d/\\d\\d/\\d\\d\\d\\d", "xx/xx/xxxx");
    document = document.replaceAll("\\d\\d/\\d\\d/\\d\\d", "xx/xx/xx");
    document = document.replaceAll("\\d\\d/\\d\\d\\d\\d", "xx/xxxx");

    DiffUtil.validatePage(document, pageClass, filename, true);
}