tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rmpestano <rmpest...@gmail.com>
Subject Re: Applicaitoncomposer and dbunit-rules
Date Fri, 19 Aug 2016 11:43:58 GMT
You Tell me ;) don't know the internals of app composer

Em sex, 19 de ago de 2016 02:28, Romain Manni-Bucau [via TomEE & OpenEJB] <
ml-node+s979440n4679808h21@n4.nabble.com> escreveu:

> What about creating the container - therefore DB - before calling dbunit?
>
> Le 19 août 2016 01:53, "rmpestano" <[hidden email]
> <http:///user/SendEmail.jtp?type=node&node=4679808&i=0>> a écrit :
>
> > Hi again,
> >
> > I've tried to chain rules but datasource isn't initialized when DBunit
> rule
> > apply method is run:
> >
> > @Rule
> > public TestRule theRule = RuleChain.outerRule(DBUnitRule.instance(new
> > ConnectionHolder() {
> >
> >     @Override
> >     public Connection getConnection() {
> >         try {
> >             return ds.getConnection(); //called by dbunit rule apply
> >         } catch (Exception e) {
> >             e.printStackTrace();
> >         }
> >         return null;
> >     }
> > })).around(new ApplicationComposerRule(this));
> >
> >
> > Any idea on how to get datasource connection when dbunit rule apply
> method
> > is called?
> >
> > Thanks in advance.
> >
> >
> > 2016-08-17 15:03 GMT-03:00 Romain Manni-Bucau [via TomEE & OpenEJB] <
> > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4679808&i=1>>:
>
> >
> > > You need to chain rules: appcomposer then dbunit or set appcomposer as
> > > @ClassRule instead of @Rule
> > >
> > > @Rafael: openejb:Resource/id should work
> > >
> > > Le 17 août 2016 19:45, "Rafael Pestano" <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4679791&i=0>> a
écrit :
> > >
> > > > I've also try to look up the datasource via jndi but without success
> > > >
> > > > 2016-08-17 14:42 GMT-03:00 Rafael Pestano <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4679791&i=1>>:
> > > >
> > > > > Hi Romain,
> > > > >
> > > > > I've tried to create DBUnit Rule in AppComposer test but could not
> > > > > instantiate the rule cause it needs a JDBC connection but looks
> like
> > > > > composer enriches the datasource after DBUnit rule apply method is
> > > > invoked.
> > > > >
> > > > >
> > > > > @Resource
> > > > > DataSource ds;
> > > > > @Rule
> > > > > public DBUnitRule dbUnitRule = DBUnitRule.instance(new
> > > ConnectionHolder()
> > > > > {
> > > > > @Override
> > > > > public Connection getConnection() { //its called by 'apply' dbunit
> > > method
> > > > > rule
> > > > > try {
> > > > > return ds.getConnection();
> > > > > } catch (Exception e) {
> > > > > // TODO Auto-generated catch block
> > > > > e.printStackTrace();
> > > > > }
> > > > > return null;
> > > > > }
> > > > > });
> > > > >
> > > > >
> > > > > Any idea on how to workaround that?
> > > > >
> > > > > Complete source code can be found here: https://github.com/
> > > > > rmpestano/tomee/blob/master/examples/application-composer-
> > > > > dbunit/src/test/java/org/superbiz/composed/MoviesTest.java#L62
> > > > >
> > > > >
> > > > >
> > > > > 2016-08-17 11:33 GMT-03:00 Romain Manni-Bucau <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4679791&i=2>>:
> > > > >
> > > > >> 2016-08-17 16:28 GMT+02:00 hwaastad <[hidden email]
> > > <http:///user/SendEmail.jtp?type=node&node=4679791&i=3>>:
> > > > >>
> > > > >> > Hi,
> > > > >> > I think I meant if it's possible to run a interceptor on
a test
> > > > >> > method....just like the usedataset...
> > > > >> >
> > > > >> >
> > > > >> Then no cause we don't lookup the instance in CDI but keep the
> JUnit
> > > one
> > > > >> to
> > > > >> not break other things - deltaspike cdirunner has a flag for
> that,
> > > guess
> > > > >> it
> > > > >> is what you asked for.
> > > > >>
> > > > >> That said keeping in mind appcomposer is a rule, another rule
is
> a
> > > > natural
> > > > >> interceptor for it - without requiring EE.
> > > > >>
> > > > >>
> > > > >> >
> > > > >> > OK, I'll have a look at what you've done. I think I can
make
> > > something
> > > > >> out
> > > > >> > of it :-)
> > > > >> >
> > > > >> > Thx,
> > > > >> >
> > > > >> > hw
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> >
> > > > >> > --
> > > > >> > View this message in context: http://tomee-openejb.979440.n4
> > > > >> .nabble.com/
> > > > >> > Applicaitoncomposer-and-dbunit-rules-tp4679781p4679783.html
> > > > >> > Sent from the TomEE Users mailing list archive at Nabble.com.
> > > > >> >
> > > > >>
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Att,
> > > > >
> > > > > Rafael M. Pestano
> > > > >
> > > > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do
> > Sul
> > > > > http://rpestano.wordpress.com/
> > > > > @realpestano
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Att,
> > > >
> > > > Rafael M. Pestano
> > > >
> > > > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do
> Sul
> > > > http://rpestano.wordpress.com/
> > > > @realpestano
> > > >
> > >
> > >
> > > ------------------------------
> > > If you reply to this email, your message will be added to the
> discussion
> > > below:
> > > http://tomee-openejb.979440.n4.nabble.com/Applicaitoncomposer-and-
> > > dbunit-rules-tp4679781p4679791.html
> > > To start a new topic under TomEE Users, email
> > > [hidden email] <http:///user/SendEmail.jtp?type=node&node=4679808&i=2>
> > > To unsubscribe from TomEE Users, click here
> > > <http://tomee-openejb.979440.n4.nabble.com/template/
> > NamlServlet.jtp?macro=unsubscribe_by_code&node=979441&code=
> > cm1wZXN0YW5vQGdtYWlsLmNvbXw5Nzk0NDF8MTE1OTM0ODgyNg==>
> > > .
> > > NAML
> > > <http://tomee-openejb.979440.n4.nabble.com/template/
> > NamlServlet.jtp?macro=macro_viewer&id=instant_html%
> > 21nabble%3Aemail.naml&base=nabble.naml.namespaces.
> > BasicNamespace-nabble.view.web.template.NabbleNamespace-
> > nabble.view.web.template.NodeNamespace&breadcrumbs=
> > notify_subscribers%21nabble%3Aemail.naml-instant_emails%
> > 21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
> > >
> >
> >
> >
> > --
> > Att,
> >
> > Rafael M. Pestano
> >
> > Desenvolvedor Java Cia. de Processamento de Dados do Rio Grande do Sul
> > http://rpestano.wordpress.com/
> > @realpestano
> >
> >
> >
> >
> > --
> > View this message in context: http://tomee-openejb.979440.n4.nabble.com/
> > Applicaitoncomposer-and-dbunit-rules-tp4679781p4679804.html
> > Sent from the TomEE Users mailing list archive at Nabble.com.
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://tomee-openejb.979440.n4.nabble.com/Applicaitoncomposer-and-dbunit-rules-tp4679781p4679808.html
> To start a new topic under TomEE Users, email
> ml-node+s979440n979441h44@n4.nabble.com
> To unsubscribe from TomEE Users, click here
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=979441&code=cm1wZXN0YW5vQGdtYWlsLmNvbXw5Nzk0NDF8MTE1OTM0ODgyNg==>
> .
> NAML
> <http://tomee-openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://tomee-openejb.979440.n4.nabble.com/Applicaitoncomposer-and-dbunit-rules-tp4679781p4679809.html
Sent from the TomEE Users mailing list archive at Nabble.com.
Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message