I reproduced this in a simple quickstart using this unit test:

@Test
public void testAjaxEventFired() throws Exception
{
   HomePage homePage = new HomePage( new PageParameters() );
   tester.startPage( homePage );

   FormTester formTester = tester.newFormTester( "form" );
   formTester.select( "radioChoice", 2 );

   Component component = tester.getComponentFromLastRenderedPage(
"form:radioChoice" );
   List<? extends Behavior> behaviors = component.getBehaviors();
   for( Behavior behavior : behaviors )
   {
      if( behavior instanceof AjaxFormChoiceComponentUpdatingBehavior )
      {
         AjaxFormChoiceComponentUpdatingBehavior afccub =
(AjaxFormChoiceComponentUpdatingBehavior) behavior;
         tester.executeBehavior( afccub );
      }
   }

   assertEquals( true, homePage.eventFired );
   assertEquals( "C", homePage.chosen );
}


This is working as expected.  HomePage has a RadioChoice with a
List<String> of choices, A,B,C,D,E.


There must be something in our application that's causing the
invocation to be rejected which Ill dig in to.


On Thu, Oct 30, 2014 at 4:27 PM, Andrea Del Bene <[email protected]>
wrote:

> On 30/10/14 21:08, Nick Pratt wrote:
>
>> Wicket 6.17.0
>>
>> I have a RadioChoice (in a Form) that has an attached
>> AjaxFormComponentUpdatingBehavior.
>>
>> The onUpdate() method of the Behavior fires an event for other components
>> on the page to update (change visibility depending on user selection in
>> radio choice).
>>
>> Im trying to unit test it using:
>>
>> formTester.selectRadioChoice( "propertyType", 2 );
>>
> I guess that's a typo :) or are you using a custom formTester?
>
>>
>> and then I'm trying to trigger the behavior to fire so that I can
>> check that the various components are visible/invisible:
>>
>> Component component = baseTester.getComponentFromLastRenderedPage(
>> "form:propertyType" );
>> for ( Behavior b : component.getBehaviors() )
>> {
>>     if ( b instanceof AjaxFormComponentUpdatingBehavior )
>>     {
>>        baseTester.executeBehavior( (AbstractAjaxBehavior) b );
>>     }
>> }
>>
>> However, I'm running in to this when the behavior is executed:
>>
>> org.apache.wicket.core.request.handler.ListenerInvocationNotAllowedEx
>> ception:
>> Behavior rejected interface invocation.
>>
>> Is it possible to unit test this specific behavior, and am I going
>> about this the right way?
>>
>> I've verified that the application works as expected in a browser.
>>
> BTW, multiple-choice component should use 
> AjaxFormChoiceComponentUpdatingBehavior
> instead of AjaxFormComponentUpdatingBehavior.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to