[
https://issues.apache.org/jira/browse/WICKET-2487?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Igor Vaynberg resolved WICKET-2487.
-----------------------------------
Resolution: Won't Fix
Assignee: Igor Vaynberg
there isnt much we can do about this, spring does not provide a uniform way to
retrieve the context, nor is there one really for all the different
environments.
you want to make it a little nicer on your api? make your application take the
applicationcontext in its constructor. that should make it more explicit. then
use a custom webapplicationfactory to create your application instance for the
filter.
> SpringComponentInjector and AbstractJUnit4SpringContextTests
> ------------------------------------------------------------
>
> Key: WICKET-2487
> URL: https://issues.apache.org/jira/browse/WICKET-2487
> Project: Wicket
> Issue Type: Improvement
> Components: wicket-spring
> Affects Versions: 1.4.1
> Reporter: Ralf Ebert
> Assignee: Igor Vaynberg
>
> SpringComponentInjector goes to WebApplicationContextUtils to resolve the
> application context. In tests derived from AbstractJUnit4SpringContextTests
> this doesn't work.
> Workaround:
> 1) Make the SpringComponentInjector configurable for your app:
> public class SomeWicketApplication extends WebApplication {
> @Override
> protected void init() {
> addComponentInstantiationListener(createSpringInjector());
> }
> protected SpringComponentInjector createSpringInjector() {
> return new SpringComponentInjector(this);
> }
> }
> 2) configure it correctly for the test:
> @ContextConfiguration(locations = { "classpath:spring.xml" })
> public class TestHomePage extends AbstractJUnit4SpringContextTests {
> private WicketTester tester;
> @Before
> public void setUp() {
> SomeWicketApplication app = new SomeWicketApplication() {
> @Override
> protected SpringComponentInjector
> createSpringInjector() {
> return new SpringComponentInjector(this,
> applicationContext);
> }
> };
> tester = new WicketTester(app);
> }
> }
> Shouldn't there be a better/easier way to accomplish this?
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.