You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2006/02/10 16:19:21 UTC
svn commit: r376728 - in /jakarta/jcs/trunk/src:
test-conf/TestSystemProperties.ccf
test/org/apache/jcs/access/SystemPropetyUnitTest.java
Author: asmuts
Date: Fri Feb 10 07:19:19 2006
New Revision: 376728
URL: http://svn.apache.org/viewcvs?rev=376728&view=rev
Log:
adding tests for system property usage in the value of a config parameter
Added:
jakarta/jcs/trunk/src/test-conf/TestSystemProperties.ccf
jakarta/jcs/trunk/src/test/org/apache/jcs/access/SystemPropetyUnitTest.java
Added: jakarta/jcs/trunk/src/test-conf/TestSystemProperties.ccf
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test-conf/TestSystemProperties.ccf?rev=376728&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/TestSystemProperties.ccf (added)
+++ jakarta/jcs/trunk/src/test-conf/TestSystemProperties.ccf Fri Feb 10 07:19:19 2006
@@ -0,0 +1,23 @@
+# Cache configuration for the 'TestDiskCache' test. The memory cache has a
+# a maximum of 100 objects, so objects should get pushed into the disk cache
+
+jcs.default=indexedDiskCache
+jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=${MY_SYSTEM_PROPERTY_MAX_SIZE}
+jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+
+
+jcs.region.missing=
+jcs.region.missing.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.region.missing.cacheattributes.MaxObjects=${NO_SUCH_PROPERTY}
+jcs.region.missing.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+
+
+##### AUXILIARY CACHES
+
+# Indexed Disk Cache
+jcs.auxiliary.indexedDiskCache=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
+jcs.auxiliary.indexedDiskCache.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
+jcs.auxiliary.indexedDiskCache.attributes.DiskPath=target/test-sandbox/${MY_SYSTEM_PROPERTY_DISK_DIR}
+
+
Added: jakarta/jcs/trunk/src/test/org/apache/jcs/access/SystemPropetyUnitTest.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/access/SystemPropetyUnitTest.java?rev=376728&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/access/SystemPropetyUnitTest.java (added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/access/SystemPropetyUnitTest.java Fri Feb 10 07:19:19 2006
@@ -0,0 +1,57 @@
+package org.apache.jcs.access;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.control.CompositeCacheManager;
+
+import junit.framework.TestCase;
+
+/**
+ *
+ *
+ * @author Aaron Smuts
+ *
+ */
+public class SystemPropetyUnitTest
+ extends TestCase
+{
+
+ /**
+ * Verify that we use a system property for a ${FOO} string in a value.
+ * @throws Exception
+ *
+ */
+ public void testSystemPropertyInValueDelimeter() throws Exception
+ {
+
+ int maxMemory = 1234;
+ System.getProperties().setProperty( "MY_SYSTEM_PROPERTY_DISK_DIR", "system_set" );
+ System.getProperties().setProperty( "MY_SYSTEM_PROPERTY_MAX_SIZE", String.valueOf( maxMemory ) );
+
+ JCS.setConfigFilename( "/TestSystemProperties.ccf" );
+
+ JCS cache = JCS.getInstance( "test1" );
+ assertEquals( "We should have used the system property for the memory size", maxMemory, cache.getCacheAttributes().getMaxObjects() );
+
+ }
+
+ /**
+ * Verify that we use a system property for a ${FOO} string in a value. We define a propety in the
+ * cache.ccf file, but we do not have it as a system property. The default value should be used, if one exists.
+ * @throws Exception
+ *
+ */
+ public void testSystemPropertyMissingInValueDelimeter() throws Exception
+ {
+ System.getProperties().setProperty( "MY_SYSTEM_PROPERTY_DISK_DIR", "system_set" );
+
+ CompositeCacheManager mgr = CompositeCacheManager.getUnconfiguredInstance();
+ mgr.configure( "/TestSystemProperties.ccf" );
+
+ JCS cache = JCS.getInstance( "missing" );
+ // TODO check against the actual default def
+ assertEquals( "We should have used the default property for the memory size", 100, cache.getCacheAttributes().getMaxObjects() );
+
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org