Try with org.apache.wicket.util.tester.BaseWicketTester.startPage(Class<C>,
PageParameters)
Put all parameters in the PageParameters instance

On Tue, Nov 2, 2010 at 1:14 PM, Stefan.Holzmueller <
[email protected]> wrote:

> Hello,
>
> we are wondering about a valid test setup - perhaps somebody is able to
> help us with it. Our approaches to write a test failed because our
> WebApplication's newSession() seem to be called whenever we create a
> WicketTester and before we are able to set any request parameters.
>
> Our setting is as follows: The application is started by a link that
> contains an HTTP GET parameter. We have extended SwarmWebApplication and
> implemented its newSession() so that the request's parameters are evaluated.
> The return value of this method is our custom Session that stores the
> initial parameter.
>
> Now we have a test like this:
>
> ----------------
> Map<String, String[]> params = new HashMap<String, String[]>();
> params.put("id", "1234567");
> WicketTester wicketTester = new WicketTester(ourApplication); // seems to
> call newSession() already
> wicketTester.setParametersForNextRequest(params);
> wicketTester.startPage(HomePage.class);
> ----------------
>
> And the application code looks like this:
> ----------------
> public class OurWebApplication extends SwarmWebApplication {
>
> [...]
>
>  @Override
>  public NewsletterSession newSession(Request request, Response response) {
>    String id = request.getParameter("id"); // is null in test setting,
> otherwise it works
>    [...]
>  }
> }
> ----------------
>
> Any clue on how to pass the initial request parameters to WicketTester? The
> productive code seems to work (checked that with some logging output), but
> we'd like to create a valid test case.
>
> Your advice would be very much appreciated. We are probably not aware of
> some pitfalls in WicketTester and how to deal with them.
>
> Cheers,
> Björn and Stefan
>
>
> --
> BRANDAD Systems AG
> Gebhardtstraße 5
> 90762 Fürth
>
> Fon +49 (0) 911 756658 - 0
> Fax +49 (0) 911 756658 - 88
> www.brandad-systems.de
>
> Vorstand: Joachim Stelzer
> Vorsitzender des Aufsichtsrats: Dr. Ottheinz Jung-Senssfelder
> Registergericht Fürth, Handelsregister-Nummer: HRB 11435
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to