开发者

Using MockRoundtrip in Stripes with Guice

I've recently introduced Guice into my ActionBeans, where previously the actionbean had its data access layer implementation hardcoded.

I have an integration test like this:

MockServletContext context = TestHelper.getServletContext();
MockRoundtrip trip = new MockRoundtrip(context, LoginActionBean.class);


trip.setParameter("authenticate", "Login");
trip.setParameter("username", "testuser2");
trip.setParameter("password", "testuser2pass");
trip.setParame开发者_运维知识库ter("targetUrl", "Activity.action?jobId=1");
trip.execute();

LoginActionBean bean = trip.getActionBean(LoginActionBean.class);

Now that I'm using Guice, I can't find a way to inject the dependencies into the LoginActionBean, since I never actually instantiate it myself.

How can I tell guice to inject the dependencies into this class?


You will need to configure the MockServletContext with a Guice configuration, like you have in your web.xml (probably in your TestHelper class getServletContext() method).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜