Nothing against it but here is my opinion,

JEE is designed to be testable so no need of any "complicated for nothing"
framework.

For me mockito answer to a different need.

For a cdi sample we have an example on trunk using alternatives ans
stereotypes.

- Romain
Le 31 août 2012 12:45, "Yann Blazart" <[email protected]> a écrit :

> I'm agree but tests with arquilian take more time than simple unit tests.
> Le 31 août 2012 11:21, "Jean-Louis MONTEIRO" <[email protected]> a écrit
> :
>
> > Waiting for Romain's answer, but I guess it will be. Mocking is an old
> > school solution ;-)
> > Indeed, nowadays, and mainly thanks to EJB 3 lite, Arquillian, and so on,
> > it's far easier to get simple integration tests. So the need to really
> > write unit tests is smaller.
> >
> > Just some thoughts.
> > Romain is currently on holidays, but quite sure he will find a hack for
> you
> > when he'll be back ;-)
> >
> > Jean-Louis
> >
> >
> > 2012/8/31 Yann Blazart <[email protected]>
> >
> > > Well, in fact I'm not sure to go in the right way.
> > >
> > > I wan't to make the demonstration that jee6 can now replace spring.
> > > One thing very interesting in spring is about that faculty to make
> > > "unit-test" between real unit-test and integration tests with
> > > @Configuration. I wanted to make the same thing.
> > >
> > > I can reproduce it with cdi-unit for example, but I wan't to use EJB
> > > 3.1 too (transaction, and security), my research show me the OpenEjb
> > > stack with the ApplicationComposer runner, this is very cool !
> > >
> > > Well to get back to my main subject. In fact that should be very nice
> > > to be able to use Mocks from Mockito instead of the instances produced
> > > by the container.
> > >
> > > Example : I have my business service a Stateless localbean, this one
> > > use a DAO, same Stateless localbean with no interface. This DAO use a
> > > persistence manager. As the DAO has no interface, I cannot replace his
> > > implementation in the @Module by writing a mock by hand, the simple
> > > extended class do not work. The problem is that this dao absolutely
> > > need the EntityManager in this case, so I need to provide it, I'm
> > > going to write an integration test, not a unit test.
> > >
> > > I'm currently studying the openjeb code to find a solution, made some
> > > things but no results for the moment.
> > >
> > > That would be nice to ben able to make someting like this :
> > >
> > >  ejbJar.addEnterpriseBean(new
> > > MockStatelessBean(DAO.class,daoMockInstance));
> > >
> > > If anybody have an idea or suggestion :)
> > >
> > > 2012/8/31, Romain Manni-Bucau <[email protected]>:
> > > > I dont think so (the proxy). The need is more than it: vetoing a bean
> > > > deployment (not managed today i think) + mocking (i would like to
> avoid
> > > to
> > > > update core for this need)
> > > >
> > > > - Romain
> > > > Le 31 août 2012 09:15, "Jean-Louis MONTEIRO" <[email protected]> a
> > > écrit :
> > > >
> > > >> 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;
> > > >> > > >> > >     }
> > > >> > > >> >
> > > >> > > >>
> > > >> > > >
> > > >> > > >
> > > >> > >
> > > >> >
> > > >>
> > > >
> > >
> >
>

Reply via email to