Repository: incubator-ignite Updated Branches: refs/heads/ignite-45 d9d895f3a -> 5b0778f81
IGNITE-45 - Fixing tests. Project: http://git-wip-us.apache.org/repos/asf/incubator-ignite/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-ignite/commit/bd595e8b Tree: http://git-wip-us.apache.org/repos/asf/incubator-ignite/tree/bd595e8b Diff: http://git-wip-us.apache.org/repos/asf/incubator-ignite/diff/bd595e8b Branch: refs/heads/ignite-45 Commit: bd595e8b5bc81537baff78f964d642fe00bb54ac Parents: d9d895f Author: Alexey Goncharuk <agoncha...@gridgain.com> Authored: Mon Mar 16 12:56:08 2015 -0700 Committer: Alexey Goncharuk <agoncha...@gridgain.com> Committed: Mon Mar 16 12:56:08 2015 -0700 ---------------------------------------------------------------------- .../processors/cache/GridCacheProcessor.java | 23 +++++-- .../cache/IgniteCacheAbstractTest.java | 20 ++++-- ...niteCacheAtomicLocalWithStoreInvokeTest.java | 6 +- ...micPrimaryWriteOrderWithStoreInvokeTest.java | 6 +- .../cache/IgniteCacheInvokeReadThroughTest.java | 5 +- ...IgniteCacheAbstractExecutionContextTest.java | 10 +-- .../IgniteCrossCacheTxStoreSelfTest.java | 72 ++++++++++++++------ .../dht/GridCacheGlobalLoadTest.java | 5 +- ...maryWriteOrderWithStoreExpiryPolicyTest.java | 6 +- ...iteCacheAtomicWithStoreExpiryPolicyTest.java | 6 +- ...eCacheExpiryPolicyWithStoreAbstractTest.java | 4 +- .../IgniteCacheTxWithStoreExpiryPolicyTest.java | 6 +- ...iteCacheNoLoadPreviousValueAbstractTest.java | 5 +- .../IgniteCacheNoReadThroughAbstractTest.java | 63 ++++++++++------- .../IgniteCacheNoWriteThroughAbstractTest.java | 5 +- .../testframework/junits/GridAbstractTest.java | 12 +++- 16 files changed, 174 insertions(+), 80 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java ---------------------------------------------------------------------- diff --git a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java index 8be171d..8e3dea9 100644 --- a/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java +++ b/modules/core/src/main/java/org/apache/ignite/internal/processors/cache/GridCacheProcessor.java @@ -50,10 +50,11 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.internal.util.typedef.internal.*; import org.apache.ignite.lang.*; import org.apache.ignite.lifecycle.*; +import org.apache.ignite.marshaller.*; +import org.apache.ignite.marshaller.jdk.*; import org.apache.ignite.spi.*; import org.jetbrains.annotations.*; -import javax.cache.*; import javax.cache.configuration.*; import javax.cache.integration.*; import javax.management.*; @@ -114,6 +115,9 @@ public class GridCacheProcessor extends GridProcessorAdapter { /** */ private IdentityHashMap<CacheStore, ThreadLocal> sesHolders = new IdentityHashMap<>(); + /** Must use JDK marshaller since it is used by discovery to fire custom events. */ + private Marshaller marshaller = new JdkMarshaller(); + /** */ private volatile boolean validateCfg = true; @@ -580,7 +584,7 @@ public class GridCacheProcessor extends GridProcessorAdapter { !ctx.config().getTransactionConfiguration().isTxSerializableEnabled()); for (int i = 0; i < cfgs.length; i++) { - CacheConfiguration<?, ?> cfg = new CacheConfiguration(cfgs[i]); + CacheConfiguration<?, ?> cfg = deepCopy(cfgs[i]); CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, cfg.getName(), cfg); @@ -1555,9 +1559,9 @@ public class GridCacheProcessor extends GridProcessorAdapter { req.deploymentId(IgniteUuid.randomUuid()); try { - CacheConfiguration cfg = new CacheConfiguration(ccfg); + CacheConfiguration cfg = deepCopy(ccfg); - CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, ccfg.getName(), ccfg); + CacheObjectContext cacheObjCtx = ctx.cacheObjects().contextForCache(null, cfg.getName(), cfg); initialize(cfg, cacheObjCtx); @@ -2405,6 +2409,17 @@ public class GridCacheProcessor extends GridProcessorAdapter { } /** + * @param src Object to copy. + * @return Deep copy of the object. + */ + private <T> T deepCopy(T src) throws IgniteCheckedException { + if (src == null) + return null; + + return marshaller.unmarshal(marshaller.marshal(src), src.getClass().getClassLoader()); + } + + /** * @param name Name to mask. * @return Masked name. */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java index 52d634a..dafc810 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAbstractTest.java @@ -132,10 +132,10 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest { if (cfg.getCacheWriterFactory() != null) cfg.setWriteThrough(true); - CacheStore<?, ?> store = cacheStore(); + Factory<CacheStore> storeFactory = cacheStoreFactory(); - if (store != null) { - cfg.setCacheStoreFactory(new FactoryBuilder.SingletonFactory(store)); + if (storeFactory != null) { + cfg.setCacheStoreFactory(storeFactory); cfg.setReadThrough(true); cfg.setWriteThrough(true); cfg.setLoadPreviousValue(true); @@ -150,7 +150,7 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest { /** * @return Cache store. */ - protected CacheStore<?, ?> cacheStore() { + protected Factory<CacheStore> cacheStoreFactory() { return null; } @@ -222,7 +222,17 @@ public abstract class IgniteCacheAbstractTest extends GridCommonAbstractTest { /** * */ - public class TestStore extends CacheStoreAdapter<Object, Object> { + public static class TestStoreFactory implements Factory<CacheStore> { + /** {@inheritDoc} */ + @Override public CacheStore create() { + return new TestStore(); + } + } + + /** + * + */ + public static class TestStore extends CacheStoreAdapter<Object, Object> { /** {@inheritDoc} */ @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) { for (Map.Entry<Object, Object> e : storeMap.entrySet()) http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java index cf06530..77d48e7 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicLocalWithStoreInvokeTest.java @@ -19,12 +19,14 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.store.*; +import javax.cache.configuration.*; + /** * */ public class IgniteCacheAtomicLocalWithStoreInvokeTest extends IgniteCacheAtomicLocalInvokeTest { /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java index a4f9d55..738aa8e 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest.java @@ -19,13 +19,15 @@ package org.apache.ignite.internal.processors.cache; import org.apache.ignite.cache.store.*; +import javax.cache.configuration.*; + /** * */ public class IgniteCacheAtomicPrimaryWriteOrderWithStoreInvokeTest extends IgniteCacheAtomicPrimaryWriteOrderInvokeTest { /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new IgniteCacheAbstractTest.TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java index 42b8991..673bbaf 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteCacheInvokeReadThroughTest.java @@ -22,6 +22,7 @@ import org.apache.ignite.cache.*; import org.apache.ignite.cache.store.*; import org.apache.ignite.configuration.*; +import javax.cache.configuration.*; import javax.cache.processor.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -55,8 +56,8 @@ public class IgniteCacheInvokeReadThroughTest extends IgniteCacheAbstractTest { } /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java index 7575c7a..36f530f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/context/IgniteCacheAbstractExecutionContextTest.java @@ -62,7 +62,7 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach * @throws Exception If failed. */ public void testUsersClassLoader() throws Exception { - UsersClassLoader testClassLdr = new UsersClassLoader(); + UsersClassLoader testClassLdr = (UsersClassLoader)grid(0).configuration().getClassLoader(); Object val = testClassLdr.loadClass(TEST_VALUE).newInstance(); @@ -75,10 +75,10 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach int idx = i % gridCount(); if (idx == 0) - assertEquals(jcache.get(i).getClass().getClassLoader(), testClassLdr); + assertEquals(testClassLdr, jcache.get(i).getClass().getClassLoader()); else - assertEquals(grid(idx).jcache(null).get(i).getClass().getClassLoader(), - grid(idx).configuration().getClassLoader()); + assertEquals(grid(idx).configuration().getClassLoader(), + grid(idx).jcache(null).get(i).getClass().getClassLoader()); } } @@ -90,7 +90,7 @@ public abstract class IgniteCacheAbstractExecutionContextTest extends IgniteCach * @throws MalformedURLException If failed */ public UsersClassLoader() throws MalformedURLException { - super(new URL[]{new URL(GridTestProperties.getProperty("p2p.uri.cls"))}); + super(new URL[] {new URL(GridTestProperties.getProperty("p2p.uri.cls"))}); } } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java index 1095066..89be8b8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/IgniteCrossCacheTxStoreSelfTest.java @@ -24,7 +24,6 @@ import org.apache.ignite.internal.*; import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; import org.apache.ignite.resources.*; -import org.apache.ignite.spi.communication.tcp.*; import org.apache.ignite.testframework.junits.common.*; import org.apache.ignite.transactions.*; import org.jetbrains.annotations.*; @@ -39,17 +38,20 @@ import java.util.concurrent.*; * */ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { + /** */ + private static Map<String, CacheStore> firstStores = new ConcurrentHashMap<>(); + + /** */ + private static Map<String, CacheStore> secondStores = new ConcurrentHashMap<>(); + /** {@inheritDoc} */ @Override protected IgniteConfiguration getConfiguration(String gridName) throws Exception { - TestStore firstStore = new TestStore(); - TestStore secondStore = new TestStore(); - IgniteConfiguration cfg = super.getConfiguration(gridName); - CacheConfiguration cfg1 = cacheConfiguration("cacheA", firstStore); - CacheConfiguration cfg2 = cacheConfiguration("cacheB", firstStore); + CacheConfiguration cfg1 = cacheConfiguration("cacheA", new FirstStoreFactory()); + CacheConfiguration cfg2 = cacheConfiguration("cacheB", new FirstStoreFactory()); - CacheConfiguration cfg3 = cacheConfiguration("cacheC", secondStore); + CacheConfiguration cfg3 = cacheConfiguration("cacheC", new SecondStoreFactory()); CacheConfiguration cfg4 = cacheConfiguration("cacheD", null); cfg.setCacheConfiguration(cfg1, cfg2, cfg3, cfg4); @@ -59,10 +61,10 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { /** * @param cacheName Cache name. - * @param store Cache store. + * @param factory Factory to use. * @return Cache configuration. */ - private CacheConfiguration cacheConfiguration(String cacheName, CacheStore<Object, Object> store) { + private CacheConfiguration cacheConfiguration(String cacheName, Factory<CacheStore> factory) { CacheConfiguration cfg = defaultCacheConfiguration(); cfg.setNearConfiguration(null); @@ -70,9 +72,8 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { cfg.setBackups(1); - if (store != null) { - cfg.setCacheStoreFactory( - new FactoryBuilder.SingletonFactory<CacheStore<? super Object, ? super Object>>(store)); + if (factory != null) { + cfg.setCacheStoreFactory(factory); cfg.setWriteThrough(true); } @@ -90,6 +91,9 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { /** {@inheritDoc} */ @Override protected void afterTestsStopped() throws Exception { stopAllGrids(); + + firstStores.clear(); + secondStores.clear(); } /** {@inheritDoc} */ @@ -105,15 +109,7 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { public void testWriteThrough() throws Exception { IgniteEx grid = grid(0); - TestStore firstStore = null; - - for (CacheConfiguration ccfg : grid(0).configuration().getCacheConfiguration()) { - if (ccfg.getCacheStoreFactory() != null) { - firstStore = (TestStore)ccfg.getCacheStoreFactory().create(); - - break; - } - } + TestStore firstStore = (TestStore)firstStores.get(grid.name()); assertNotNull(firstStore); @@ -301,4 +297,38 @@ public class IgniteCrossCacheTxStoreSelfTest extends GridCommonAbstractTest { return ses; } } + + /** + * + */ + private static class FirstStoreFactory implements Factory<CacheStore> { + /** {@inheritDoc} */ + @Override public CacheStore create() { + String gridName = startingGrid.get(); + + CacheStore store = firstStores.get(gridName); + + if (store == null) + store = F.addIfAbsent(firstStores, gridName, new TestStore()); + + return store; + } + } + + /** + * + */ + private static class SecondStoreFactory implements Factory<CacheStore> { + /** {@inheritDoc} */ + @Override public CacheStore create() { + String gridName = startingGrid.get(); + + CacheStore store = secondStores.get(gridName); + + if (store == null) + store = F.addIfAbsent(secondStores, gridName, new TestStore()); + + return store; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java index b166ed6..fb1c2a3 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/distributed/dht/GridCacheGlobalLoadTest.java @@ -29,6 +29,7 @@ import org.jetbrains.annotations.*; import org.junit.*; import javax.cache.*; +import javax.cache.configuration.*; import java.util.concurrent.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -178,8 +179,8 @@ public class GridCacheGlobalLoadTest extends IgniteCacheAbstractTest { } /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } /** http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java index 5f014bd..6068ec8 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest.java @@ -19,13 +19,15 @@ package org.apache.ignite.internal.processors.cache.expiry; import org.apache.ignite.cache.store.*; +import javax.cache.configuration.*; + /** * */ public class IgniteCacheAtomicPrimaryWriteOrderWithStoreExpiryPolicyTest extends IgniteCacheAtomicPrimaryWriteOrderExpiryPolicyTest{ /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java index 13fa950..714cd54 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheAtomicWithStoreExpiryPolicyTest.java @@ -19,12 +19,14 @@ package org.apache.ignite.internal.processors.cache.expiry; import org.apache.ignite.cache.store.*; +import javax.cache.configuration.*; + /** * */ public class IgniteCacheAtomicWithStoreExpiryPolicyTest extends IgniteCacheAtomicExpiryPolicyTest { /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java index 5a8519f..e536435 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheExpiryPolicyWithStoreAbstractTest.java @@ -43,8 +43,8 @@ public abstract class IgniteCacheExpiryPolicyWithStoreAbstractTest extends Ignit } /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java index 292876f..83306ab 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/expiry/IgniteCacheTxWithStoreExpiryPolicyTest.java @@ -19,12 +19,14 @@ package org.apache.ignite.internal.processors.cache.expiry; import org.apache.ignite.cache.store.*; +import javax.cache.configuration.*; + /** * */ public class IgniteCacheTxWithStoreExpiryPolicyTest extends IgniteCacheTxExpiryPolicyTest { /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java index 4cd8716..858eba5 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoLoadPreviousValueAbstractTest.java @@ -23,6 +23,7 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.transactions.*; +import javax.cache.configuration.*; import java.util.*; import static org.apache.ignite.cache.CacheAtomicityMode.*; @@ -36,8 +37,8 @@ public abstract class IgniteCacheNoLoadPreviousValueAbstractTest extends IgniteC private Integer lastKey = 0; /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java index f734229..bd8e51f 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoReadThroughAbstractTest.java @@ -25,6 +25,7 @@ import org.apache.ignite.internal.util.typedef.*; import org.apache.ignite.lang.*; import org.apache.ignite.transactions.*; +import javax.cache.configuration.*; import javax.cache.integration.*; import javax.cache.processor.*; import java.util.*; @@ -40,32 +41,11 @@ public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAb private Integer lastKey = 0; /** */ - private boolean allowLoad; + private static boolean allowLoad; /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore() { - @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) { - if (!allowLoad) - fail(); - - super.loadCache(clo, args); - } - - @Override public Object load(Object key) { - if (!allowLoad) - fail(); - - return super.load(key); - } - - @Override public Map<Object, Object> loadAll(Iterable<?> keys) { - if (!allowLoad) - fail(); - - return super.loadAll(keys); - } - }; + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new NoReadThroughStoreFactory(); } /** {@inheritDoc} */ @@ -90,6 +70,11 @@ public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAb return ccfg; } + /** {@inheritDoc} */ + @Override protected void beforeTest() throws Exception { + allowLoad = false; + } + /** * @throws Exception If failed. */ @@ -317,4 +302,34 @@ public abstract class IgniteCacheNoReadThroughAbstractTest extends IgniteCacheAb return keys; } + + /** + * + */ + private static class NoReadThroughStoreFactory implements Factory<CacheStore> { + @Override public CacheStore create() { + return new TestStore() { + @Override public void loadCache(IgniteBiInClosure<Object, Object> clo, Object... args) { + if (!allowLoad) + fail(); + + super.loadCache(clo, args); + } + + @Override public Object load(Object key) { + if (!allowLoad) + fail(); + + return super.load(key); + } + + @Override public Map<Object, Object> loadAll(Iterable<?> keys) { + if (!allowLoad) + fail(); + + return super.loadAll(keys); + } + }; + } + } } http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java index 955db49..cb01cff 100644 --- a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/integration/IgniteCacheNoWriteThroughAbstractTest.java @@ -23,6 +23,7 @@ import org.apache.ignite.configuration.*; import org.apache.ignite.internal.processors.cache.*; import org.apache.ignite.transactions.*; +import javax.cache.configuration.*; import javax.cache.processor.*; import java.util.*; @@ -37,8 +38,8 @@ public abstract class IgniteCacheNoWriteThroughAbstractTest extends IgniteCacheA private Integer lastKey = 0; /** {@inheritDoc} */ - @Override protected CacheStore<?, ?> cacheStore() { - return new TestStore(); + @Override protected Factory<CacheStore> cacheStoreFactory() { + return new TestStoreFactory(); } /** {@inheritDoc} */ http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/bd595e8b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java ---------------------------------------------------------------------- diff --git a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java index 68846c3..96e54c5 100644 --- a/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java +++ b/modules/core/src/test/java/org/apache/ignite/testframework/junits/GridAbstractTest.java @@ -90,6 +90,9 @@ public abstract class GridAbstractTest extends TestCase { /** Timestamp for tests. */ private static long ts = System.currentTimeMillis(); + /** Starting grid name. */ + protected static ThreadLocal<String> startingGrid = new ThreadLocal<>(); + static { System.setProperty(IgniteSystemProperties.IGNITE_ATOMIC_CACHE_DELETE_HISTORY_SIZE, "10000"); System.setProperty(IgniteSystemProperties.IGNITE_UPDATE_NOTIFIER, "false"); @@ -644,7 +647,14 @@ public abstract class GridAbstractTest extends TestCase { * @throws Exception If failed. */ protected Ignite startGrid(String gridName, GridSpringResourceContext ctx) throws Exception { - return IgnitionEx.start(optimize(getConfiguration(gridName)), ctx); + startingGrid.set(gridName); + + try { + return IgnitionEx.start(optimize(getConfiguration(gridName)), ctx); + } + finally { + startingGrid.set(null); + } } /**