cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject svn commit: r439274 - in /incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src: main/java/org/apache/cayenne/cache/OSQueryCache.java test/java/org/apache/cayenne/cache/OSQueryCacheTst.java
Date Fri, 01 Sep 2006 11:37:51 GMT
Author: aadamchik
Date: Fri Sep  1 04:37:51 2006
New Revision: 439274

URL: http://svn.apache.org/viewvc?rev=439274&view=rev
Log:
exposing preconfigured cache groups

Modified:
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
    incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/cache/OSQueryCacheTst.java

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/cache/OSQueryCache.java?rev=439274&r1=439273&r2=439274&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/main/java/org/apache/cayenne/cache/OSQueryCache.java
Fri Sep  1 04:37:51 2006
@@ -18,6 +18,8 @@
  ****************************************************************/
 package org.apache.cayenne.cache;
 
+import java.util.Collection;
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -96,6 +98,16 @@
 
     public OSQueryCache(GeneralCacheAdministrator cache, Properties properties) {
         init(cache, properties);
+    }
+    
+    /**
+     * Returns a collection of group names that have been configured explicitly via
+     * properties.
+     */
+    public Collection getGroupNames() {
+        return refreshSpecifications != null
+                ? Collections.unmodifiableCollection(refreshSpecifications.keySet())
+                : Collections.EMPTY_SET;
     }
 
     /**

Modified: incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/cache/OSQueryCacheTst.java
URL: http://svn.apache.org/viewvc/incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/cache/OSQueryCacheTst.java?rev=439274&r1=439273&r2=439274&view=diff
==============================================================================
--- incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/cache/OSQueryCacheTst.java
(original)
+++ incubator/cayenne/main/trunk/core/cayenne-jdk1.4/src/test/java/org/apache/cayenne/cache/OSQueryCacheTst.java
Fri Sep  1 04:37:51 2006
@@ -84,6 +84,25 @@
         assertEquals("24 * * * * *", xyz.cronExpression);
         assertEquals(35, xyz.refreshPeriod);
     }
+    
+    public void testGroupNames() {
+
+        Properties props = new Properties();
+        OSQueryCache c1 = new OSQueryCache(new GeneralCacheAdministrator(), props);
+        assertTrue(c1.getGroupNames().isEmpty());
+
+        props.put(OSQueryCache.GROUP_PREFIX + "ABC" + OSQueryCache.REFRESH_SUFFIX, "25");
+        props.put(
+                OSQueryCache.GROUP_PREFIX + "XYZ" + OSQueryCache.CRON_SUFFIX,
+                "24 * * * * *");
+
+        OSQueryCache c2 = new OSQueryCache(new GeneralCacheAdministrator(), props);
+
+        assertEquals(2, c2.getGroupNames().size());
+
+        assertTrue(c2.getGroupNames().contains("ABC"));
+        assertTrue(c2.getGroupNames().contains("XYZ"));
+    }
 
     public void testSize() {
         OSQueryCache cache = new OSQueryCache();



Mime
View raw message