ignite-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sboi...@apache.org
Subject [14/20] ignite git commit: IGNITE-1864: Transaction manager factory instead of Transaction manager Lookup
Date Wed, 09 Dec 2015 12:13:20 GMT
IGNITE-1864: Transaction manager factory instead of Transaction manager Lookup


Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/5ea19a45
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/5ea19a45
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/5ea19a45

Branch: refs/heads/ignite-1537
Commit: 5ea19a4549eb9df619bad9e8a86b844a5db2ca1f
Parents: 0adee3a
Author: ashutak <ashutak@gridgain.com>
Authored: Wed Dec 9 12:02:57 2015 +0300
Committer: ashutak <ashutak@gridgain.com>
Committed: Wed Dec 9 12:02:57 2015 +0300

----------------------------------------------------------------------
 .../configuration/CacheConfiguration.java       |   4 +-
 .../configuration/TransactionConfiguration.java |  47 +++-
 .../cache/jta/CacheJtaManagerAdapter.java       |   4 +-
 .../HibernateTransactionalDataRegion.java       |  18 +-
 .../HibernateL2CacheTransactionalSelfTest.java  |  23 +-
 modules/jta/pom.xml                             |   9 +-
 .../cache/jta/jndi/CacheJndiTmFactory.java      | 132 +++++++++++
 .../processors/cache/jta/CacheJtaManager.java   |  41 +++-
 .../cache/AbstarctCacheJtaSelfTest.java         | 183 +++++++++++++++
 .../cache/CacheJndiTmFactorySelfTest.java       | 166 ++++++++++++++
 ...CacheJtaConfigurationValidationSelfTest.java |   4 +-
 ...CacheJtaFactoryConfigValidationSelfTest.java | 142 ++++++++++++
 .../processors/cache/GridCacheJtaSelfTest.java  | 221 -------------------
 .../cache/GridCacheReplicatedJtaSelfTest.java   |  32 ---
 .../cache/GridJtaLifecycleAwareSelfTest.java    | 191 ++++++++++++++++
 .../GridPartitionedCacheJtaFactorySelfTest.java |  41 ++++
 ...titionedCacheJtaLookupClassNameSelfTest.java |  83 +++++++
 .../GridReplicatedCacheJtaFactorySelfTest.java  |  32 +++
 ...plicatedCacheJtaLookupClassNameSelfTest.java |  32 +++
 .../GridTmLookupLifecycleAwareSelfTest.java     | 122 ----------
 .../ignite/testsuites/IgniteJtaTestSuite.java   |  26 ++-
 21 files changed, 1150 insertions(+), 403 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
index 67f7b2e..d73ff58 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/CacheConfiguration.java
@@ -1112,7 +1112,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * Gets class name of transaction manager finder for integration for JEE app servers.
      *
      * @return Transaction manager finder.
-     * @deprecated Use {@link TransactionConfiguration#getTxManagerLookupClassName()} instead.
+     * @deprecated Use {@link TransactionConfiguration#getTxManagerFactory()} instead.
      */
     @Deprecated
     public String getTransactionManagerLookupClassName() {
@@ -1125,7 +1125,7 @@ public class CacheConfiguration<K, V> extends MutableConfiguration<K, V> {
      * @param tmLookupClsName Name of class implementing GridCacheTmLookup interface that is used to
      *      receive JTA transaction manager.
      * @return {@code this} for chaining.
-     * @deprecated Use {@link TransactionConfiguration#setTxManagerLookupClassName(String)} instead.
+     * @deprecated Use {@link TransactionConfiguration#setTxManagerFactory(Factory)} instead.
      */
     @Deprecated
     public CacheConfiguration<K, V> setTransactionManagerLookupClassName(String tmLookupClsName) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/core/src/main/java/org/apache/ignite/configuration/TransactionConfiguration.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/configuration/TransactionConfiguration.java b/modules/core/src/main/java/org/apache/ignite/configuration/TransactionConfiguration.java
index fc2a6cb..b3d294d 100644
--- a/modules/core/src/main/java/org/apache/ignite/configuration/TransactionConfiguration.java
+++ b/modules/core/src/main/java/org/apache/ignite/configuration/TransactionConfiguration.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.configuration;
 
 import java.io.Serializable;
+import javax.cache.configuration.Factory;
 import org.apache.ignite.transactions.Transaction;
 import org.apache.ignite.transactions.TransactionConcurrency;
 import org.apache.ignite.transactions.TransactionIsolation;
@@ -65,6 +66,9 @@ public class TransactionConfiguration implements Serializable {
     /** Name of class implementing GridCacheTmLookup. */
     private String tmLookupClsName;
 
+    /** {@code javax.transaction.TransactionManager} factory. */
+    private Factory txManagerFactory;
+
     /**
      * Empty constructor.
      */
@@ -83,6 +87,7 @@ public class TransactionConfiguration implements Serializable {
         pessimisticTxLogSize = cfg.getPessimisticTxLogSize();
         txSerEnabled = cfg.isTxSerializableEnabled();
         tmLookupClsName = cfg.getTxManagerLookupClassName();
+        txManagerFactory = cfg.getTxManagerFactory();
     }
 
     /**
@@ -214,7 +219,9 @@ public class TransactionConfiguration implements Serializable {
      * Gets class name of transaction manager finder for integration for JEE app servers.
      *
      * @return Transaction manager finder.
+     * @deprecated Use {@link #getTxManagerFactory()} instead.
      */
+    @Deprecated
     public String getTxManagerLookupClassName() {
         return tmLookupClsName;
     }
@@ -224,8 +231,46 @@ public class TransactionConfiguration implements Serializable {
      *
      * @param tmLookupClsName Name of class implementing GridCacheTmLookup interface that is used to
      *      receive JTA transaction manager.
+     * @deprecated Use {@link #setTxManagerFactory(Factory)} instead.
      */
+    @Deprecated
     public void setTxManagerLookupClassName(String tmLookupClsName) {
         this.tmLookupClsName = tmLookupClsName;
     }
-}
\ No newline at end of file
+
+    /**
+     * Gets transaction manager factory for integration with JEE app servers.
+     *
+     * @param <T> Instance of {@code javax.transaction.TransactionManager}.
+     * @return Transaction manager factory.
+     */
+    @SuppressWarnings("unchecked")
+    public <T> Factory<T> getTxManagerFactory() {
+        return txManagerFactory;
+    }
+
+    /**
+     * Sets transaction manager factory for available {@code javax.transaction.TransactionManager} implementation,
+     * if any.
+     * <p>
+     * It allows to use different transactional systems. Implement factory that produce native
+     * {@code javax.transaction.TransactionManager} within your environment.
+     * <p>
+     * The following implementations are provided out of the box (jta module must be enabled):
+     * <ul>
+     * <li>
+     *  {@code org.apache.ignite.cache.jta.jndi.CacheJndiTmFactory} utilizes configured JNDI names to look up
+     *  a transaction manager.
+     * </li>
+     * </ul>
+     *
+     * Ignite will throw IgniteCheckedException if {@link Factory#create()} method throws any exception,
+     * returns {@code null}-value or returns non-{@code TransactionManager} instance.
+     *
+     * @param factory Transaction manager factory.
+     * @param <T> Instance of {@code javax.transaction.TransactionManager}.
+     */
+    public <T> void setTxManagerFactory(Factory<T> factory) {
+        txManagerFactory = factory;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java
----------------------------------------------------------------------
diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java
index 7b45e73..0fd97eb 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManagerAdapter.java
@@ -44,7 +44,9 @@ public abstract class CacheJtaManagerAdapter extends GridCacheSharedManagerAdapt
     /**
      * Gets transaction manager finder. Returns Object to avoid dependency on JTA library.
      *
+     * Used only in test purposes.
+     *
      * @return Transaction manager finder.
      */
     @Nullable public abstract Object tmLookup();
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
index d89911c..ed2ee01 100644
--- a/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
+++ b/modules/hibernate/src/main/java/org/apache/ignite/cache/hibernate/HibernateTransactionalDataRegion.java
@@ -88,13 +88,15 @@ public class HibernateTransactionalDataRegion extends HibernateRegion implements
                     throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite cache with " +
                         "'TRANSACTIONAL' atomicity mode: " + cache.name());
 
-                if (cache.configuration().getTransactionManagerLookupClassName() == null) {
-                    TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration();
-                    
-                    if (txCfg == null || txCfg.getTxManagerLookupClassName() == null)
-                        throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite with " +
-                            "TransactionManagerLookup configured (see IgniteConfiguration." +
-                            "getTransactionConfiguration().getTxManagerLookupClassName()): " + cache.name());
+                TransactionConfiguration txCfg = ignite.configuration().getTransactionConfiguration();
+
+                if (txCfg == null ||
+                    (txCfg.getTxManagerFactory() == null
+                    && txCfg.getTxManagerLookupClassName() == null
+                    && cache.configuration().getTransactionManagerLookupClassName() == null)) {
+                    throw new CacheException("Hibernate TRANSACTIONAL access strategy must have Ignite with " +
+                                "Factory<TransactionManager> configured (see IgniteConfiguration." +
+                                "getTransactionConfiguration().setTxManagerFactory()): " + cache.name());
                 }
 
                 return new HibernateTransactionalAccessStrategy(ignite, cache);
@@ -103,4 +105,4 @@ public class HibernateTransactionalDataRegion extends HibernateRegion implements
                 throw new IllegalArgumentException("Unknown Hibernate access type: " + accessType);
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
index 99be869..9141be2 100644
--- a/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
+++ b/modules/hibernate/src/test/java/org/apache/ignite/cache/hibernate/HibernateL2CacheTransactionalSelfTest.java
@@ -18,11 +18,12 @@
 package org.apache.ignite.cache.hibernate;
 
 import java.util.Collections;
+import javax.cache.configuration.Factory;
 import javax.transaction.TransactionManager;
 import javax.transaction.UserTransaction;
 import org.apache.commons.dbcp.managed.BasicManagedDataSource;
-import org.apache.ignite.cache.jta.CacheTmLookup;
 import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
 import org.h2.jdbcx.JdbcDataSource;
 import org.hibernate.cache.spi.access.AccessType;
 import org.hibernate.engine.transaction.internal.jta.JtaTransactionFactory;
@@ -61,9 +62,12 @@ public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfT
     /**
      */
     @SuppressWarnings("PublicInnerClass")
-    public static class TestTmLookup implements CacheTmLookup {
+    public static class TestTmFactory implements Factory<TransactionManager> {
+        /** */
+        private static final long serialVersionUID = 0;
+
         /** {@inheritDoc} */
-        @Override public TransactionManager getTm() {
+        @Override public TransactionManager create() {
             return jotm.getTransactionManager();
         }
     }
@@ -86,11 +90,18 @@ public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfT
     }
 
     /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.getTransactionConfiguration().setTxManagerFactory(new TestTmFactory());
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
     @Override protected CacheConfiguration transactionalRegionConfiguration(String regionName) {
         CacheConfiguration cfg = super.transactionalRegionConfiguration(regionName);
 
-        cfg.setTransactionManagerLookupClassName(TestTmLookup.class.getName());
-
         cfg.setNearConfiguration(null);
 
         return cfg;
@@ -131,4 +142,4 @@ public class HibernateL2CacheTransactionalSelfTest extends HibernateL2CacheSelfT
     @Override protected AccessType[] accessTypes() {
         return new AccessType[]{AccessType.TRANSACTIONAL};
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/pom.xml
----------------------------------------------------------------------
diff --git a/modules/jta/pom.xml b/modules/jta/pom.xml
index e296940..c69b6cc 100644
--- a/modules/jta/pom.xml
+++ b/modules/jta/pom.xml
@@ -82,6 +82,13 @@
             <version>${spring.version}</version>
             <scope>test</scope>
         </dependency>
+
+        <dependency>
+            <groupId>org.apache.tomcat</groupId>
+            <artifactId>catalina</artifactId>
+            <version>6.0.43</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
     <build>
@@ -99,5 +106,5 @@
             </plugin>
         </plugins>
     </build>
-    
+
 </project>

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmFactory.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmFactory.java b/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmFactory.java
new file mode 100644
index 0000000..f39e50e
--- /dev/null
+++ b/modules/jta/src/main/java/org/apache/ignite/cache/jta/jndi/CacheJndiTmFactory.java
@@ -0,0 +1,132 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.cache.jta.jndi;
+
+import java.util.Arrays;
+import java.util.Hashtable;
+import java.util.Map;
+import javax.cache.configuration.Factory;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.transaction.TransactionManager;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.internal.util.typedef.internal.U;
+
+/**
+ * Implementation of {@code Factory<TransactionManager>} interface that is using JNDI names to find TM.
+ * <p>
+ * Note that {@link #create()} method iterates by JNDI names and returns the first found
+ * {@link TransactionManager} instance at context.
+ */
+public class CacheJndiTmFactory implements Factory<TransactionManager> {
+    /** */
+    private static final long serialVersionUID = 0;
+
+    /** */
+    private String[] jndiNames;
+
+    /** */
+    private Map<?, ?> environment;
+
+    /**
+     * Creates uninitialized jndi TM lookup.
+     */
+    public CacheJndiTmFactory() {
+        /* No-op. */
+    }
+
+    /**
+     * Creates generic TM lookup with given jndi names.
+     *
+     * @param jndiNames JNDI names that is used to find TM.
+     */
+    public CacheJndiTmFactory(String... jndiNames) {
+        this.jndiNames = jndiNames;
+    }
+
+    /**
+     * Gets a list of JNDI names.
+     *
+     * @return List of JNDI names that is used to find TM.
+     */
+    public String[] getJndiNames() {
+        return jndiNames;
+    }
+
+    /**
+     * Sets JNDI names used by this TM factory.
+     *
+     * @param jndiNames JNDI names that is used to find TM.
+     */
+    public void setJndiNames(String... jndiNames) {
+        this.jndiNames = jndiNames;
+    }
+
+    /**
+     * Gets initial context environment map.
+     *
+     * @return Initial context environment map.
+     */
+    public Map<?, ?> getInitialContextEnvironment() {
+        return environment;
+    }
+
+    /**
+     * Sets initial context environment map that will be used
+     * in {@link InitialContext#InitialContext(Hashtable)} constructor.
+     *
+     * @param environment Initial context environment map.
+     */
+    public void setInitialContextEnvironment(Map<?, ?> environment) {
+        this.environment = environment;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("UseOfObsoleteCollectionType")
+    @Override public TransactionManager create() {
+        assert jndiNames != null;
+        assert jndiNames.length != 0;
+
+        InitialContext ctx;
+
+        try {
+            ctx = new InitialContext(environment == null ? null : new Hashtable<>(environment));
+        }
+        catch (NamingException e) {
+            throw new IgniteException("Failed to instantiate InitialContext: " + environment, e);
+        }
+
+        for (String s : jndiNames) {
+            Object obj;
+
+            try {
+                obj = ctx.lookup(s);
+            }
+            catch (NamingException e) {
+                U.warn(null, "Failed to lookup resourse: " + e);
+
+                continue;
+            }
+
+            if (obj != null && obj instanceof TransactionManager)
+                return (TransactionManager) obj;
+        }
+
+        throw new IgniteException("Failed to lookup TM by: " + Arrays.toString(jndiNames));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
index 28e2791..a65a4f8 100644
--- a/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
+++ b/modules/jta/src/main/java/org/apache/ignite/internal/processors/cache/jta/CacheJtaManager.java
@@ -18,6 +18,7 @@
 package org.apache.ignite.internal.processors.cache.jta;
 
 import java.util.concurrent.atomic.AtomicReference;
+import javax.cache.configuration.Factory;
 import javax.transaction.RollbackException;
 import javax.transaction.SystemException;
 import javax.transaction.Transaction;
@@ -43,11 +44,46 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
     /** */
     private final AtomicReference<CacheTmLookup> tmLookupRef = new AtomicReference<>();
 
+    /** */
+    private Factory<TransactionManager> tmFactory;
+
     /** {@inheritDoc} */
     @Override protected void start0() throws IgniteCheckedException {
         super.start0();
 
         if (cctx.txConfig() != null) {
+            tmFactory = cctx.txConfig().getTxManagerFactory();
+
+            if (tmFactory != null) {
+                cctx.kernalContext().resource().injectGeneric(tmFactory);
+
+                if (tmFactory instanceof LifecycleAware)
+                    ((LifecycleAware)tmFactory).start();
+
+                Object txMgr;
+
+                try {
+                    txMgr = tmFactory.create();
+                }
+                catch (Exception e) {
+                    throw new IgniteCheckedException("Failed to create transaction manager [tmFactory="
+                        + tmFactory + "]", e);
+                }
+
+                if (txMgr == null)
+                    throw new IgniteCheckedException("Failed to create transaction manager (transaction manager " +
+                        "factory created null-value transaction manager) [tmFactory=" + tmFactory + "]");
+
+                if (!(txMgr instanceof TransactionManager))
+                    throw new IgniteCheckedException("Failed to create transaction manager (transaction manager " +
+                        "factory created object that is not an instance of TransactionManager) [tmFactory="
+                        + tmFactory + ", txMgr=" + txMgr + "]");
+
+                jtaTm = (TransactionManager)txMgr;
+
+                return;
+            }
+
             String txLookupClsName = cctx.txConfig().getTxManagerLookupClassName();
 
             if (txLookupClsName != null)
@@ -61,6 +97,9 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
 
         if (tmLookup instanceof LifecycleAware)
             ((LifecycleAware)tmLookup).stop();
+
+        if (tmFactory instanceof LifecycleAware)
+            ((LifecycleAware)tmFactory).stop();
     }
 
     /**
@@ -172,4 +211,4 @@ public class CacheJtaManager extends CacheJtaManagerAdapter {
     @Nullable @Override public Object tmLookup() {
         return tmLookupRef.get();
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/AbstarctCacheJtaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/AbstarctCacheJtaSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/AbstarctCacheJtaSelfTest.java
new file mode 100644
index 0000000..41c4565
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/AbstarctCacheJtaSelfTest.java
@@ -0,0 +1,183 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import javax.transaction.Status;
+import javax.transaction.UserTransaction;
+import org.apache.ignite.IgniteCache;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.transactions.Transaction;
+import org.objectweb.jotm.Jotm;
+
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+import static org.apache.ignite.transactions.TransactionState.ACTIVE;
+
+/**
+ * Abstract class for cache tests.
+ */
+public abstract class AbstarctCacheJtaSelfTest extends GridCacheAbstractSelfTest {
+    /** */
+    private static final int GRID_CNT = 1;
+
+    /** Java Open Transaction Manager facade. */
+    protected static Jotm jotm;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        jotm = new Jotm(true, false);
+
+        super.beforeTestsStarted();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        super.afterTestsStopped();
+
+        jotm.stop();
+    }
+
+    /** {@inheritDoc} */
+    @Override protected int gridCount() {
+        return GRID_CNT;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return PARTITIONED;
+    }
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        configureJta(cfg);
+
+        CacheConfiguration cfg1 = cacheConfiguration(gridName);
+
+        CacheConfiguration cfg2 = cacheConfiguration(gridName);
+
+        cfg2.setName("cache-2");
+
+        cfg.setCacheConfiguration(cfg1, cfg2);
+
+        return cfg;
+    }
+
+    /**
+     * @param cfg Ignite Configuration.
+     */
+    protected abstract void configureJta(IgniteConfiguration cfg);
+
+    /**
+     * JUnit.
+     *
+     * @throws Exception If failed.
+     */
+    public void testJta() throws Exception {
+        UserTransaction jtaTx = jotm.getUserTransaction();
+
+        IgniteCache<String, Integer> cache = jcache();
+
+        assert ignite(0).transactions().tx() == null;
+
+        jtaTx.begin();
+
+        try {
+            assert ignite(0).transactions().tx() == null;
+
+            assert cache.getAndPut("key", 1) == null;
+
+            Transaction tx = ignite(0).transactions().tx();
+
+            assert tx != null;
+            assert tx.state() == ACTIVE;
+
+            Integer one = 1;
+
+            assertEquals(one, cache.get("key"));
+
+            tx = ignite(0).transactions().tx();
+
+            assert tx != null;
+            assert tx.state() == ACTIVE;
+
+            jtaTx.commit();
+
+            assert ignite(0).transactions().tx() == null;
+        }
+        finally {
+            if (jtaTx.getStatus() == Status.STATUS_ACTIVE)
+                jtaTx.rollback();
+        }
+
+        assertEquals((Integer)1, cache.get("key"));
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    @SuppressWarnings("ConstantConditions")
+    public void testJtaTwoCaches() throws Exception {
+        UserTransaction jtaTx = jotm.getUserTransaction();
+
+        IgniteEx ignite = grid(0);
+
+        IgniteCache<String, Integer> cache1 = jcache();
+
+        IgniteCache<Object, Object> cache2 = ignite.cache("cache-2");
+
+        assertNull(ignite.transactions().tx());
+
+        jtaTx.begin();
+
+        try {
+            cache1.put("key", 0);
+            cache2.put("key", 0);
+            cache1.put("key1", 1);
+            cache2.put("key2", 2);
+
+            assertEquals(0, (int)cache1.get("key"));
+            assertEquals(0, (int)cache1.get("key"));
+            assertEquals(1, (int)cache1.get("key1"));
+            assertEquals(2, (int)cache2.get("key2"));
+
+            assertEquals(ignite.transactions().tx().state(), ACTIVE);
+
+            jtaTx.commit();
+
+            assertNull(ignite.transactions().tx());
+
+            assertEquals(0, (int)cache1.get("key"));
+            assertEquals(0, (int)cache2.get("key"));
+            assertEquals(1, (int)cache1.get("key1"));
+            assertEquals(2, (int)cache2.get("key2"));
+        }
+        finally {
+            if (jtaTx.getStatus() == Status.STATUS_ACTIVE)
+                jtaTx.rollback();
+        }
+
+        assertEquals(0, (int)cache1.get("key"));
+        assertEquals(0, (int)cache2.get("key"));
+        assertEquals(1, (int)cache1.get("key1"));
+        assertEquals(2, (int)cache2.get("key2"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java
new file mode 100644
index 0000000..0dee4be
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/CacheJndiTmFactorySelfTest.java
@@ -0,0 +1,166 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.transaction.HeuristicMixedException;
+import javax.transaction.HeuristicRollbackException;
+import javax.transaction.InvalidTransactionException;
+import javax.transaction.NotSupportedException;
+import javax.transaction.RollbackException;
+import javax.transaction.SystemException;
+import javax.transaction.Transaction;
+import javax.transaction.TransactionManager;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.jta.jndi.CacheJndiTmFactory;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+/**
+ *
+ */
+public class CacheJndiTmFactorySelfTest extends GridCommonAbstractTest {
+    /** */
+    private static final String TM_JNDI_NAME = "java:/comp/env/tm/testtm1";
+
+    /** */
+    private static final String TM_JNDI_NAME2 = "java:/comp/env/tm/testtm2";
+
+    /** */
+    private static final String NOT_TM_JNDI_NAME = "java:/comp/env/tm/wrongClass";
+
+    /** */
+    private String initCtxFactoryBackup;
+
+    /** */
+    private String urlPkgPrefixesBackup;
+
+    /** {@inheritDoc} */
+    @Override protected void beforeTestsStarted() throws Exception {
+        super.beforeTestsStarted();
+
+        initCtxFactoryBackup = System.getProperty(Context.INITIAL_CONTEXT_FACTORY);
+        urlPkgPrefixesBackup = System.getProperty(Context.URL_PKG_PREFIXES);
+
+        // Create initial context
+        System.setProperty(Context.INITIAL_CONTEXT_FACTORY, "org.apache.naming.java.javaURLContextFactory");
+        System.setProperty(Context.URL_PKG_PREFIXES, "org.apache.naming");
+
+        InitialContext ic = new InitialContext();
+
+        ic.createSubcontext("java:");
+        ic.createSubcontext("java:/comp");
+        ic.createSubcontext("java:/comp/env");
+        ic.createSubcontext("java:/comp/env/tm");
+
+        ic.bind(TM_JNDI_NAME, new TestTransactionManager());
+        ic.bind(TM_JNDI_NAME2, new TestTransactionManager2());
+        ic.bind(NOT_TM_JNDI_NAME, 1);
+    }
+
+    /** {@inheritDoc} */
+    @Override protected void afterTestsStopped() throws Exception {
+        if (initCtxFactoryBackup != null)
+            System.setProperty(Context.INITIAL_CONTEXT_FACTORY, initCtxFactoryBackup);
+
+        if (urlPkgPrefixesBackup != null)
+            System.setProperty(Context.URL_PKG_PREFIXES, urlPkgPrefixesBackup);
+
+        super.afterTestsStopped();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFactory() throws Exception {
+        CacheJndiTmFactory f = new CacheJndiTmFactory("wrongJndiName", NOT_TM_JNDI_NAME, TM_JNDI_NAME2, TM_JNDI_NAME);
+
+        TransactionManager mgr = f.create();
+
+        assertNotNull(mgr);
+
+        assertTrue("Mgr: " + mgr, mgr instanceof TestTransactionManager2);
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFactoryException() throws Exception {
+        final CacheJndiTmFactory f = new CacheJndiTmFactory("wrongJndiName", NOT_TM_JNDI_NAME, "wrongJndiName2");
+
+        GridTestUtils.assertThrows(log, new Callable<TransactionManager>() {
+            @Override public TransactionManager call() throws Exception {
+                return f.create();
+            }
+        }, IgniteException.class, "Failed to lookup TM by");
+    }
+
+    /**
+     *
+     */
+    public static class TestTransactionManager implements TransactionManager {
+        /** {@inheritDoc} */
+        @Override public void begin() throws NotSupportedException, SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public void commit() throws RollbackException, HeuristicMixedException, HeuristicRollbackException,
+            SecurityException, IllegalStateException, SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public int getStatus() throws SystemException {
+            return 0;
+        }
+
+        /** {@inheritDoc} */
+        @Override public Transaction getTransaction() throws SystemException {
+            return null;
+        }
+
+        /** {@inheritDoc} */
+        @Override public void resume(Transaction tobj) throws InvalidTransactionException, IllegalStateException,
+            SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public void rollback() throws IllegalStateException, SecurityException, SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public void setRollbackOnly() throws IllegalStateException, SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public void setTransactionTimeout(int seconds) throws SystemException {
+        }
+
+        /** {@inheritDoc} */
+        @Override public Transaction suspend() throws SystemException {
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    public static class TestTransactionManager2 extends TestTransactionManager{
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java
index 8935b91..83127d1 100644
--- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaConfigurationValidationSelfTest.java
@@ -49,6 +49,8 @@ public class GridCacheJtaConfigurationValidationSelfTest extends GridCommonAbstr
     }
 
     /**
+     * Tests that a user did not set 'transactionManagerLookupClassName' property for atomic cache.
+     *
      * @throws Exception If failed.
      */
     public void testAtomicWithTmLookup() throws Exception {
@@ -71,4 +73,4 @@ public class GridCacheJtaConfigurationValidationSelfTest extends GridCommonAbstr
             return null;
         }
     }
-}
\ No newline at end of file
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java
new file mode 100644
index 0000000..2208b6c
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaFactoryConfigValidationSelfTest.java
@@ -0,0 +1,142 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import javax.cache.configuration.Factory;
+import javax.transaction.TransactionManager;
+import org.apache.ignite.IgniteCheckedException;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.testframework.GridTestUtils;
+import org.apache.ignite.testframework.junits.common.GridCommonAbstractTest;
+
+import static org.apache.ignite.cache.CacheAtomicityMode.ATOMIC;
+
+/**
+ * Configuration validation test.
+ */
+public class GridCacheJtaFactoryConfigValidationSelfTest extends GridCommonAbstractTest {
+    /** */
+    private Factory factory;
+
+    /** {@inheritDoc} */
+    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.getTransactionConfiguration().setTxManagerFactory(factory);
+
+        CacheConfiguration ccfg = new CacheConfiguration();
+
+        ccfg.setAtomicityMode(ATOMIC);
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testNullFactory() throws Exception {
+        factory = new NullTxFactory();
+
+        Throwable e = GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid(0);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, null);
+
+        e.getCause().getMessage().startsWith("Failed to create transaction manager");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testWrongTypeFactory() throws Exception {
+        factory = new IntegerTxFactory();
+
+        Throwable e = GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid(0);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, null);
+
+        e.getCause().getMessage().startsWith("Failed to create transaction manager");
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testExceptionFactory() throws Exception {
+        factory = new ExceptionTxFactory();
+
+        Throwable e = GridTestUtils.assertThrows(log, new Callable<Void>() {
+            @Override public Void call() throws Exception {
+                startGrid(0);
+
+                return null;
+            }
+        }, IgniteCheckedException.class, null);
+
+        e.getCause().getMessage().startsWith("Failed to create transaction manager");
+    }
+
+    /**
+     *
+     */
+    public static class NullTxFactory implements Factory<TransactionManager> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override public TransactionManager create() {
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    public static class IntegerTxFactory implements Factory<Integer> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override public Integer create() {
+            return 1;
+        }
+    }
+
+    /**
+     *
+     */
+    public static class ExceptionTxFactory implements Factory {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** {@inheritDoc} */
+        @Override public Object create() {
+            throw new UnsupportedOperationException();
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaSelfTest.java
deleted file mode 100644
index e8a7a48..0000000
--- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheJtaSelfTest.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import java.util.concurrent.Callable;
-import javax.transaction.Status;
-import javax.transaction.TransactionManager;
-import javax.transaction.UserTransaction;
-import org.apache.ignite.IgniteCache;
-import org.apache.ignite.IgniteException;
-import org.apache.ignite.cache.CacheAtomicityMode;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.jta.CacheTmLookup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.internal.IgniteEx;
-import org.apache.ignite.testframework.GridTestUtils;
-import org.apache.ignite.transactions.Transaction;
-import org.objectweb.jotm.Jotm;
-
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-import static org.apache.ignite.transactions.TransactionState.ACTIVE;
-
-/**
- * Abstract class for cache tests.
- */
-public class GridCacheJtaSelfTest extends GridCacheAbstractSelfTest {
-    /** */
-    private static final int GRID_CNT = 1;
-
-    /** Java Open Transaction Manager facade. */
-    private static Jotm jotm;
-
-    /** {@inheritDoc} */
-    @Override protected void beforeTestsStarted() throws Exception {
-        super.beforeTestsStarted();
-
-        jotm = new Jotm(true, false);
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterTestsStopped() throws Exception {
-        super.afterTestsStopped();
-
-        jotm.stop();
-    }
-
-    /** {@inheritDoc} */
-    @Override protected int gridCount() {
-        return GRID_CNT;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return PARTITIONED;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.getTransactionConfiguration().setTxManagerLookupClassName(TestTmLookup.class.getName());
-        
-        CacheConfiguration cfg1 = cacheConfiguration(gridName);
-
-        CacheConfiguration cfg2 = cacheConfiguration(gridName);
-
-        cfg2.setName("cache-2");
-
-        cfg.setCacheConfiguration(cfg1, cfg2);
-
-        return cfg;
-    }
-
-    /**
-     *
-     */
-    @SuppressWarnings("PublicInnerClass")
-    public static class TestTmLookup implements CacheTmLookup {
-        /** {@inheritDoc} */
-        @Override public TransactionManager getTm() {
-            return jotm.getTransactionManager();
-        }
-    }
-
-    /**
-     *
-     */
-    @SuppressWarnings("PublicInnerClass")
-    public static class TestTmLookup2 implements CacheTmLookup {
-        /** {@inheritDoc} */
-        @Override public TransactionManager getTm() {
-            return null;
-        }
-    }
-
-    /**
-     * JUnit.
-     *
-     * @throws Exception If failed.
-     */
-    public void testJta() throws Exception {
-        UserTransaction jtaTx = jotm.getUserTransaction();
-
-        IgniteCache<String, Integer> cache = jcache();
-
-        assert ignite(0).transactions().tx() == null;
-
-        jtaTx.begin();
-
-        try {
-            assert ignite(0).transactions().tx() == null;
-
-            assert cache.getAndPut("key", 1) == null;
-
-            Transaction tx = ignite(0).transactions().tx();
-
-            assert tx != null;
-            assert tx.state() == ACTIVE;
-
-            Integer one = 1;
-
-            assertEquals(one, cache.get("key"));
-
-            tx = ignite(0).transactions().tx();
-
-            assert tx != null;
-            assert tx.state() == ACTIVE;
-
-            jtaTx.commit();
-
-            assert ignite(0).transactions().tx() == null;
-        }
-        finally {
-            if (jtaTx.getStatus() == Status.STATUS_ACTIVE)
-                jtaTx.rollback();
-        }
-
-        assertEquals((Integer)1, cache.get("key"));
-    }
-
-    /**
-     * @throws Exception If failed.
-     */
-    @SuppressWarnings("ConstantConditions")
-    public void testJtaTwoCaches() throws Exception {
-        UserTransaction jtaTx = jotm.getUserTransaction();
-
-        IgniteEx ignite = grid(0);
-
-        IgniteCache<String, Integer> cache1 = jcache();
-
-        IgniteCache<Object, Object> cache2 = ignite.cache("cache-2");
-
-        assertNull(ignite.transactions().tx());
-
-        jtaTx.begin();
-
-        try {
-            cache1.put("key", 1);
-            cache2.put("key", 1);
-
-            assertEquals(1, (int)cache1.get("key"));
-            assertEquals(1, (int)cache2.get("key"));
-
-            assertEquals(ignite.transactions().tx().state(), ACTIVE);
-
-            jtaTx.commit();
-
-            assertNull(ignite.transactions().tx());
-
-            assertEquals(1, (int)cache1.get("key"));
-            assertEquals(1, (int)cache2.get("key"));
-        }
-        finally {
-            if (jtaTx.getStatus() == Status.STATUS_ACTIVE)
-                jtaTx.rollback();
-        }
-
-        assertEquals(1, (int)cache1.get("key"));
-        assertEquals(1, (int)cache2.get("key"));
-    }
-    
-    /**
-     *
-     */
-    public void testUncompatibleTmLookup() {
-        fail("https://issues.apache.org/jira/browse/IGNITE-1094");
-        
-        final IgniteEx ignite = grid(0);
-        
-        final CacheConfiguration cacheCfg = new CacheConfiguration();
-        
-        cacheCfg.setName("Foo");
-        cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
-        cacheCfg.setTransactionManagerLookupClassName(TestTmLookup2.class.getName());
-        
-        GridTestUtils.assertThrows(log, new Callable<Object>() {
-            @Override public Object call() throws IgniteException {
-                ignite.createCache(cacheCfg);
-                
-                return null;
-            }
-        }, IgniteException.class, null);
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedJtaSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedJtaSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedJtaSelfTest.java
deleted file mode 100644
index 1f8dc81..0000000
--- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridCacheReplicatedJtaSelfTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import org.apache.ignite.cache.CacheMode;
-
-import static org.apache.ignite.cache.CacheMode.REPLICATED;
-
-/**
- * JTA integration test using REPLICATED cache.
- */
-public class GridCacheReplicatedJtaSelfTest extends GridCacheJtaSelfTest {
-    /** {@inheritDoc} */
-    @Override protected CacheMode cacheMode() {
-        return REPLICATED;
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java
new file mode 100644
index 0000000..8582b8e
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridJtaLifecycleAwareSelfTest.java
@@ -0,0 +1,191 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import javax.cache.configuration.Factory;
+import javax.transaction.TransactionManager;
+import org.apache.ignite.Ignite;
+import org.apache.ignite.cache.CacheMode;
+import org.apache.ignite.cache.jta.CacheTmLookup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.NearCacheConfiguration;
+import org.apache.ignite.internal.IgniteKernal;
+import org.apache.ignite.lifecycle.LifecycleAware;
+import org.apache.ignite.resources.IgniteInstanceResource;
+import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
+import org.apache.ignite.testframework.junits.common.GridAbstractLifecycleAwareSelfTest;
+import org.jetbrains.annotations.Nullable;
+
+import static org.apache.ignite.cache.CacheMode.PARTITIONED;
+
+/**
+ * Test for {@link LifecycleAware} support for {@link CacheTmLookup}.
+ */
+public class GridJtaLifecycleAwareSelfTest extends GridAbstractLifecycleAwareSelfTest {
+    /** */
+    private static final String CACHE_NAME = "cache";
+
+    /** */
+    private boolean near;
+
+    /** */
+    private TmConfigurationType tmConfigurationType;
+
+    /**
+     */
+    @SuppressWarnings("PublicInnerClass")
+    public static class TestTxLookup extends GridAbstractLifecycleAwareSelfTest.TestLifecycleAware
+        implements CacheTmLookup {
+        /** */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public void start() {
+            super.start();
+
+            assertNotNull(ignite);
+        }
+
+        /** {@inheritDoc} */
+        @Nullable @Override public TransactionManager getTm() {
+            return null;
+        }
+    }
+
+    /**
+     *
+     */
+    public static class TestTxFactory extends GridAbstractLifecycleAwareSelfTest.TestLifecycleAware
+        implements Factory<TransactionManager> {
+        /** */
+        private static final long serialVersionUID = 0L;
+
+        /** */
+        @IgniteInstanceResource
+        private Ignite ignite;
+
+        /** {@inheritDoc} */
+        @Override public void start() {
+            super.start();
+
+            assertNotNull(ignite);
+        }
+
+        /** {@inheritDoc} */
+        @Override public TransactionManager create() {
+            return null;
+        }
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("unchecked")
+    @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
+        IgniteConfiguration cfg = super.getConfiguration(gridName);
+
+        cfg.setDiscoverySpi(new TcpDiscoverySpi());
+
+        CacheConfiguration ccfg = defaultCacheConfiguration();
+
+        ccfg.setCacheMode(PARTITIONED);
+
+        ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
+
+        ccfg.setCacheMode(CacheMode.PARTITIONED);
+
+        ccfg.setName(CACHE_NAME);
+
+        switch (tmConfigurationType){
+            case CACHE_LOOKUP:
+                ccfg.setTransactionManagerLookupClassName(TestTxLookup.class.getName());
+                break;
+            case GLOBAL_LOOKUP:
+                cfg.getTransactionConfiguration().setTxManagerLookupClassName(TestTxLookup.class.getName());
+                break;
+            case FACTORY:
+                cfg.getTransactionConfiguration().setTxManagerFactory(new TestTxFactory());
+                break;
+        }
+
+        cfg.setCacheConfiguration(ccfg);
+
+        return cfg;
+    }
+
+    /** {@inheritDoc} */
+    @SuppressWarnings("OverlyStrongTypeCast")
+    @Override protected void afterGridStart(Ignite ignite) {
+        TestTxLookup tmLookup =
+            (TestTxLookup)((IgniteKernal) ignite).context().cache().internalCache(CACHE_NAME).context().jta().tmLookup();
+
+        assertNotNull(tmLookup);
+
+        lifecycleAwares.add(tmLookup);
+    }
+
+    /** {@inheritDoc} */
+    @Override public void testLifecycleAware() throws Exception {
+        // No-op, see anothre tests.
+    }
+
+    /** {@inheritDoc} */
+    public void testCacheLookupLifecycleAware() throws Exception {
+        tmConfigurationType = TmConfigurationType.CACHE_LOOKUP;
+
+        checkLifecycleAware();
+    }
+
+    /** {@inheritDoc} */
+    public void testGlobalLookupLifecycleAware() throws Exception {
+        tmConfigurationType = TmConfigurationType.GLOBAL_LOOKUP;
+
+        checkLifecycleAware();
+    }
+
+    /** {@inheritDoc} */
+    public void testFactoryLifecycleAware() throws Exception {
+        tmConfigurationType = TmConfigurationType.FACTORY;
+
+        checkLifecycleAware();
+    }
+
+    /**
+     * @throws Exception If failed.
+     */
+    private void checkLifecycleAware() throws Exception {
+        for (boolean nearEnabled : new boolean[] {true, false}) {
+            near = nearEnabled;
+
+            testLifecycleAware();
+        }
+    }
+
+    /**
+     *
+     */
+    private enum TmConfigurationType {
+        /** */
+        CACHE_LOOKUP,
+
+        /** */
+        GLOBAL_LOOKUP,
+
+        /** */
+        FACTORY}
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaFactorySelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaFactorySelfTest.java
new file mode 100644
index 0000000..8d53d7f
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaFactorySelfTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import javax.cache.configuration.Factory;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.configuration.TransactionConfiguration;
+import org.objectweb.transaction.jta.TransactionManager;
+
+/**
+ * Factory JTA integration test using PARTITIONED cache.
+ */
+public class GridPartitionedCacheJtaFactorySelfTest extends AbstarctCacheJtaSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void configureJta(IgniteConfiguration cfg) {
+        TransactionConfiguration txCfg = cfg.getTransactionConfiguration();
+
+        txCfg.setTxManagerFactory(new Factory<TransactionManager>() {
+            private static final long serialVersionUID = 0L;
+
+            @Override public TransactionManager create() {
+                return jotm.getTransactionManager();
+            }
+        });
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaLookupClassNameSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaLookupClassNameSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaLookupClassNameSelfTest.java
new file mode 100644
index 0000000..ccebb9f
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridPartitionedCacheJtaLookupClassNameSelfTest.java
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import java.util.concurrent.Callable;
+import javax.transaction.TransactionManager;
+import org.apache.ignite.IgniteException;
+import org.apache.ignite.cache.CacheAtomicityMode;
+import org.apache.ignite.cache.jta.CacheTmLookup;
+import org.apache.ignite.configuration.CacheConfiguration;
+import org.apache.ignite.configuration.IgniteConfiguration;
+import org.apache.ignite.internal.IgniteEx;
+import org.apache.ignite.testframework.GridTestUtils;
+
+/**
+ * Lookup class name based JTA integration test using PARTITIONED cache.
+ */
+public class GridPartitionedCacheJtaLookupClassNameSelfTest extends AbstarctCacheJtaSelfTest {
+    /** {@inheritDoc} */
+    @Override protected void configureJta(IgniteConfiguration cfg) {
+        cfg.getTransactionConfiguration().setTxManagerLookupClassName(TestTmLookup.class.getName());
+    }
+
+    /**
+     *
+     */
+    public void testUncompatibleTmLookup() {
+        fail("https://issues.apache.org/jira/browse/IGNITE-1094");
+
+        final IgniteEx ignite = grid(0);
+
+        final CacheConfiguration cacheCfg = new CacheConfiguration();
+
+        cacheCfg.setName("Foo");
+        cacheCfg.setAtomicityMode(CacheAtomicityMode.TRANSACTIONAL);
+        cacheCfg.setTransactionManagerLookupClassName(TestTmLookup2.class.getName());
+
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws IgniteException {
+                ignite.createCache(cacheCfg);
+
+                return null;
+            }
+        }, IgniteException.class, null);
+    }
+
+    /**
+     *
+     */
+    @SuppressWarnings("PublicInnerClass")
+    public static class TestTmLookup implements CacheTmLookup {
+        /** {@inheritDoc} */
+        @Override public TransactionManager getTm() {
+            return jotm.getTransactionManager();
+        }
+    }
+
+    /**
+     *
+     */
+    @SuppressWarnings("PublicInnerClass")
+    public static class TestTmLookup2 implements CacheTmLookup {
+        /** {@inheritDoc} */
+        @Override public TransactionManager getTm() {
+            return null;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaFactorySelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaFactorySelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaFactorySelfTest.java
new file mode 100644
index 0000000..3885447
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaFactorySelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMode;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+
+/**
+ * Factory JTA integration test using REPLICATED cache.
+ */
+public class GridReplicatedCacheJtaFactorySelfTest extends GridPartitionedCacheJtaFactorySelfTest {
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return REPLICATED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaLookupClassNameSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaLookupClassNameSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaLookupClassNameSelfTest.java
new file mode 100644
index 0000000..2b89ba1
--- /dev/null
+++ b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridReplicatedCacheJtaLookupClassNameSelfTest.java
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ignite.internal.processors.cache;
+
+import org.apache.ignite.cache.CacheMode;
+
+import static org.apache.ignite.cache.CacheMode.REPLICATED;
+
+/**
+ * Lookup class name based JTA integration test using REPLICATED cache.
+ */
+public class GridReplicatedCacheJtaLookupClassNameSelfTest extends GridPartitionedCacheJtaLookupClassNameSelfTest {
+    /** {@inheritDoc} */
+    @Override protected CacheMode cacheMode() {
+        return REPLICATED;
+    }
+}

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridTmLookupLifecycleAwareSelfTest.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridTmLookupLifecycleAwareSelfTest.java b/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridTmLookupLifecycleAwareSelfTest.java
deleted file mode 100644
index de02e3c..0000000
--- a/modules/jta/src/test/java/org/apache/ignite/internal/processors/cache/GridTmLookupLifecycleAwareSelfTest.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.ignite.internal.processors.cache;
-
-import javax.transaction.TransactionManager;
-import org.apache.ignite.Ignite;
-import org.apache.ignite.cache.CacheMode;
-import org.apache.ignite.cache.jta.CacheTmLookup;
-import org.apache.ignite.configuration.CacheConfiguration;
-import org.apache.ignite.configuration.IgniteConfiguration;
-import org.apache.ignite.configuration.NearCacheConfiguration;
-import org.apache.ignite.internal.IgniteKernal;
-import org.apache.ignite.lifecycle.LifecycleAware;
-import org.apache.ignite.resources.IgniteInstanceResource;
-import org.apache.ignite.spi.discovery.tcp.TcpDiscoverySpi;
-import org.apache.ignite.testframework.junits.common.GridAbstractLifecycleAwareSelfTest;
-import org.jetbrains.annotations.Nullable;
-
-import static org.apache.ignite.cache.CacheMode.PARTITIONED;
-
-/**
- * Test for {@link LifecycleAware} support for {@link CacheTmLookup}.
- */
-public class GridTmLookupLifecycleAwareSelfTest extends GridAbstractLifecycleAwareSelfTest {
-    /** */
-    private static final String CACHE_NAME = "cache";
-
-    /** */
-    private boolean near;
-
-    /** */
-    private boolean configureGlobalTmLookup;
-
-    /**
-     */
-    @SuppressWarnings("PublicInnerClass")
-    public static class TestTxLookup extends GridAbstractLifecycleAwareSelfTest.TestLifecycleAware
-        implements CacheTmLookup {
-        /** */
-        @IgniteInstanceResource
-        Ignite ignite;
-
-        /** {@inheritDoc} */
-        @Override public void start() {
-            super.start();
-
-            assertNotNull(ignite);
-        }
-
-        /** {@inheritDoc} */
-        @Nullable @Override public TransactionManager getTm() {
-            return null;
-        }
-    }
-
-    /** {@inheritDoc} */
-    @Override protected final IgniteConfiguration getConfiguration(String gridName) throws Exception {
-        IgniteConfiguration cfg = super.getConfiguration(gridName);
-
-        cfg.setDiscoverySpi(new TcpDiscoverySpi());
-
-        CacheConfiguration ccfg = defaultCacheConfiguration();
-
-        ccfg.setCacheMode(PARTITIONED);
-
-        ccfg.setNearConfiguration(near ? new NearCacheConfiguration() : null);
-
-        ccfg.setCacheMode(CacheMode.PARTITIONED);
-
-        ccfg.setName(CACHE_NAME);
-
-        if (configureGlobalTmLookup)
-            cfg.getTransactionConfiguration().setTxManagerLookupClassName(TestTxLookup.class.getName());
-        else
-            ccfg.setTransactionManagerLookupClassName(TestTxLookup.class.getName());
-
-        cfg.setCacheConfiguration(ccfg);
-
-        return cfg;
-    }
-
-    /** {@inheritDoc} */
-    @Override protected void afterGridStart(Ignite ignite) {
-        TestTxLookup tmLookup =
-            (TestTxLookup)((IgniteKernal) ignite).context().cache().internalCache(CACHE_NAME).context().jta().tmLookup();
-
-        assertNotNull(tmLookup);
-
-        lifecycleAwares.add(tmLookup);
-    }
-
-    /** {@inheritDoc} */
-    @Override public void testLifecycleAware() throws Exception {
-        for (boolean nearEnabled : new boolean[] {true, false}) {
-            near = nearEnabled;
-
-            super.testLifecycleAware();
-        }
-    }
-
-    /** {@inheritDoc} */
-    public void testLifecycleAwareGlobal() throws Exception {
-        configureGlobalTmLookup = true;
-
-        super.testLifecycleAware();
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ignite/blob/5ea19a45/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java
----------------------------------------------------------------------
diff --git a/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java b/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java
index 657ee10..6e0c096 100644
--- a/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java
+++ b/modules/jta/src/test/java/org/apache/ignite/testsuites/IgniteJtaTestSuite.java
@@ -18,10 +18,14 @@
 package org.apache.ignite.testsuites;
 
 import junit.framework.TestSuite;
+import org.apache.ignite.internal.processors.cache.CacheJndiTmFactorySelfTest;
 import org.apache.ignite.internal.processors.cache.GridCacheJtaConfigurationValidationSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheJtaSelfTest;
-import org.apache.ignite.internal.processors.cache.GridCacheReplicatedJtaSelfTest;
-import org.apache.ignite.internal.processors.cache.GridTmLookupLifecycleAwareSelfTest;
+import org.apache.ignite.internal.processors.cache.GridCacheJtaFactoryConfigValidationSelfTest;
+import org.apache.ignite.internal.processors.cache.GridPartitionedCacheJtaFactorySelfTest;
+import org.apache.ignite.internal.processors.cache.GridPartitionedCacheJtaLookupClassNameSelfTest;
+import org.apache.ignite.internal.processors.cache.GridReplicatedCacheJtaFactorySelfTest;
+import org.apache.ignite.internal.processors.cache.GridReplicatedCacheJtaLookupClassNameSelfTest;
+import org.apache.ignite.internal.processors.cache.GridJtaLifecycleAwareSelfTest;
 
 /**
  * JTA integration tests.
@@ -34,11 +38,19 @@ public class IgniteJtaTestSuite extends TestSuite {
     public static TestSuite suite() throws Exception {
         TestSuite suite = new TestSuite("JTA Integration Test Suite");
 
-        suite.addTestSuite(GridCacheJtaSelfTest.class);
-        suite.addTestSuite(GridCacheReplicatedJtaSelfTest.class);
-        suite.addTestSuite(GridTmLookupLifecycleAwareSelfTest.class);
+        suite.addTestSuite(GridPartitionedCacheJtaFactorySelfTest.class);
+        suite.addTestSuite(GridReplicatedCacheJtaFactorySelfTest.class);
+
+        suite.addTestSuite(GridPartitionedCacheJtaLookupClassNameSelfTest.class);
+        suite.addTestSuite(GridReplicatedCacheJtaLookupClassNameSelfTest.class);
+
+        suite.addTestSuite(GridJtaLifecycleAwareSelfTest.class);
         suite.addTestSuite(GridCacheJtaConfigurationValidationSelfTest.class);
+        suite.addTestSuite(GridCacheJtaFactoryConfigValidationSelfTest.class);
+
+        // Factory
+        suite.addTestSuite(CacheJndiTmFactorySelfTest.class);
 
         return suite;
     }
-}
\ No newline at end of file
+}


Mime
View raw message