M2 but snapshot hasnt been redeployed yet (build from sources to get this
fix)



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-08 16:29 GMT+01:00 Steve Goldsmith <[email protected]>:

> Here's the weird thing, if I run all tests it works (tomee-embedded)
> because a test with the default provider runs before the failing test. If I
> run the individual test it fails, so EjbContainer must be leaving artifacts
> in memory even after proper shut down.
>
> Is this fix in 7.0.0 snapshot or only 7.0.0 M2? I'll try system properties
> if snapshot doesn't work.
>
> On Tue, Dec 8, 2015 at 8:16 AM, Romain Manni-Bucau <[email protected]>
> wrote:
>
> > right https://issues.apache.org/jira/browse/TOMEE-1675
> >
> > System properties should work anyway.
> >
> >
> > 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-08 1:40 GMT+01:00 Steve Goldsmith <[email protected]>:
> >
> > > I tried several lookups, but none were found. Looking in the log I do
> not
> > > see the datasource being created. Maybe tomee-embedded provider doesn't
> > > pick up the datasource via properties?
> > >
> > > On Mon, Dec 7, 2015 at 5:05 PM, Romain Manni-Bucau <
> > [email protected]>
> > > wrote:
> > >
> > > > openejb:Resource/ds or java:global/ds if you set a global name to the
> > ds.
> > > > Le 7 déc. 2015 22:45, "Steve Goldsmith" <[email protected]> a écrit :
> > > >
> > > > > In order to keep my tests consistent I don't mind looking up the
> > > > datasource
> > > > > without injection. So if I use:
> > > > >
> > > > >         final Map p = new HashMap();
> > > > >         p.put(Context.INITIAL_CONTEXT_FACTORY,
> > > > >
> >  "org.apache.openejb.core.LocalInitialContextFactory");
> > > > >         p.put("openejb.embedded.initialcontext.close ", "DESTROY");
> > > > >         p.put("openejb.embedded.remotable", "true");
> > > > >         p.put("dataSource", "new://Resource?type=DataSource");
> > > > >         p.put("dataSource.JdbcDriver", "org.hsqldb.jdbcDriver");
> > > > >         p.put("dataSource.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
> > > > >         p.put(EJBContainer.APP_NAME, "datasource");
> > > > >         p.put(EJBContainer.PROVIDER, "tomee-embedded");
> > > > >         // Add WAR and MDB modules
> > > > >         p.put(EJBContainer.MODULES, new
> > > File[]{Archive.archive().copyTo(
> > > > >             "WEB-INF/classes",
> > > jarLocation(TestService.class)).asDir()});
> > > > >         // Random port
> > > > >         p.put(EmbeddedTomEEContainer.TOMEE_EJBCONTAINER_HTTP_PORT,
> > > "-1");
> > > > >         container = EJBContainer.createEJBContainer(p);
> > > > >
> > > > > What would the lookup look like?
> > > > >
> > > > > context.lookup("java:global/.../dataSource");
> > > > >
> > > > >
> > > > >
> > > > > On Mon, Dec 7, 2015 at 4:11 PM, Romain Manni-Bucau <
> > > > [email protected]>
> > > > > wrote:
> > > > >
> > > > > > 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
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Steven P. Goldsmith
> > > > >
> > > >
> > >
> > >
> > >
> > > --
> > > Steven P. Goldsmith
> > >
> >
>
>
>
> --
> Steven P. Goldsmith
>

Reply via email to