You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Dmitriy Neretin <dm...@googlemail.com> on 2013/05/07 17:24:01 UTC

How to unit test AttributeModifier

Hello,

Is it possible to unit test an AttributeModifier?

I have a simple component:

WebMarkupContainer container = new WebMarkupContainer("containerId");
container.add(new AttributeModifier("name", "anyDynamicValue"));

In the unit test:

WebMarkupContainer container = (WebMarkupContainer)
tester.getComponentFromLastRenderedPage("containerId");

Is it possible to get the modifier above? I can see it in the object state
(while debugging) but I have no idea how to get it to test an
anyDynamicValue...

Any ideas?

Regards,

Dmitriy

Re: How to unit test AttributeModifier

Posted by Dmitriy Neretin <dm...@googlemail.com>.
Thanks to all! It works now!
Am 08.05.2013 14:39 schrieb "Kees van Dieren" <in...@squins.com>:

> Another option is to use the TagTester:
>
> TagTester tester = wicketTester.getTagByWicketId("containerId");
>
> tester.getAttribute("name"); // returns: "anyDynamicValue"
>
>
>
>
> Best regards / Met vriendelijke groet,
>
> Kees van Dieren
> Squins IT Solutions BV
> Oranjestraat 30
> 2983 HS Ridderkerk
> The Netherlands
> Mobile: +31 (0)6 30413841
> www.squins.com
> Chamber of commerce Rotterdam: 24435103
>
>
> 2013/5/8 Martin Grigorov <mg...@apache.org>
>
> > Also check AttributeModifierTest in wicket-core/src/test/java/..
> >
> >
> > On Tue, May 7, 2013 at 5:31 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> > >wrote:
> >
> > > attribute modifiers are behaviors, so use
> > > component.getbehavior(AttributeModifier.class) to get it.
> > >
> > > -igor
> > >
> > > On Tue, May 7, 2013 at 8:24 AM, Dmitriy Neretin
> > > <dm...@googlemail.com> wrote:
> > > > Hello,
> > > >
> > > > Is it possible to unit test an AttributeModifier?
> > > >
> > > > I have a simple component:
> > > >
> > > > WebMarkupContainer container = new WebMarkupContainer("containerId");
> > > > container.add(new AttributeModifier("name", "anyDynamicValue"));
> > > >
> > > > In the unit test:
> > > >
> > > > WebMarkupContainer container = (WebMarkupContainer)
> > > > tester.getComponentFromLastRenderedPage("containerId");
> > > >
> > > > Is it possible to get the modifier above? I can see it in the object
> > > state
> > > > (while debugging) but I have no idea how to get it to test an
> > > > anyDynamicValue...
> > > >
> > > > Any ideas?
> > > >
> > > > Regards,
> > > >
> > > > Dmitriy
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > > For additional commands, e-mail: users-help@wicket.apache.org
> > >
> > >
> >
> >
> > --
> > Martin Grigorov
> > Wicket Training & Consulting
> > http://jWeekend.com <http://jweekend.com/>
> >
>

Re: How to unit test AttributeModifier

Posted by Kees van Dieren <in...@squins.com>.
Another option is to use the TagTester:

TagTester tester = wicketTester.getTagByWicketId("containerId");

tester.getAttribute("name"); // returns: "anyDynamicValue"




Best regards / Met vriendelijke groet,

Kees van Dieren
Squins IT Solutions BV
Oranjestraat 30
2983 HS Ridderkerk
The Netherlands
Mobile: +31 (0)6 30413841
www.squins.com
Chamber of commerce Rotterdam: 24435103


2013/5/8 Martin Grigorov <mg...@apache.org>

> Also check AttributeModifierTest in wicket-core/src/test/java/..
>
>
> On Tue, May 7, 2013 at 5:31 PM, Igor Vaynberg <igor.vaynberg@gmail.com
> >wrote:
>
> > attribute modifiers are behaviors, so use
> > component.getbehavior(AttributeModifier.class) to get it.
> >
> > -igor
> >
> > On Tue, May 7, 2013 at 8:24 AM, Dmitriy Neretin
> > <dm...@googlemail.com> wrote:
> > > Hello,
> > >
> > > Is it possible to unit test an AttributeModifier?
> > >
> > > I have a simple component:
> > >
> > > WebMarkupContainer container = new WebMarkupContainer("containerId");
> > > container.add(new AttributeModifier("name", "anyDynamicValue"));
> > >
> > > In the unit test:
> > >
> > > WebMarkupContainer container = (WebMarkupContainer)
> > > tester.getComponentFromLastRenderedPage("containerId");
> > >
> > > Is it possible to get the modifier above? I can see it in the object
> > state
> > > (while debugging) but I have no idea how to get it to test an
> > > anyDynamicValue...
> > >
> > > Any ideas?
> > >
> > > Regards,
> > >
> > > Dmitriy
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
>
> --
> Martin Grigorov
> Wicket Training & Consulting
> http://jWeekend.com <http://jweekend.com/>
>

Re: How to unit test AttributeModifier

Posted by Martin Grigorov <mg...@apache.org>.
Also check AttributeModifierTest in wicket-core/src/test/java/..


On Tue, May 7, 2013 at 5:31 PM, Igor Vaynberg <ig...@gmail.com>wrote:

> attribute modifiers are behaviors, so use
> component.getbehavior(AttributeModifier.class) to get it.
>
> -igor
>
> On Tue, May 7, 2013 at 8:24 AM, Dmitriy Neretin
> <dm...@googlemail.com> wrote:
> > Hello,
> >
> > Is it possible to unit test an AttributeModifier?
> >
> > I have a simple component:
> >
> > WebMarkupContainer container = new WebMarkupContainer("containerId");
> > container.add(new AttributeModifier("name", "anyDynamicValue"));
> >
> > In the unit test:
> >
> > WebMarkupContainer container = (WebMarkupContainer)
> > tester.getComponentFromLastRenderedPage("containerId");
> >
> > Is it possible to get the modifier above? I can see it in the object
> state
> > (while debugging) but I have no idea how to get it to test an
> > anyDynamicValue...
> >
> > Any ideas?
> >
> > Regards,
> >
> > Dmitriy
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>


-- 
Martin Grigorov
Wicket Training & Consulting
http://jWeekend.com <http://jweekend.com/>

Re: How to unit test AttributeModifier

Posted by Igor Vaynberg <ig...@gmail.com>.
attribute modifiers are behaviors, so use
component.getbehavior(AttributeModifier.class) to get it.

-igor

On Tue, May 7, 2013 at 8:24 AM, Dmitriy Neretin
<dm...@googlemail.com> wrote:
> Hello,
>
> Is it possible to unit test an AttributeModifier?
>
> I have a simple component:
>
> WebMarkupContainer container = new WebMarkupContainer("containerId");
> container.add(new AttributeModifier("name", "anyDynamicValue"));
>
> In the unit test:
>
> WebMarkupContainer container = (WebMarkupContainer)
> tester.getComponentFromLastRenderedPage("containerId");
>
> Is it possible to get the modifier above? I can see it in the object state
> (while debugging) but I have no idea how to get it to test an
> anyDynamicValue...
>
> Any ideas?
>
> Regards,
>
> Dmitriy

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