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" <[email protected]> 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 <[email protected]>: > > > 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 <[email protected]>: > > > >> 2016-08-17 16:28 GMT+02:00 hwaastad <[email protected]>: > >> > >> > 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 >
