I would like to know how to test spring components or jsf managebeans.
Component has many autowired services which inturn has many autowired repositories. These autowired services and repository also has be instantiated. So it would be helpful if anyone can provide a example.
Component is like
@Component
@SessionScope
public void myComponentBean(){
@Autowired
IMyService1 iMyService1;
@Autowired
IMyService2 iMyService2;
public void doSomething(){
iMyService1.callServiceMehtod();
}
}
ServiceInterface is like
public interface IMyService1 {
public void callServiceMethod();
}
SerivceImplementation is like
@Service
public class IMyServiceImpl implements IMyService1 {
@Autowired
private IMyReposiory1 iMyReposiory1;
@Autowired
private IMyReposiory2 iMyReposiory2;
public void callServiceMethod(){
iMyReposiory1.callServiceMethod();
}
}
Repository is like
@Repository
public class MyReposiory1 extends HibernateUtil implements IMyReposiory1 {
public void callServiceMethod(){
}
}
Aucun commentaire:
Enregistrer un commentaire