Checkout the blog tutorial, the unit test part.... http://cwiki.apache.org/confluence/display/WICKET/Blog+Tutorial
Jörn Zaefferer wrote:
Hi, my wicket applicatin uses the SpringComponentInjector and @SpringBean annotations, which works great at runtime where the application context is present. I'd like to use WicketTester for JUnit tests: tester = new WicketTester(new MyApplication()); In MyApplication#init, the component injector is created: addComponentInstantiationListener(new SpringComponentInjector(this)); That constructor loads the ApplicationContext via WebApplicationContextUtils.getRequiredWebApplicationContext(webapp.getServletContext() That is the part which fails in my test, because there is no ApplicationContext stored in the servlet context. How can I fix that? My attempts so far: The description here doesn't help: http://cwiki.apache.org/WICKET/spring.html#Spring-UnitTestingtheProxyApproach The injector is already configured at that point. The alternative would be to put the application context into the ServletContext, so that WebApplicationContextUtils can find it. I've found no way to access MockWebApplication.context to set it manually, though I was able to set it by overwriting newServletContext. Though .setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, context); where context is of type AnnotApplicationContextMock yields an IllegalStateException, because AnnotApplicationContextMock doesn't implement WebApplicationContext. Thanks Jörn --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
-- -Wicket for love -Jme for fun Nino Martinez Wael Java Specialist @ Jayway DK http://www.jayway.dk +45 2936 7684 --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]