Can't you just put setters on your page/components that take the
dependencies?  Then, during testing, you can just inject mock objects.

On Fri, Apr 25, 2008 at 9:21 AM, Sarkast <[EMAIL PROTECTED]> wrote:
>
>  Hello there,
>
>  I have a question which came up when trying to test my wicket pages.
>
>  Currently a working implementation is the following in my test class:
>
>  Creating an ApplicationContextMock, populating it with the beans, creating
>  the WebApplication, injecting the context and initializing the WicketTester.
>
>        ApplicationContextMock appctx = new ApplicationContextMock();
>         appctx.putBean("userDao", new InMemoryUserDoaMock());
>         WebApplication app = new HelloApplication();
>         app.addComponentInstantiationListener(new
>  SpringComponentInjector(app, appctx));
>         wicketTester = new WicketTester(app);
>         wicketTester.startPage(new Login());
>
>
>  The problem is, this test only runs when the
>  addComponentInstantiatenListener line is commented out in the
>  WebApplication's init method needed to test . Just like here:
>
>     protected void init() {
>         super.init();
>         mount("/pages", PackageName.forPackage(Login.class.getPackage()));
>         //  commented out for testing addComponentInstantiationListener(new
>  SpringComponentInjector(this));
>     }
>
>  However, this line is important for the real system, obviously.
>
>  Is it possible to run the test without commenting out the mentioned line? We
>  would really like to not edit the real code, as it seems strange to modify
>  it so the test can run.
>
>  Hope that someone could understand what the problem is and help me :-(
>
>  Thanks in advance,
>
>  Tom
>
>  --
>  View this message in context: 
> http://www.nabble.com/WicketTester-in-spring%2C-question-about-springinjection-tp16895558p16895558.html
>  Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
>  ---------------------------------------------------------------------
>  To unsubscribe, e-mail: [EMAIL PROTECTED]
>  For additional commands, e-mail: [EMAIL PROTECTED]
>
>

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

Reply via email to