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 Wed, 17 Aug 2016 17:45:25 GMT
I've also try to look up the datasource via jndi but without success

2016-08-17 14:42 GMT-03:00 Rafael Pestano <rmpestano@gmail.com>:

> 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 <rmannibucau@gmail.com>:
>
>> 2016-08-17 16:28 GMT+02:00 hwaastad <helge@waastad.org>:
>>
>> > 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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message