You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Denis Kandrov <dk...@unipro.ru> on 2009/07/20 14:03:12 UTC

org.apache.wicket.protocol.http.WebSession cannot be cast to org.apache.wicket.authentication.AuthenticatedWebSession

Hi, All!

I'm trying to set up testing for my JavaEE&Wicket Application but ran across this error message:

org.apache.wicket.protocol.http.WebSession cannot be cast to org.apache.wicket.authentication.AuthenticatedWebSession

I'm using JUnitEE for run my tests at Application Server.
Also I found a couple of threads where the solution was to create an instance of ClientApplication and pass it to WicketTester: 
-------- 
tester = new WicketTester(new ClientApplication()); 
-------- 
It work fine, but this solution create many ClientApplication objects, that eat memory and creation of this objects take some time.
And also I have one ClientApplication, that deployed, created and runned at appServer.

How can I show to WicketTester my ClientApplication?

Denis.

Re: How test modal windows with wicket tester?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Be careful.. that will execute all callbacks, not just close callback.

This is safer:

  public void executeModalWindowCloseCallback(ModalWindow modalWindow) {
    for (IBehavior behavior : modalWindow.getBehaviors()) {
      if (behavior instanceof AbstractDefaultAjaxBehavior) {
        String name = behavior.getClass().getSimpleName();
        if (name.startsWith("WindowClosedBehavior")) {
          tester.executeBehavior((AbstractAjaxBehavior) behavior);
        }
      }
    }
  }

  public void executeModalWindowCloseButtonCallback(ModalWindow modalWindow) {
    for (IBehavior behavior : modalWindow.getBehaviors()) {
      if (behavior instanceof AbstractDefaultAjaxBehavior) {
        String name = behavior.getClass().getSimpleName();
        if (name.startsWith("CloseButtonBehavior")) {
          tester.executeBehavior((AbstractAjaxBehavior) behavior);
        }
      }
    }
  }


**
Martin

2009/9/9 Per Lundholm <pe...@gmail.com>:
>   /**
>     * Execute a close on a modal window.
>     */
>    private void executeClose() {
>
>        ModalWindow window = (ModalWindow)
> tester.getComponentFromLastRenderedPage(MODAL);
>
>        tester.clickLink(MODAL + ":content:closeOK", true);
>
>        List<IBehavior> behaviors = window.getBehaviors();
>        for (IBehavior behavior : behaviors) {
>            if (behavior instanceof AbstractAjaxBehavior) {
>                tester.executeBehavior((AbstractAjaxBehavior) behavior);
>            }
>        }
>    }
>
>
> 2009/9/8 Martin Makundi <ma...@koodaripalvelut.com>
>
>> Hi!
>>
>> There is nothing special in testing modal windows. It is just a panel
>> with a panel inside. You can use tester.assertVisible...
>>
>> THe only trick is if you have windowCloseCallbacks.. you need to
>> invoke those manually using tester.executeBehavior...
>>
>> **
>> Martin
>>
>> 2009/9/8 Denis Kandrov <dk...@unipro.ru>:
>> > I have dashboard, that have modal windows for adding comments and view
>> > dashboard message.
>> >
>> > How can I get this modal window for testing with wicket tester?
>> > And how to check that modal window is opened?
>> >
>> > Denis.
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> > For additional commands, e-mail: users-help@wicket.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>

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


Re: How test modal windows with wicket tester?

Posted by Per Lundholm <pe...@gmail.com>.
   /**
     * Execute a close on a modal window.
     */
    private void executeClose() {

        ModalWindow window = (ModalWindow)
tester.getComponentFromLastRenderedPage(MODAL);

        tester.clickLink(MODAL + ":content:closeOK", true);

        List<IBehavior> behaviors = window.getBehaviors();
        for (IBehavior behavior : behaviors) {
            if (behavior instanceof AbstractAjaxBehavior) {
                tester.executeBehavior((AbstractAjaxBehavior) behavior);
            }
        }
    }


2009/9/8 Martin Makundi <ma...@koodaripalvelut.com>

> Hi!
>
> There is nothing special in testing modal windows. It is just a panel
> with a panel inside. You can use tester.assertVisible...
>
> THe only trick is if you have windowCloseCallbacks.. you need to
> invoke those manually using tester.executeBehavior...
>
> **
> Martin
>
> 2009/9/8 Denis Kandrov <dk...@unipro.ru>:
> > I have dashboard, that have modal windows for adding comments and view
> > dashboard message.
> >
> > How can I get this modal window for testing with wicket tester?
> > And how to check that modal window is opened?
> >
> > Denis.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How test modal windows with wicket tester?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Yes.. you need to check the panel INSIDE the modal panel.

And a hint: avoid using string paths to the maximum... you'll have
more flexibility in refactoring. Just do like this:

MessageTabs tabs = (MessageTabs) tester.getLastRenderedPage();
Panel panel = tabs.getPanel();
Company company = panel.getCompany();
CommentForm form = company.getForm();
ModalWindow modalWindow = form.getCommentCreateModal();
// Assert visibility
tester.assertInvisible(modalWindow.getPageRelativePath() + ":" +
modalWindow.getContentId());

**
Martin

2009/9/10 Denis Kandrov <dk...@unipro.ru>:
> Hi, Martin!
> I try use
>  tester.assertVisible("messageTabs:panel:company:commentForm:commentCreateModal")
> where
>  messageTabs:panel:company:commentForm:commentCreateModal  is
> my.app.class.NotificationModalWindow
> where
>  NotificationModalWindow extends ModalWindow.
>
> But it not work, "messageTabs:panel:company:commentForm:commentCreateModal"
> is always visible..
>
> Denis.
>
> Martin Makundi пишет:
>>
>> Hi!
>>
>> There is nothing special in testing modal windows. It is just a panel
>> with a panel inside. You can use tester.assertVisible...
>>
>> THe only trick is if you have windowCloseCallbacks.. you need to
>> invoke those manually using tester.executeBehavior...
>>
>> **
>> Martin
>>
>> 2009/9/8 Denis Kandrov <dk...@unipro.ru>:
>>
>>>
>>> I have dashboard, that have modal windows for adding comments and view
>>> dashboard message.
>>>
>>> How can I get this modal window for testing with wicket tester?
>>> And how to check that modal window is opened?
>>>
>>> Denis.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How test modal windows with wicket tester?

Posted by Denis Kandrov <dk...@unipro.ru>.
Hi, Martin!
I try use
  
tester.assertVisible("messageTabs:panel:company:commentForm:commentCreateModal")
where
  messageTabs:panel:company:commentForm:commentCreateModal  is   
my.app.class.NotificationModalWindow
where
  NotificationModalWindow extends ModalWindow.

But it not work, 
"messageTabs:panel:company:commentForm:commentCreateModal" is always 
visible..

Denis.

Martin Makundi пишет:
> Hi!
>
> There is nothing special in testing modal windows. It is just a panel
> with a panel inside. You can use tester.assertVisible...
>
> THe only trick is if you have windowCloseCallbacks.. you need to
> invoke those manually using tester.executeBehavior...
>
> **
> Martin
>
> 2009/9/8 Denis Kandrov <dk...@unipro.ru>:
>   
>> I have dashboard, that have modal windows for adding comments and view
>> dashboard message.
>>
>> How can I get this modal window for testing with wicket tester?
>> And how to check that modal window is opened?
>>
>> Denis.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>     
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>   


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


Re: How test modal windows with wicket tester?

Posted by Martin Makundi <ma...@koodaripalvelut.com>.
Hi!

There is nothing special in testing modal windows. It is just a panel
with a panel inside. You can use tester.assertVisible...

THe only trick is if you have windowCloseCallbacks.. you need to
invoke those manually using tester.executeBehavior...

**
Martin

2009/9/8 Denis Kandrov <dk...@unipro.ru>:
> I have dashboard, that have modal windows for adding comments and view
> dashboard message.
>
> How can I get this modal window for testing with wicket tester?
> And how to check that modal window is opened?
>
> Denis.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


How test modal windows with wicket tester?

Posted by Denis Kandrov <dk...@unipro.ru>.
I have dashboard, that have modal windows for adding comments and view 
dashboard message.

How can I get this modal window for testing with wicket tester?
And how to check that modal window is opened?

Denis.


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