Package org.apache.wicket.util.tester
Class WicketTestCase
- java.lang.Object
-
- org.apache.wicket.util.tester.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
-
-
Field Summary
Fields Modifier and Type Field Description WicketTester
tester
-
Constructor Summary
Constructors Constructor Description WicketTestCase()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
commonAfter()
void
commonBefore()
protected void
compareMarkupWithFile(IMarkupFragment markup, String filename, Class<?> scopeClass)
Compare the markup provided with the file contentprotected void
compareMarkupWithString(IMarkupFragment markup, String testMarkup)
Compare the markup provided with the Stringprotected void
executeBehavior(AbstractAjaxBehavior behavior, String filename)
protected void
executeListener(Component component, String filename)
protected <T extends Page>
voidexecuteTest(Class<T> pageClass, String filename)
Use-Dwicket.replace.expected.results=true
to automatically replace the expected output file.protected <T extends Page>
voidexecuteTest(Class<T> pageClass, PageParameters parameters, String filename)
Use-Dwicket.replace.expected.results=true
to automatically replace the expected output file.protected void
executeTest(Page page, String filename)
Use-Dwicket.replace.expected.results=true
to automatically replace the expected output file.String
getBasedir()
Returns the current Maven build directory taken from the basedir system property, or null if not setprotected WebApplication
newApplication()
protected WicketTester
newWicketTester(WebApplication app)
In case you need to subclass WicketTester and want to be independent on possible changes in setUp().
-
-
-
Field Detail
-
tester
public WicketTester tester
-
-
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, 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
-
executeListener
protected void executeListener(Component component, String filename) throws Exception
- Parameters:
component
-filename
-- Throws:
Exception
-
executeBehavior
protected void executeBehavior(AbstractAjaxBehavior behavior, String filename) throws Exception
- Parameters:
behavior
-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
-
-
-