Class WicketTestCase


  • public abstract class WicketTestCase
    extends Object
    Base class for tests which require comparing wicket response with a file.

    To create/replace the expected result file with the new content, define the system property like -Dwicket.replace.expected.results=true

    • Constructor Detail

      • WicketTestCase

        public WicketTestCase()
    • Method Detail

      • commonBefore

        @BeforeEach
        public void commonBefore()
      • newApplication

        protected WebApplication newApplication()
        Returns:
        the application that should be used for the test
      • newWicketTester

        protected WicketTester newWicketTester​(WebApplication app)
        In case you need to subclass WicketTester and want to be independent on possible changes in setUp().
        Parameters:
        app -
        Returns:
        WIcketTester
      • commonAfter

        @AfterEach
        public void commonAfter()
      • executeTest

        protected <T extends Page> void executeTest​(Class<T> pageClass,
                                                    String filename)
                                             throws Exception
        Use -Dwicket.replace.expected.results=true to automatically replace the expected output file.
        Type Parameters:
        T -
        Parameters:
        pageClass -
        filename -
        Throws:
        Exception
      • executeTest

        protected void executeTest​(Page page,
                                   String filename)
                            throws Exception
        Use -Dwicket.replace.expected.results=true to automatically replace the expected output file.
        Parameters:
        page -
        filename -
        Throws:
        Exception
      • executeTest

        protected <T extends Page> void executeTest​(Class<T> pageClass,
                                                    org.apache.wicket.request.mapper.parameter.PageParameters parameters,
                                                    String filename)
                                             throws Exception
        Use -Dwicket.replace.expected.results=true to automatically replace the expected output file.
        Type Parameters:
        T -
        Parameters:
        pageClass -
        parameters -
        filename -
        Throws:
        Exception
      • getBasedir

        public String getBasedir()
        Returns the current Maven build directory taken from the basedir system property, or null if not set
        Returns:
        path with a trailing slash
      • compareMarkupWithFile

        protected final void compareMarkupWithFile​(IMarkupFragment markup,
                                                   String filename,
                                                   Class<?> scopeClass)
                                            throws IOException
        Compare the markup provided with the file content
        Parameters:
        markup -
        filename -
        scopeClass -
        Throws:
        IOException
      • compareMarkupWithString

        protected final void compareMarkupWithString​(IMarkupFragment markup,
                                                     String testMarkup)
        Compare the markup provided with the String
        Parameters:
        markup -
        testMarkup -