[infinispan-commits] Infinispan SVN: r1509 - in trunk/core/src: main/java/org/infinispan/manager and 1 other directories.
infinispan-commits at lists.jboss.org
infinispan-commits at lists.jboss.org
Mon Feb 15 12:24:09 EST 2010
Author: manik.surtani at jboss.com
Date: 2010-02-15 12:24:08 -0500 (Mon, 15 Feb 2010)
New Revision: 1509
Added:
trunk/core/src/test/java/org/infinispan/config/ConfigurationValidation2Test.java
trunk/core/src/test/java/org/infinispan/config/ConfigurationValidationTest.java
Modified:
trunk/core/src/main/java/org/infinispan/config/Configuration.java
trunk/core/src/main/java/org/infinispan/manager/DefaultCacheManager.java
Log:
[ISPN-346] (Shouldn't be legal to start a non-clustered REPL_ASYNC cache)
Modified: trunk/core/src/main/java/org/infinispan/config/Configuration.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/config/Configuration.java 2010-02-15 14:57:12 UTC (rev 1508)
+++ trunk/core/src/main/java/org/infinispan/config/Configuration.java 2010-02-15 17:24:08 UTC (rev 1509)
@@ -167,6 +167,10 @@
return globalConfiguration;
}
+ public void setGlobalConfiguration(GlobalConfiguration gc) {
+ this.globalConfiguration = gc;
+ }
+
public String getName() {
return name;
}
@@ -722,6 +726,9 @@
// certain combinations are illegal, such as state transfer + DIST
if (clustering.mode.isDistributed() && clustering.stateRetrieval.fetchInMemoryState)
throw new ConfigurationException("Cache cannot use DISTRIBUTION mode and have fetchInMemoryState set to true. Perhaps you meant to enable rehashing?");
+
+ if (clustering.mode.isClustered() && (globalConfiguration.getTransportClass() == null || globalConfiguration.getTransportClass().length() == 0))
+ throw new ConfigurationException("Cache cannot use a clustered mode ("+clustering.mode+") mode and not define a transport!");
}
public boolean isOnePhaseCommit() {
Modified: trunk/core/src/main/java/org/infinispan/manager/DefaultCacheManager.java
===================================================================
--- trunk/core/src/main/java/org/infinispan/manager/DefaultCacheManager.java 2010-02-15 14:57:12 UTC (rev 1508)
+++ trunk/core/src/main/java/org/infinispan/manager/DefaultCacheManager.java 2010-02-15 17:24:08 UTC (rev 1509)
@@ -377,12 +377,13 @@
}
private Cache createCache(String cacheName) {
- Configuration c = null;
+ Configuration c;
if (cacheName.equals(DEFAULT_CACHE_NAME) || !configurationOverrides.containsKey(cacheName))
c = globalConfiguration.getDefaultConfiguration().clone();
else
c = configurationOverrides.get(cacheName);
+ c.setGlobalConfiguration(globalConfiguration);
c.assertValid();
Cache cache = new InternalCacheFactory().createCache(c, globalComponentRegistry, cacheName);
Cache other = caches.putIfAbsent(cacheName, cache);
Added: trunk/core/src/test/java/org/infinispan/config/ConfigurationValidation2Test.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/ConfigurationValidation2Test.java (rev 0)
+++ trunk/core/src/test/java/org/infinispan/config/ConfigurationValidation2Test.java 2010-02-15 17:24:08 UTC (rev 1509)
@@ -0,0 +1,61 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.config;
+
+import org.infinispan.manager.CacheManager;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.Test;
+
+import static org.infinispan.config.Configuration.CacheMode.LOCAL;
+import static org.infinispan.config.Configuration.CacheMode.REPL_ASYNC;
+
+/**
+ * ConfigurationValidationTest.
+ *
+ * @author Sanne Grinovero
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "config.ConfigurationValidationTest")
+public class ConfigurationValidation2Test extends SingleCacheManagerTest {
+
+ public void testWrongCachemodeConfiguration() {
+ cacheManager.getCache().put("key", "value");
+ }
+
+ public void testCachemodeConfiguration() {
+ cacheManager.getCache("local").put("key", "value");
+ }
+
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ GlobalConfiguration gc = GlobalConfiguration.getClusteredDefault();
+ Configuration config = new Configuration();
+ config.setCacheMode(REPL_ASYNC);
+ CacheManager cm = TestCacheManagerFactory.createCacheManager(gc, config);
+ config = new Configuration();
+ config.setCacheMode(LOCAL);
+ cm.defineConfiguration("local", config);
+ return cm;
+ }
+}
\ No newline at end of file
Property changes on: trunk/core/src/test/java/org/infinispan/config/ConfigurationValidation2Test.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
Added: trunk/core/src/test/java/org/infinispan/config/ConfigurationValidationTest.java
===================================================================
--- trunk/core/src/test/java/org/infinispan/config/ConfigurationValidationTest.java (rev 0)
+++ trunk/core/src/test/java/org/infinispan/config/ConfigurationValidationTest.java 2010-02-15 17:24:08 UTC (rev 1509)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.infinispan.config;
+
+import org.infinispan.manager.CacheManager;
+import org.infinispan.manager.DefaultCacheManager;
+import org.infinispan.test.SingleCacheManagerTest;
+import org.infinispan.test.fwk.TestCacheManagerFactory;
+import org.testng.annotations.Test;
+
+import static org.infinispan.config.Configuration.CacheMode.LOCAL;
+import static org.infinispan.config.Configuration.CacheMode.REPL_ASYNC;
+
+/**
+ * ConfigurationValidationTest.
+ *
+ * @author Sanne Grinovero
+ * @since 4.0
+ */
+ at Test(groups = "functional", testName = "config.ConfigurationValidationTest")
+public class ConfigurationValidationTest extends SingleCacheManagerTest {
+
+ @Test (expectedExceptions=ConfigurationException.class)
+ public void testWrongCachemodeConfiguration() {
+ cacheManager.getCache().put("key", "value");
+ }
+
+ public void testCachemodeConfiguration() {
+ cacheManager.getCache("local").put("key", "value");
+ }
+
+
+ @Override
+ protected CacheManager createCacheManager() throws Exception {
+ GlobalConfiguration gc = GlobalConfiguration.getNonClusteredDefault();
+ Configuration config = new Configuration();
+ config.setCacheMode(REPL_ASYNC);
+ CacheManager cm = TestCacheManagerFactory.createCacheManager(gc, config);
+ config = new Configuration();
+ config.setCacheMode(LOCAL);
+ cm.defineConfiguration("local", config);
+ return cm;
+ }
+}
Property changes on: trunk/core/src/test/java/org/infinispan/config/ConfigurationValidationTest.java
___________________________________________________________________
Name: svn:keywords
+ Id Revision
Name: svn:eol-style
+ LF
More information about the infinispan-commits
mailing list