tomee-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rafael Pestano <rmpest...@gmail.com>
Subject Re: Applicaitoncomposer and dbunit-rules
Date Fri, 19 Aug 2016 13:42:08 GMT
Now that we have a prototype the implementation is a mere detail ;)


Em sex, 19 de ago de 2016 10:33, Romain Manni-Bucau <rmannibucau@gmail.com>
escreveu:

> this was the proposal actually ;)
>
>
> Romain Manni-Bucau
> @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> <http://rmannibucau.wordpress.com> | Github <
> https://github.com/rmannibucau> |
> LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> <http://www.tomitribe.com> | JavaEE Factory
> <https://javaeefactory-rmannibucau.rhcloud.com>
>
> 2016-08-19 15:32 GMT+02:00 Rafael Pestano <rmpestano@gmail.com>:
>
> > Exactly!
> >
> > Em sex, 19 de ago de 2016 10:13, Romain Manni-Bucau <
> rmannibucau@gmail.com
> > >
> > escreveu:
> >
> > > like
> https://gist.github.com/rmannibucau/4df57b865a50edab1f2c259fb9c5c6
> > e2
> > > ?
> > >
> > >
> > > Romain Manni-Bucau
> > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> > > <http://rmannibucau.wordpress.com> | Github <
> > > https://github.com/rmannibucau> |
> > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > <http://www.tomitribe.com> | JavaEE Factory
> > > <https://javaeefactory-rmannibucau.rhcloud.com>
> > >
> > > 2016-08-19 15:08 GMT+02:00 Rafael Pestano <rmpestano@gmail.com>:
> > >
> > > > Thanks for the explanation, I've looked at your sample and see too
> much
> > > > infrastructure code inside the test (e.g. db setup) I'd like to have
> > > > something like the example at [1] where we delegate infra code to an
> > > > interceptor, can we have something similar with app composer, a
> 'dbunit
> > > > module' makes sense?
> > > >
> > > >
> > > > [1]
> > > > https://github.com/rmpestano/dbunit-rules-sample/blob/
> > > > master/src/test/java/com/github/dbunit/rules/sample/
> > > > cdi/DBUnitRulesCDITest.java
> > > >
> > > > Em sex, 19 de ago de 2016 09:44, Romain Manni-Bucau <
> > > rmannibucau@gmail.com
> > > > >
> > > > escreveu:
> > > >
> > > > > Basically appcomposer lifecycle is bound to the statement. For the
> > > runner
> > > > > or @Rule it means a method and for a @ClassRule the class. If you
> > don't
> > > > run
> > > > > it before other rules, other rules can't use the container
> including
> > > > > container resources like datasources. So chaining appcomposert then
> > > > dbunit
> > > > > rule works. If you check my impl I used @DbUnitInstance to mark an
> > > > injected
> > > > > field as a datasource to use instead of using a ConnectionHolder
to
> > > make
> > > > > the test setup smoother.
> > > > >
> > > > >
> > > > > Romain Manni-Bucau
> > > > > @rmannibucau <https://twitter.com/rmannibucau> |  Blog
> > > > > <https://blog-rmannibucau.rhcloud.com> | Old Wordpress Blog
> > > > > <http://rmannibucau.wordpress.com> | Github <
> > > > > https://github.com/rmannibucau> |
> > > > > LinkedIn <https://www.linkedin.com/in/rmannibucau> | Tomitriber
> > > > > <http://www.tomitribe.com> | JavaEE Factory
> > > > > <https://javaeefactory-rmannibucau.rhcloud.com>
> > > > >
> > > > > 2016-08-19 13:43 GMT+02:00 rmpestano <rmpestano@gmail.com>:
> > > > >
> > > > > > 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