hi deven,

please have a look e.g. at [1].
however, if you just need simple mocks, just use @Specializes and/or
@Alternative for beans in the test-classpath (see e.g. [2]).

regards,
gerhard

[1]
http://deltaspike.apache.org/documentation/test-control.html#_mock_frameworks
[2] https://github.com/CDIatWork/IdeaFork/tree/master/ideafork/src/test

http://www.irian.at

Your JavaEE powerhouse -
JavaEE Consulting, Development and
Courses in English and German

Professional Support for Apache
MyFaces, DeltaSpike and OpenWebBeans

2014-11-14 16:30 GMT+01:00 Deven Phillips <[email protected]>:

> So, to get to the real meat of the matter: IF I use BeanProvider to inject
> an instance, how would I mock that instance in my unit tests?
>
> For example:
>
> AbstractSocketHandler handlerInstance =
> > BeanProvider.injectFields(HandlerImpl.class.newInstance());
>
>
> How would I mock that instance so that I can properly unit test without
> having to build lots of crazy things?
>
> Thanks again!!
>
> Deven
>
> On Fri, Nov 14, 2014 at 9:47 AM, Gerhard Petracek <
> [email protected]> wrote:
>
> > hi deven,
> >
> > it depends on details you haven't provided.
> > however, in any case you can use BeanProvider#injectFields to fill
> > injection points of any instance which isn't managed by the
> cdi-container.
> >
> > regards,
> > gerhard
> >
> > http://www.irian.at
> >
> > Your JavaEE powerhouse -
> > JavaEE Consulting, Development and
> > Courses in English and German
> >
> > Professional Support for Apache
> > MyFaces, DeltaSpike and OpenWebBeans
> >
> >
> >
> > 2014-11-14 15:32 GMT+01:00 Deven Phillips <[email protected]>:
> >
> > > Hi all,
> > >
> > >      New to DeltaSpike (coming from Guice) and I am trying to migrate
> my
> > > Jetty websocket implementation to DeltaSpike, but I would like some
> help
> > > figuring out how to properly inject my JSR-356 annotated object into
> the
> > > WebSocketCreator class. I have created an abstract
> AbstractSocketHandler
> > > which both of my implementation inherit from. So, in my project, if I
> > have
> > > a class which @Produces an instance of that, does anyone know if the
> > Jetty
> > > implementation will inject it into the appropriate places? Or will I
> have
> > > to manually use BeanManager to accomplish the injections?
> > >
> > > Thanks in advance for any help!!
> > >
> > > Deven Phillips
> > >
> >
>

Reply via email to