Hi Alex

I guess you're right - I can use the Spring stuff only in the testing environment...will give it a shot.

Thanks for your help.

Regards,
Andy Barlow

On 16 Nov 2007, at 20:47, Alex Objelean wrote:


I am using the same approach for testing wicket components and it works like
charm. Though I'm using Spring for service injection, I do not see any
difference when it is about EJB services.

The whole idea of WicketTester, is to test it outside the container, so you can use EasyMock to mock your EJB service, thus simulate anything in order
to test wicket components.

Alex.


Andy Barlow [Deftex] wrote:

Thanks Alex

That would of course resolve the ClassCastException, but it doesn't
event get to the original failure point: in fact, it fails earlier
because it is not being run within a J2EE context and consequently
fails as soon as an attempt is made to do a JNDI lookup on the session
beans.

I guess what I really need to do mock off the getEJBService() of
MainApplication to return a "mock" object that serves the data to the
test pages.

Problem is, I'm not sure how to achieve that without initialising
WicketTester with a mock MainApplication, which will then fail with a
ClassCastException, as before.

I think it's a Catch 22, but not being too familiar with the
WicketTester approach I'm hopeful someone out there could help.

Note: I want to avoid using Spring, and though I have used contrib-
java-ee in earlier versions of Wicket, it doesn't seem to play nicely
with Wicket 1.3 and I don't want to go backwards. I'd like a solution
that can mock of the EJB layers that are looked up in - and accessed
via - the MainApplication class.

Hope someone can help!

Regards,
Andy Barlow



On 16 Nov 2007, at 19:08, Alex Objelean wrote:



In order to avoid ClassCastException, when constructing a new instance
of
WicketTester,  initialize it with your MainApplication:

WicketTester tester = new WicketTester(new MainApplication());



Andy Barlow [Deftex] wrote:

I have an application which used Session EJB's to deliver data to
Wicket pages.

These are looked up using JNDI in the main application class: for the
sake of argument let's call it MainApplication.java.

I then have a BasePage.java from which all other pages that use these
EJB's inherit, in which there is a getter that returns the EJB service
as follows:

 public EJBLocal getEJBService() {
       return ((MainApplication)this.getApplication()).
getEJBService();
   }

It all works nicely, but I want to (retrospectively, slap on the
wrist) write a test harness to validate the application.

My problem is I get a ClassCastException in BasePage.java because the
MockWebApplication that WicketTester creates/uses cannot be cast to
MainApplication.

I've seen examples where Spring beans are mocked off, so I'm sure it's
possible.

Has anyone got any ideas or suggestions?

Regards,
Andy Barlow




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
View this message in context:
http://www.nabble.com/WicketTester%3A-how-to-mock-off-EJB%27s-tf4822609.html#a13798080
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Regards,
Andy Barlow

The information in this email or facsimile is confidential and is
intended solely for the addressee(s) and access to this email or
facsimile by anyone else is unauthorised. If you are not the intended
recipient then any disclosure, copying, distribution or any action
taken or omitted to be taken in reliance on it, is prohibited and may
be unlawful. Information expressed in this email or facsimile is not
given or endorsed by my firm or employer unless otherwise indicated by
an authorised representative independent of this message.

Deftex Limited
Computer Consultancy

Andy Barlow MBCS CENG EURING CITP
Deftex Limited
Consultant
High Riding
Richmond
North Yorkshire
DL10 5BN

skype: andybarlow285

[EMAIL PROTECTED]
tel: +44 (0)208 123 6285
http://www.deftex.co.uk
mobile: +44 (0)7830 302 268



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
View this message in context: 
http://www.nabble.com/WicketTester%3A-how-to-mock-off-EJB%27s-tf4822609.html#a13801297
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Regards,
Andy Barlow

The information in this email or facsimile is confidential and is intended solely for the addressee(s) and access to this email or facsimile by anyone else is unauthorised. If you are not the intended recipient then any disclosure, copying, distribution or any action taken or omitted to be taken in reliance on it, is prohibited and may be unlawful. Information expressed in this email or facsimile is not given or endorsed by my firm or employer unless otherwise indicated by an authorised representative independent of this message.

Deftex Limited
Computer Consultancy

Andy Barlow MBCS CENG EURING CITP
Deftex Limited
Consultant
High Riding
Richmond
North Yorkshire
DL10 5BN

skype: andybarlow285

[EMAIL PROTECTED]
tel: +44 (0)208 123 6285
http://www.deftex.co.uk
mobile: +44 (0)7830 302 268



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to