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


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.

Reply via email to