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

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

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

duk_e
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.
Reply | Threaded
Open this post in threaded view
|

How test modal windows with wicket tester?

duk_e
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: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How test modal windows with wicket tester?

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 <[hidden email]>:

> 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: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How test modal windows with wicket tester?

Per Lundholm
   /**
     * 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 <[hidden email]>

> 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 <[hidden email]>:
> > 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: [hidden email]
> > For additional commands, e-mail: [hidden email]
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>
Reply | Threaded
Open this post in threaded view
|

Re: How test modal windows with wicket tester?

Martin Makundi
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 <[hidden email]>:

>   /**
>     * 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 <[hidden email]>
>
>> 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 <[hidden email]>:
>> > 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: [hidden email]
>> > For additional commands, e-mail: [hidden email]
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How test modal windows with wicket tester?

duk_e
In reply to this post by Martin Makundi
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 <[hidden email]>:
>  
>> 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: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>>    
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How test modal windows with wicket tester?

Martin Makundi
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 <[hidden email]>:

> 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 <[hidden email]>:
>>
>>>
>>> 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: [hidden email]
>>> For additional commands, e-mail: [hidden email]
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]
>> For additional commands, e-mail: [hidden email]
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]