emmanuelbernard / hibernate-core-ogm

Hibernate extension for Object Grid Mapper
http://hibernate.org
11 stars 4 forks source link

Add JTA test #9

Open emmanuelbernard opened 14 years ago

emmanuelbernard commented 14 years ago

emmanuel>About JTA, it's more an Infinispan's business. I am just using the cache. If somebody tells me how to configure JTA in Infinispan + a standalone JTA TM, I can add a unit test for this.

manik>Just make sure your Infinispan configuration uses a TransactionManagerLookup. For JBoss TS standalone, make sure you use JBossStandaloneJTAManagerLookup. E.g.,

http://docs.jboss.org/infinispan/4.1/apidocs/org/infinispan/config/Configuration.html#setTransactionManagerLookup(org.infinispan.transaction.lookup.TransactionManagerLookup)

or if you are using an XML file to configure,

http://docs.jboss.org/infinispan/4.1/apidocs/config.html#ce_default_transaction

emmanuel>Note that I have JBoss TS standalone working in HSearch but the resource registration relies on SQL Datasource, not just any XAResource.

manik>Hmm. Maybe adding a UT would be a good idea, to flush out any nuances here.

emmanuelbernard commented 14 years ago

Yes, I have this in place. Start any Infinispan test with -Dinfinispan.test.jta.tm=jbosstm and the test uses JBoss TS Standalone. Otherwise it uses an internal DummyTransactionManager stub.

Have a look at TransactionSetup, a test helper class that handles this.

http://fisheye.jboss.org/browse/Infinispan/branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TransactionSetup.java?r=2041#l36

This is used by the TestCacheManagerFactory which creates configurations and cache managers for the unit tests, injecting the appropriate transaction manager based on the system property.

http://fisheye.jboss.org/browse/Infinispan/branches/4.1.x/core/src/test/java/org/infinispan/test/fwk/TestCacheManagerFactory.java?r=2276#l110