Romain, maybe a proxy handler on top of the business interface can do the trick. Not sure it will work, but it should be able to provide any implementation even a mock to a business interface.
The need is there, so that be great to have a look. Any other ideas? Jean-Louis 2012/8/30 Romain Manni-Bucau <[email protected]> > Hmm, not sure i get what is hard, never tried it but using alternative of > cdi or specialize should do the trick. > > To use mockito you need to change deep in the code the way ejb are > instantiated+scanned (doable but i really think it is easier to mock an ejb > than using mockito) > > Another lazy solution is to divide your module in submodule to be modular > even for testing > > - Romain > Le 29 août 2012 13:34, "Yann Blazart" <[email protected]> a écrit : > > > Wo I'm studying applicationComposer code. It's difficult. > > > > Why I want to use mockito ? Simply because I wan't to make some unit > tests > > without have to get all. > > > > For example I wan't to test a business service, a stateless ejb. This one > > use another one that make some things with mms, databases and other > things. > > The only things I wan't to test are the calling sequences to the second > ejb > > by the first one. That's why I wan't to use mockito as I don't need to > > prepare the resources (jms db). if I use a class that extends the second > > ejb, it will try to inject the resources I don't need.... > > > > 2012/8/28 Yann Blazart <[email protected]> > > > > > Mockito is more easy to use than extends the ejb class. > > > > > > I will search for a way to make that works. > > > > > > > > > 2012/8/28 Romain Manni-Bucau <[email protected]> > > > > > >> Hi, > > >> > > >> Generally we mock services replacing them by child or another > > >> implementation so no need of mockito and you keep injection > > >> consistent...but you can use mockito to implement this other class > with > > a > > >> kind of delegate pattern. > > >> > > >> - Romain > > >> Le 28 août 2012 16:19, "Yann Blazart" <[email protected]> a > écrit > > : > > >> > > >> > Hi , is there a way to use Mockito instance with Application > composer > > >> for > > >> > unit tests ? > > >> > > > >> > For example here, is there a solution to use the mockito instance > for > > >> the > > >> > EjbJar ? : > > >> > > > >> > > > >> > > @RunWith(ApplicationComposer.class) > > >> > > public class EchoServiceTest { > > >> > > > > >> > > @Mock > > >> > > private DummyService dummyService; > > >> > > @EJB > > >> > > private EchoService echoService; > > >> > > @Before > > >> > > public void init() { > > >> > > MockitoAnnotations.initMocks(this); > > >> > > } > > >> > > > > >> > > @Module > > >> > > public EjbJar createEjbJar() { > > >> > > EjbJar ejbJar = new > EjbJar(this.getClass().getSimpleName()); > > >> > > ejbJar.addEnterpriseBean(new > > >> StatelessBean(EchoService.class)); > > >> > > // ejbJar.addEnterpriseBean(new StatelessBean); > > >> > > return ejbJar; > > >> > > } > > >> > > > >> > > > > > > > > >
