maybe the easiest is to try
https://github.com/apache/tomee/blob/120a33c7b4de07ae01c17978ea37d88a911ea860/container/openejb-junit/src/test/java/org/apache/openejb/junit/TestEJBContainerRule.java#L46

side note: you can need to decorate your test @ManagedBean


Romain Manni-Bucau
@rmannibucau <https://twitter.com/rmannibucau> |  Blog
<http://rmannibucau.wordpress.com> | Github <https://github.com/rmannibucau> |
LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
<http://www.tomitribe.com>

2015-12-07 22:03 GMT+01:00 Steve Goldsmith <[email protected]>:

> You say Injector class which I assume is not
> container.getContext().bind("inject", this). Is there an example somewhere?
>
> On Mon, Dec 7, 2015 at 3:55 PM, Romain Manni-Bucau <[email protected]>
> wrote:
>
> > Injector class can do the trick
> >
> >
> > Romain Manni-Bucau
> > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > <http://rmannibucau.wordpress.com> | Github <
> > https://github.com/rmannibucau> |
> > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > <http://www.tomitribe.com>
> >
> > 2015-12-07 21:36 GMT+01:00 sgjava <[email protected]>:
> >
> > > I am testing an app with EmbeddedTomEEContainer, but it's unable to
> > inject
> > > a
> > > DataSource as a @Resource. This works fine with standard EJBContainer.
> Is
> > > this because injection is done on web app (deployment) vs. unit test?
> > >
> > > Works:
> > >
> > >
> >
> https://github.com/sgjava/datasource-tomee/blob/master/src/test/java/com/codeferm/datasource/DataSourceTest.java
> > >
> > > Fails:
> > >
> > >
> >
> https://github.com/sgjava/datasource-tomee/blob/master/src/test/java/com/codeferm/datasource/DataSourceWebTest.java
> > >
> > > Considering that is there a way to inject a DataSource resource in a
> web
> > > base unit test? The app doesn't use any database access, but I need it
> > for
> > > the unit tests. I can always just use DbUtils/Commons Pool, but I like
> to
> > > get resources from the container for tests.
> > >
> > >
> > >
> > > --
> > > View this message in context:
> > >
> >
> http://tomee-openejb.979440.n4.nabble.com/Test-DataSource-injection-with-EmbeddedTomEEContainer-tp4677167.html
> > > Sent from the TomEE Users mailing list archive at Nabble.com.
> > >
> >
>
>
>
> --
> Steven P. Goldsmith
>

Reply via email to