0
測試:模擬@ org.jboss.seam.annotations.in行爲單元測試
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中注入部分的一些聰明的辦法嗎?
//雅各布