【发布时间】:2011-04-04 12:55:46
【问题描述】:
测试:
public class BeanTest {
private SomeBean target;
@Test(groups = "integration")
public void checkIfAuthenticationWorks() {
ApplicationBean applicationBean = mock(ApplicationBean.class);
target = new SomeBean();
// Some cool code to inject applicationBean to target class
assertEquals("token", target.authenticate(USERNAME, PASSWORD));
}
}
班级:
@AutoCreate
@Name("someBean")
@Scope(ScopeType.SESSION)
public class someBean implements Serializable {
@Logger
private static Log log;
@In
ApplicationBean applicationBean;
public String authenticate(String username, String password) {
// Very cool code!
return "token";
}
}
有解决applicationBean注入部分的聪明方法吗?
//雅各布
【问题讨论】: