Hi, There is nothing specific for Wizard components in WicketTester. WicketTester is in -core, Wizard is in -extensions. -core doesn't know about -extensions. Can't you test it like any other Panel ?
On Sat, Mar 10, 2012 at 12:13 AM, Dan Alvizu <dalv...@pingidentity.com> wrote: > Hi again, > > Sorry for the repost but I haven't been able to find a way through > WicketTester API to accomplish this, so I'm bumping this thread. > > Has anybody successfully written unit tests for the wizard? > > Thanks, > > Dan > > On Mon, Mar 5, 2012 at 2:34 PM, Dan Alvizu <dalv...@pingidentity.com> wrote: > >> Hi, >> >> I've got a wizard with 5 steps. If I want to test just step four, but do >> not want to go through steps 1 through 3 first, how would I do that? >> >> I found this message for wicket 1.4: >> >> http://osdir.com/ml/users-wicket.apache.org/2011-06/msg00498.html >> >> However, startPanel() is deprecated and replaced with >> startComponentInPage(). If I use this method, I will get an NPE in >> WizardSteps.onInitialize() method: >> >> >> >> java.lang.NullPointerException: null >> at >> org.apache.wicket.extensions.wizard.WizardStep.onInitialize(WizardStep.java:445) >> ~[wicket-extensions-1.5.4.jar:1.5.4] >> at org.apache.wicket.Component.fireInitialize(Component.java:920) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.MarkupContainer$4.component(MarkupContainer.java:1007) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.MarkupContainer$4.component(MarkupContainer.java:1005) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:143) >> ~[wicket-util-1.5.4.jar:1.5.4] >> at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:122) >> ~[wicket-util-1.5.4.jar:1.5.4] >> at org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:191) >> ~[wicket-util-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:923) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.MarkupContainer.internalInitialize(MarkupContainer.java:1003) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at org.apache.wicket.Page.internalPrepareForRender(Page.java:278) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at org.apache.wicket.Component.render(Component.java:2282) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at org.apache.wicket.Page.renderPage(Page.java:1041) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.handler.render.WebPageRenderer.renderPage(WebPageRenderer.java:105) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.handler.render.WebPageRenderer.respond(WebPageRenderer.java:224) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.handler.RenderPageRequestHandler.respond(RenderPageRequestHandler.java:167) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:781) >> ~[wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) >> ~[wicket-request-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:255) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:212) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:283) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:650) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.processRequest(BaseWicketTester.java:570) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:780) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.startPage(BaseWicketTester.java:796) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.startComponentInPage(BaseWicketTester.java:1400) >> [wicket-core-1.5.4.jar:1.5.4] >> at >> org.apache.wicket.util.tester.BaseWicketTester.startComponentInPage(BaseWicketTester.java:1336) >> [wicket-core-1.5.4.jar:1.5.4] >> >> [...] >> >> Sure enough, in org.apache.wicket.extensions.wizard.WizardStep.java, >> there's an attempt to find the Form parent which will not exist: >> >> @Override >> >> protected void onInitialize() >> >> { >> >> super.onInitialize(); >> >> >> Form<?> form = findParent(Form.class); >> >> form.add(formValidatorWrapper); // NPE here, form will be null >> >> } >> >> >> Is there a preferred way to do this without patching BaseWicketTester? >> >> Thanks, >> >> Dan >> >> >> -- Martin Grigorov jWeekend Training, Consulting, Development http://jWeekend.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org