IGNITE-45 - WIP

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

Branch: refs/heads/ignite-45
Commit: 208db5da90a9d4c8eb4525150fab563df0a015c5
Parents: 378112e
Author: Alexey Goncharuk <agoncha...@gridgain.com>
Authored: Thu Mar 5 19:10:38 2015 -0800
Committer: Alexey Goncharuk <agoncha...@gridgain.com>
Committed: Thu Mar 5 19:10:38 2015 -0800

----------------------------------------------------------------------
 .../cache/IgniteDynamicCacheStartSelfTest.java  | 58 +++++++++++++++++++-
 1 file changed, 55 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ignite/blob/208db5da/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
index a0b593e..d7769e9 100644
--- 
a/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
+++ 
b/modules/core/src/test/java/org/apache/ignite/internal/processors/cache/IgniteDynamicCacheStartSelfTest.java
@@ -45,6 +45,9 @@ public class IgniteDynamicCacheStartSelfTest extends 
GridCommonAbstractTest {
     private static final String TEST_ATTRIBUTE_NAME = "TEST_ATTRIBUTE_NAME";
 
     /** */
+    private boolean cache = true;
+
+    /** */
     public static final IgnitePredicate<ClusterNode> NODE_FILTER = new 
IgnitePredicate<ClusterNode>() {
         /** {@inheritDoc} */
         @Override public boolean apply(ClusterNode n) {
@@ -70,11 +73,13 @@ public class IgniteDynamicCacheStartSelfTest extends 
GridCommonAbstractTest {
 
         cfg.setUserAttributes(F.asMap(TEST_ATTRIBUTE_NAME, testAttribute));
 
-        CacheConfiguration cacheCfg = new CacheConfiguration();
+        if (cache) {
+            CacheConfiguration cacheCfg = new CacheConfiguration();
 
-        cacheCfg.setName(STATIC_CACHE_NAME);
+            cacheCfg.setName(STATIC_CACHE_NAME);
 
-        cfg.setCacheConfiguration(cacheCfg);
+            cfg.setCacheConfiguration(cacheCfg);
+        }
 
         return cfg;
     }
@@ -397,4 +402,51 @@ public class IgniteDynamicCacheStartSelfTest extends 
GridCommonAbstractTest {
             testAttribute = true;
         }
     }
+
+    /**
+     * @throws Exception If failed.
+     */
+    public void testFailWhenStaticCacheExists() throws Exception {
+        GridTestUtils.assertThrows(log, new Callable<Object>() {
+            @Override public Object call() throws Exception {
+                final IgniteKernal kernal = (IgniteKernal)grid(0);
+
+                CacheConfiguration ccfg = new CacheConfiguration();
+                
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+                // Cache is already configured, should fail.
+                ccfg.setName(STATIC_CACHE_NAME);
+
+                return kernal.context().cache().dynamicStartCache(ccfg, 
NODE_FILTER).get();
+            }
+        }, IgniteCheckedException.class, null);
+    }
+
+    /**
+     * @throws Exception If failed. TODO Ignite-45.
+     */
+    public void _testFailWhenStaticCacheExistsOnOtherNode() throws Exception {
+        cache = false;
+
+        startGrid(nodeCount());
+
+        try {
+            GridTestUtils.assertThrows(log, new Callable<Object>() {
+                @Override public Object call() throws Exception {
+                    final IgniteKernal kernal = 
(IgniteKernal)grid(nodeCount());
+
+                    CacheConfiguration ccfg = new CacheConfiguration();
+                    
ccfg.setWriteSynchronizationMode(CacheWriteSynchronizationMode.FULL_SYNC);
+
+                    // Cache is already configured, should fail.
+                    ccfg.setName(STATIC_CACHE_NAME);
+
+                    return kernal.context().cache().dynamicStartCache(ccfg, 
NODE_FILTER).get();
+                }
+            }, IgniteCheckedException.class, null);
+        }
+        finally {
+            stopGrid(nodeCount());
+        }
+    }
 }

Reply via email to