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]