geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jgenen...@apache.org
Subject svn commit: r449093 - in /geronimo/sandbox/gcache/server/src: main/java/org/apache/geronimo/gcache/command/CommandTypes.java test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
Date Fri, 22 Sep 2006 21:16:54 GMT
Author: jgenender
Date: Fri Sep 22 14:16:54 2006
New Revision: 449093

URL: http://svn.apache.org/viewvc?view=rev&rev=449093
Log:
Add ClearCacheCommand

Added:
    geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
  (with props)
Modified:
    geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CommandTypes.java

Modified: geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CommandTypes.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CommandTypes.java?view=diff&rev=449093&r1=449092&r2=449093
==============================================================================
--- geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CommandTypes.java
(original)
+++ geronimo/sandbox/gcache/server/src/main/java/org/apache/geronimo/gcache/command/CommandTypes.java
Fri Sep 22 14:16:54 2006
@@ -3,6 +3,7 @@
 public class CommandTypes {
     public static final int PUT_ENTRY_COMMAND = 1;
     public static final int REMOVE_ENTRY_COMMAND = 2;
+    public static final int CLEARCACHE_COMMAND = 3;
 
     public static Command createCommand(int identifier) {
         Command command = null;
@@ -12,6 +13,9 @@
                 break;
             case(REMOVE_ENTRY_COMMAND):
                 command = new RemoveEntryCommand();
+                break;
+            case(CLEARCACHE_COMMAND):
+                command = new ClearCacheCommand();
                 break;
         }
         return command;

Added: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
URL: http://svn.apache.org/viewvc/geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java?view=auto&rev=449093
==============================================================================
--- geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
(added)
+++ geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
Fri Sep 22 14:16:54 2006
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.geronimo.gcache.command;
+
+import org.testng.annotations.Test;
+import org.apache.geronimo.gcache.CacheInfoHolder;
+import net.sf.ehcache.CacheManager;
+import net.sf.ehcache.Cache;
+import net.sf.ehcache.Element;
+
+public class ClearCacheCommandTest {
+
+    @Test
+    public void testClearCache() throws Exception{
+
+        String cacheName1 = "Test";
+        String cacheName2 = "Test2";
+
+        //Set up a cache
+        CacheManager cacheMgr = CacheManager.create();
+        cacheMgr.addCache(cacheName1);
+        cacheMgr.addCache(cacheName2);
+        Cache cache1 = cacheMgr.getCache(cacheName1);
+        Cache cache2 = cacheMgr.getCache(cacheName2);
+        assert cache1 != null;
+        assert cache2 != null;
+
+        cache1.put(new Element("key1","data1"));
+        cache2.put(new Element("key1","data1"));
+        cache1.put(new Element("key2","data2"));
+        cache2.put(new Element("key2","data2"));
+        cache1.put(new Element("key3","data3"));
+        cache2.put(new Element("key3","data3"));
+
+        assert cache1.getSize() == 3;
+        assert cache2.getSize() == 3;
+
+        //Submit a clear cache
+        ClearCacheCommand command = (ClearCacheCommand)CommandTypes.createCommand(CommandTypes.CLEARCACHE_COMMAND);
+        command.setCacheName(cacheName1);
+
+        CacheInfoHolder info = new CacheInfoHolder(cacheMgr);
+        command.execute(info);
+
+        //Cache1 should be empty
+        assert cache1.getSize() == 0;
+        //Cache2 should not be touched
+        assert cache2.getSize() == 3;
+
+    }
+}

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Date Revision

Propchange: geronimo/sandbox/gcache/server/src/test/java/org/apache/geronimo/gcache/command/ClearCacheCommandTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message