You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Bjørn Grønbæk <bj...@endomondo.com> on 2012/02/09 21:59:54 UTC

Very simple Wicket test to verify panel type...

Hi,

I'm just starting out with Wicket and WicketTester...

I have a page that adds one of several panels, depending of its
PageParameter. I would like to verify that behaviour with WicketTester...
but how to?

The code is something like this:

        String type = null;
        Panel p = null;

        if(getPageParameters() != null)
            type = getPageParameters().getString("BRAND_TYPE");

        if(type != null && type.equals("BRAND"))
            p = new PanelA(id);
        else
            p = new PanelB(id);
         add(p);

I've tried something like this:

wicketTester.startPage(CreatePage.class);
wicketTester.assertRenderedPage(CreatePage.class);
wicketTester.assertComponent(":panelid",PanelA.class);

but that doesn't work. The test fails with this message:
junit.framework.AssertionFailedError: component 'CreatePage' is not
type:PanelA

Am I using the AssertComponent in a wrong way?
How else can I perform a test like that?
Could you point me to a good resource on how I find the path to components?


-- 

Best Regard

Bjørn Grønbæk

Software Engineer

m: bjorn.gronbaek@endomondo.com <fi...@endomondo.com>
p: +45 22669501
w: *www.endomondo.com* <http://www.endomondo.com/>
t: *www.twitter.com/endomondo* <http://www.twitter.com/endomondo>
f:* **www.facebook.com/endomondo* <http://www.facebook.com/endomondo>
e: www.endomondo.com/profile/406738 <http://www.endomondo.com/profile/your>

Re: Very simple Wicket test to verify panel type...

Posted by Bjørn Grønbæk <bj...@endomondo.com>.
Hi Hans and Martin.

The dump and debugComponentTrees was exactly what I was looking for. My
pages inherit from other pages, which of course made my panels have id's
like: topcontainer:subcontainer:panelid.

I'll check out the other tools as well.

Thanks alot.

BG

On 10 February 2012 08:54, Martin Grigorov <mg...@apache.org> wrote:

> Hi
>
> One way to see the component paths is:
> org.apache.wicket.util.tester.BaseWicketTester#debugComponentTrees
>
> Another way is by using DebugBar from wicket-devutils. At
> http://www.wicket-library.com/wicket-examples/forminput , in the
> top-right corner there is a link "Inspector", click it and it will
> show you more info, check "Page" section.
>
> On Thu, Feb 9, 2012 at 10:59 PM, Bjørn Grønbæk
> <bj...@endomondo.com> wrote:
> > Hi,
> >
> > I'm just starting out with Wicket and WicketTester...
> >
> > I have a page that adds one of several panels, depending of its
> > PageParameter. I would like to verify that behaviour with WicketTester...
> > but how to?
> >
> > The code is something like this:
> >
> >        String type = null;
> >        Panel p = null;
> >
> >        if(getPageParameters() != null)
> >            type = getPageParameters().getString("BRAND_TYPE");
> >
> >        if(type != null && type.equals("BRAND"))
> >            p = new PanelA(id);
> >        else
> >            p = new PanelB(id);
> >         add(p);
> >
> > I've tried something like this:
> >
> > wicketTester.startPage(CreatePage.class);
> > wicketTester.assertRenderedPage(CreatePage.class);
> > wicketTester.assertComponent(":panelid",PanelA.class);
> >
> > but that doesn't work. The test fails with this message:
> > junit.framework.AssertionFailedError: component 'CreatePage' is not
> > type:PanelA
> >
> > Am I using the AssertComponent in a wrong way?
> > How else can I perform a test like that?
> > Could you point me to a good resource on how I find the path to
> components?
> >
> >
> > --
> >
> > Best Regard
> >
> > Bjørn Grønbæk
> >
> > Software Engineer
> >
> > m: bjorn.gronbaek@endomondo.com <fi...@endomondo.com>
> > p: +45 22669501
> > w: *www.endomondo.com* <http://www.endomondo.com/>
> > t: *www.twitter.com/endomondo* <http://www.twitter.com/endomondo>
> > f:* **www.facebook.com/endomondo* <http://www.facebook.com/endomondo>
> > e: www.endomondo.com/profile/406738 <
> http://www.endomondo.com/profile/your>
>
>
>
> --
> Martin Grigorov
> jWeekend
> Training, Consulting, Development
> http://jWeekend.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 

Best Regard

Bjørn Grønbæk

Software Engineer

m: bjorn.gronbaek@endomondo.com <fi...@endomondo.com>
p: +45 22669501
w: *www.endomondo.com* <http://www.endomondo.com/>
t: *www.twitter.com/endomondo* <http://www.twitter.com/endomondo>
f:* **www.facebook.com/endomondo* <http://www.facebook.com/endomondo>
e: www.endomondo.com/profile/406738 <http://www.endomondo.com/profile/your>

Re: Very simple Wicket test to verify panel type...

Posted by Martin Grigorov <mg...@apache.org>.
Hi

One way to see the component paths is:
org.apache.wicket.util.tester.BaseWicketTester#debugComponentTrees

Another way is by using DebugBar from wicket-devutils. At
http://www.wicket-library.com/wicket-examples/forminput , in the
top-right corner there is a link "Inspector", click it and it will
show you more info, check "Page" section.

On Thu, Feb 9, 2012 at 10:59 PM, Bjørn Grønbæk
<bj...@endomondo.com> wrote:
> Hi,
>
> I'm just starting out with Wicket and WicketTester...
>
> I have a page that adds one of several panels, depending of its
> PageParameter. I would like to verify that behaviour with WicketTester...
> but how to?
>
> The code is something like this:
>
>        String type = null;
>        Panel p = null;
>
>        if(getPageParameters() != null)
>            type = getPageParameters().getString("BRAND_TYPE");
>
>        if(type != null && type.equals("BRAND"))
>            p = new PanelA(id);
>        else
>            p = new PanelB(id);
>         add(p);
>
> I've tried something like this:
>
> wicketTester.startPage(CreatePage.class);
> wicketTester.assertRenderedPage(CreatePage.class);
> wicketTester.assertComponent(":panelid",PanelA.class);
>
> but that doesn't work. The test fails with this message:
> junit.framework.AssertionFailedError: component 'CreatePage' is not
> type:PanelA
>
> Am I using the AssertComponent in a wrong way?
> How else can I perform a test like that?
> Could you point me to a good resource on how I find the path to components?
>
>
> --
>
> Best Regard
>
> Bjørn Grønbæk
>
> Software Engineer
>
> m: bjorn.gronbaek@endomondo.com <fi...@endomondo.com>
> p: +45 22669501
> w: *www.endomondo.com* <http://www.endomondo.com/>
> t: *www.twitter.com/endomondo* <http://www.twitter.com/endomondo>
> f:* **www.facebook.com/endomondo* <http://www.facebook.com/endomondo>
> e: www.endomondo.com/profile/406738 <http://www.endomondo.com/profile/your>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Very simple Wicket test to verify panel type...

Posted by Hans Lesmeister <ha...@lessy-software.de>.
Hi,

"panelid" instead of ":panelid"?
You can dump the Component-Tree to the console with tester.dumpXXX


Am 09.02.12 21:59 schrieb "Bjørn Grønbæk" unter
<bj...@endomondo.com>:

> Hi,
> 
> I'm just starting out with Wicket and WicketTester...
> 
> I have a page that adds one of several panels, depending of its
> PageParameter. I would like to verify that behaviour with WicketTester...
> but how to?
> 
> The code is something like this:
> 
>         String type = null;
>         Panel p = null;
> 
>         if(getPageParameters() != null)
>             type = getPageParameters().getString("BRAND_TYPE");
> 
>         if(type != null && type.equals("BRAND"))
>             p = new PanelA(id);
>         else
>             p = new PanelB(id);
>          add(p);
> 
> I've tried something like this:
> 
> wicketTester.startPage(CreatePage.class);
> wicketTester.assertRenderedPage(CreatePage.class);
> wicketTester.assertComponent(":panelid",PanelA.class);
> 
> but that doesn't work. The test fails with this message:
> junit.framework.AssertionFailedError: component 'CreatePage' is not
> type:PanelA
> 
> Am I using the AssertComponent in a wrong way?
> How else can I perform a test like that?
> Could you point me to a good resource on how I find the path to components?
> 



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org