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 tv...@apache.org on 2007/05/10 18:04:27 UTC

svn commit: r536904 [32/38] - in /jakarta/jcs/trunk: ./ auxiliary-builds/javagroups/ auxiliary-builds/javagroups/src/java/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/javagroups/src/test/org/apache/jcs/auxiliary/javagroups/ auxiliary-builds/jd...

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java Thu May 10 09:03:42 2007
@@ -1,291 +1,301 @@
-package org.apache.jcs.auxiliary.remote.server;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation. Licensed 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.
- */
-
-import java.util.LinkedList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.auxiliary.remote.RemoteCacheListenerMockImpl;
-import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
-import org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
-import org.apache.jcs.engine.CacheElement;
-import org.apache.jcs.engine.behavior.ICacheElement;
-
-/**
- * Since the server does not know that it is a server, it is easy to unit test. The factory does all
- * the rmi work.
- * <p>
- * @author Aaron Smuts
- */
-public class RemoteCacheServerUnitTest
-    extends TestCase
-{
-
-    /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
-     * and verify that the second gets an id of 2.
-     * <p>
-     * @throws Exception
-     */
-    public void testAddListenerToCache()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
-
-        String cacheName = "testAddListener";
-
-        // DO WORK
-        server.addCacheListener( cacheName, mockListener1 );
-        server.addCacheListener( cacheName, mockListener2 );
-
-        // VERIFY
-        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
-        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
-    }
-
-    /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
-     * and verify that the second gets an id of 2.
-     * <p>
-     * @throws Exception
-     */
-    public void testAddListenerToAll()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
-
-        // DO WORK
-        // don't specify the cache name
-        server.addCacheListener( mockListener1 );
-        server.addCacheListener( mockListener2 );
-
-        // VERIFY
-        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
-        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
-    }
-
-    /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
-     * and verify that the second gets an id of 2. Call remove Listener and verify that it is
-     * removed.
-     * <p>
-     * @throws Exception
-     */
-    public void testAddListenerToAllThenRemove()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
-
-        String cacheName = "testAddListenerToAllThenRemove";
-
-        // DO WORK
-        server.addCacheListener( cacheName, mockListener1 );
-        server.addCacheListener( cacheName, mockListener2 );
-
-        // VERIFY
-        assertEquals( "Wrong number of listeners.", 2, server.getCacheListeners( cacheName ).eventQMap.size() );
-        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
-        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
-
-        // DO WORK
-        server.removeCacheListener( cacheName, mockListener1.getListenerId() );
-        assertEquals( "Wrong number of listeners.", 1, server.getCacheListeners( cacheName ).eventQMap.size() );
-    }
-
-    /**
-     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
-     * and verify that the second gets an id of 2. Call remove Listener and verify that it is
-     * removed.
-     * <p>
-     * @throws Exception
-     */
-    public void testAddListenerToAllThenRemove_clusterType()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
-        mockListener1.remoteType = IRemoteCacheServerAttributes.CLUSTER;
-        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
-        mockListener2.remoteType = IRemoteCacheServerAttributes.CLUSTER;
-
-        String cacheName = "testAddListenerToAllThenRemove";
-
-        // DO WORK
-        server.addCacheListener( cacheName, mockListener1 );
-        server.addCacheListener( cacheName, mockListener2 );
-
-        // VERIFY
-        assertEquals( "Wrong number of listeners.", 0, server.getCacheListeners( cacheName ).eventQMap.size() );
-        assertEquals( "Wrong number of listeners.", 2, server.getClusterListeners( cacheName ).eventQMap.size() );
-        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
-        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
-
-        // DO WORK
-        server.removeCacheListener( cacheName, mockListener1.getListenerId() );
-        assertEquals( "Wrong number of listeners.", 1, server.getClusterListeners( cacheName ).eventQMap.size() );
-    }    
-    
-    /**
-     * Register a listener and then verify that it is called when we put using a different listener
-     * id.
-     * @throws Exception
-     */
-    public void testSimpleRegisterListenerAndPut()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-
-        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        String cacheName = "testSimpleRegisterListenerAndPut";
-        server.addCacheListener( cacheName, mockListener );
-
-        // DO WORK
-        List inputItems = new LinkedList();
-        int numToPut = 10;
-
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Long( i ) );
-            inputItems.add( element );
-            server.update( element, 9999 );
-        }
-
-        Thread.sleep( 100 );
-        Thread.yield();
-        Thread.sleep( 100 );
-
-        // VERIFY
-        assertEquals( "Wrong number of items put to listener.", numToPut, mockListener.putItems.size() );
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            assertEquals( "Wrong item.", inputItems.get( i ), mockListener.putItems.get( i ) );
-        }
-    }
-
-    /**
-     * Register a listener and then verify that it is called when we put using a different listener
-     * id. The updates should come from a cluster listener and local cluster consistency should be
-     * true.
-     * <p>
-     * @throws Exception
-     */
-    public void testSimpleRegisterListenerAndPut_FromClusterWithLCC()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setLocalClusterConsistency( true );
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        // this is to get the listenr id for inserts.
-        RemoteCacheListenerMockImpl clusterListener = new RemoteCacheListenerMockImpl();
-        clusterListener.remoteType = IRemoteCacheAttributes.CLUSTER;
-
-        // this should get the updates
-        RemoteCacheListenerMockImpl localListener = new RemoteCacheListenerMockImpl();
-        localListener.remoteType = IRemoteCacheAttributes.LOCAL;
-
-        String cacheName = "testSimpleRegisterListenerAndPut_FromClusterWithLCC";
-        server.addCacheListener( cacheName, clusterListener );
-        server.addCacheListener( cacheName, localListener );
-
-        // DO WORK
-        List inputItems = new LinkedList();
-        int numToPut = 10;
-
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Long( i ) );
-            inputItems.add( element );
-            // update using the cluster listener id
-            server.update( element, clusterListener.getListenerId() );
-        }
-
-        Thread.sleep( 100 );
-        Thread.yield();
-        Thread.sleep( 100 );
-
-        // VERIFY
-        assertEquals( "Wrong number of items put to listener.", numToPut, localListener.putItems.size() );
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            assertEquals( "Wrong item.", inputItems.get( i ), localListener.putItems.get( i ) );
-        }
-    }
-
-    /**
-     * Register a listener and then verify that it is called when we put using a different listener
-     * id.
-     * @throws Exception
-     */
-    public void testSimpleRegisterListenerAndRemove()
-        throws Exception
-    {
-        // SETUP
-        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
-        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
-
-        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
-        RemoteCacheServer server = new RemoteCacheServer( rcsa );
-
-        String cacheName = "testSimpleRegisterListenerAndPut";
-        server.addCacheListener( cacheName, mockListener );
-
-        // DO WORK
-        int numToPut = 10;
-
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            // use a junk listener id
-            server.remove( cacheName, String.valueOf( i ), 9999 );
-        }
-
-        Thread.sleep( 100 );
-        Thread.yield();
-        Thread.sleep( 100 );
-
-        // VERIFY
-        assertEquals( "Wrong number of items removed from listener.", numToPut, mockListener.removedKeys.size() );
-        for ( int i = 0; i < numToPut; i++ )
-        {
-            assertEquals( "Wrong key.", String.valueOf( i ), mockListener.removedKeys.get( i ) );
-        }
-    }
-
-}
+package org.apache.jcs.auxiliary.remote.server;
+
+/*
+ * 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.
+ */
+
+import java.util.LinkedList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.auxiliary.remote.RemoteCacheListenerMockImpl;
+import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
+import org.apache.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * Since the server does not know that it is a server, it is easy to unit test. The factory does all
+ * the rmi work.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class RemoteCacheServerUnitTest
+    extends TestCase
+{
+
+    /**
+     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * and verify that the second gets an id of 2.
+     * <p>
+     * @throws Exception
+     */
+    public void testAddListenerToCache()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
+        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+
+        String cacheName = "testAddListener";
+
+        // DO WORK
+        server.addCacheListener( cacheName, mockListener1 );
+        server.addCacheListener( cacheName, mockListener2 );
+
+        // VERIFY
+        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
+        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+    }
+
+    /**
+     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * and verify that the second gets an id of 2.
+     * <p>
+     * @throws Exception
+     */
+    public void testAddListenerToAll()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
+        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+
+        // DO WORK
+        // don't specify the cache name
+        server.addCacheListener( mockListener1 );
+        server.addCacheListener( mockListener2 );
+
+        // VERIFY
+        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
+        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+    }
+
+    /**
+     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * and verify that the second gets an id of 2. Call remove Listener and verify that it is
+     * removed.
+     * <p>
+     * @throws Exception
+     */
+    public void testAddListenerToAllThenRemove()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
+        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+
+        String cacheName = "testAddListenerToAllThenRemove";
+
+        // DO WORK
+        server.addCacheListener( cacheName, mockListener1 );
+        server.addCacheListener( cacheName, mockListener2 );
+
+        // VERIFY
+        assertEquals( "Wrong number of listeners.", 2, server.getCacheListeners( cacheName ).eventQMap.size() );
+        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
+        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+
+        // DO WORK
+        server.removeCacheListener( cacheName, mockListener1.getListenerId() );
+        assertEquals( "Wrong number of listeners.", 1, server.getCacheListeners( cacheName ).eventQMap.size() );
+    }
+
+    /**
+     * Add a listner. Pass the id of 0, verify that the server sets a new listener id. Do another
+     * and verify that the second gets an id of 2. Call remove Listener and verify that it is
+     * removed.
+     * <p>
+     * @throws Exception
+     */
+    public void testAddListenerToAllThenRemove_clusterType()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        RemoteCacheListenerMockImpl mockListener1 = new RemoteCacheListenerMockImpl();
+        mockListener1.remoteType = IRemoteCacheServerAttributes.CLUSTER;
+        RemoteCacheListenerMockImpl mockListener2 = new RemoteCacheListenerMockImpl();
+        mockListener2.remoteType = IRemoteCacheServerAttributes.CLUSTER;
+
+        String cacheName = "testAddListenerToAllThenRemove";
+
+        // DO WORK
+        server.addCacheListener( cacheName, mockListener1 );
+        server.addCacheListener( cacheName, mockListener2 );
+
+        // VERIFY
+        assertEquals( "Wrong number of listeners.", 0, server.getCacheListeners( cacheName ).eventQMap.size() );
+        assertEquals( "Wrong number of listeners.", 2, server.getClusterListeners( cacheName ).eventQMap.size() );
+        assertEquals( "Wrong listener id.", 1, mockListener1.getListenerId() );
+        assertEquals( "Wrong listener id.", 2, mockListener2.getListenerId() );
+
+        // DO WORK
+        server.removeCacheListener( cacheName, mockListener1.getListenerId() );
+        assertEquals( "Wrong number of listeners.", 1, server.getClusterListeners( cacheName ).eventQMap.size() );
+    }
+
+    /**
+     * Register a listener and then verify that it is called when we put using a different listener
+     * id.
+     * @throws Exception
+     */
+    public void testSimpleRegisterListenerAndPut()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+
+        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        String cacheName = "testSimpleRegisterListenerAndPut";
+        server.addCacheListener( cacheName, mockListener );
+
+        // DO WORK
+        List inputItems = new LinkedList();
+        int numToPut = 10;
+
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Long( i ) );
+            inputItems.add( element );
+            server.update( element, 9999 );
+        }
+
+        Thread.sleep( 100 );
+        Thread.yield();
+        Thread.sleep( 100 );
+
+        // VERIFY
+        assertEquals( "Wrong number of items put to listener.", numToPut, mockListener.putItems.size() );
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            assertEquals( "Wrong item.", inputItems.get( i ), mockListener.putItems.get( i ) );
+        }
+    }
+
+    /**
+     * Register a listener and then verify that it is called when we put using a different listener
+     * id. The updates should come from a cluster listener and local cluster consistency should be
+     * true.
+     * <p>
+     * @throws Exception
+     */
+    public void testSimpleRegisterListenerAndPut_FromClusterWithLCC()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setLocalClusterConsistency( true );
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        // this is to get the listenr id for inserts.
+        RemoteCacheListenerMockImpl clusterListener = new RemoteCacheListenerMockImpl();
+        clusterListener.remoteType = IRemoteCacheAttributes.CLUSTER;
+
+        // this should get the updates
+        RemoteCacheListenerMockImpl localListener = new RemoteCacheListenerMockImpl();
+        localListener.remoteType = IRemoteCacheAttributes.LOCAL;
+
+        String cacheName = "testSimpleRegisterListenerAndPut_FromClusterWithLCC";
+        server.addCacheListener( cacheName, clusterListener );
+        server.addCacheListener( cacheName, localListener );
+
+        // DO WORK
+        List inputItems = new LinkedList();
+        int numToPut = 10;
+
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Long( i ) );
+            inputItems.add( element );
+            // update using the cluster listener id
+            server.update( element, clusterListener.getListenerId() );
+        }
+
+        Thread.sleep( 100 );
+        Thread.yield();
+        Thread.sleep( 100 );
+
+        // VERIFY
+        assertEquals( "Wrong number of items put to listener.", numToPut, localListener.putItems.size() );
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            assertEquals( "Wrong item.", inputItems.get( i ), localListener.putItems.get( i ) );
+        }
+    }
+
+    /**
+     * Register a listener and then verify that it is called when we put using a different listener
+     * id.
+     * @throws Exception
+     */
+    public void testSimpleRegisterListenerAndRemove()
+        throws Exception
+    {
+        // SETUP
+        IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
+        rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
+
+        RemoteCacheListenerMockImpl mockListener = new RemoteCacheListenerMockImpl();
+        RemoteCacheServer server = new RemoteCacheServer( rcsa );
+
+        String cacheName = "testSimpleRegisterListenerAndPut";
+        server.addCacheListener( cacheName, mockListener );
+
+        // DO WORK
+        int numToPut = 10;
+
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            // use a junk listener id
+            server.remove( cacheName, String.valueOf( i ), 9999 );
+        }
+
+        Thread.sleep( 100 );
+        Thread.yield();
+        Thread.sleep( 100 );
+
+        // VERIFY
+        assertEquals( "Wrong number of items removed from listener.", numToPut, mockListener.removedKeys.size() );
+        for ( int i = 0; i < numToPut; i++ )
+        {
+            assertEquals( "Wrong key.", String.valueOf( i ), mockListener.removedKeys.get( i ) );
+        }
+    }
+
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/EventQueueConcurrentLoadTest.java Thu May 10 09:03:42 2007
@@ -1,19 +1,22 @@
 package org.apache.jcs.engine;
 
 /*
- * Copyright 2001-2004 The Apache Software Foundation.
+ * 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
  *
- * Licensed 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
  *
- *     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.
+ * 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.
  */
 
 import java.io.IOException;
@@ -30,7 +33,7 @@
  * This test case is designed to makes sure there are no deadlocks in the event
  * queue. The time to live should be set to a very short interval to make a
  * deadlock more likely.
- * 
+ *
  * @author Aaron Smuts
  */
 public class EventQueueConcurrentLoadTest
@@ -50,7 +53,7 @@
 
     /**
      * Constructor for the TestDiskCache object.
-     * 
+     *
      * @param testName
      */
     public EventQueueConcurrentLoadTest( String testName )
@@ -60,7 +63,7 @@
 
     /**
      * Main method passes this test to the text test runner.
-     * 
+     *
      * @param args
      */
     public static void main( String args[] )
@@ -71,7 +74,7 @@
 
     /**
      * A unit test suite for JUnit
-     * 
+     *
      * @return The test suite
      */
     public static Test suite()
@@ -167,7 +170,7 @@
 
     /**
      * Adds put events to the queue.
-     * 
+     *
      * @param end
      * @param expectedPutCount
      * @throws Exception
@@ -200,7 +203,7 @@
 
     /**
      * Add remove events to the event queue.
-     * 
+     *
      * @param end
      * @throws Exception
      */
@@ -216,7 +219,7 @@
 
     /**
      * Add remove events to the event queue.
-     * 
+     *
      * @throws Exception
      */
     public void runStopProcessingTest()
@@ -227,7 +230,7 @@
 
     /**
      * Test putting and a delay. Waits until queue is empty to start.
-     * 
+     *
      * @param end
      * @param expectedPutCount
      * @throws Exception
@@ -277,12 +280,12 @@
         System.out.println( "queue is empty, comparing putCount" );
 
         Thread.sleep( 1000 );
-        
+
         // this becomes less accurate with each test. It should never fail. If
         // it does things are very off.
         assertTrue( "The put count [" + listen.putCount + "] is below the expected minimum threshold ["
                     + expectedPutCount + "]", listen.putCount >= ( expectedPutCount - 1 ) );
-        
+
     }
 
     /**
@@ -304,7 +307,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#handlePut(org.apache.jcs.engine.behavior.ICacheElement)
          */
         public void handlePut( ICacheElement item )
@@ -318,7 +321,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemove(java.lang.String,
          *      java.io.Serializable)
          */
@@ -334,7 +337,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#handleRemoveAll(java.lang.String)
          */
         public void handleRemoveAll( String cacheName )
@@ -346,7 +349,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#handleDispose(java.lang.String)
          */
         public void handleDispose( String cacheName )
@@ -358,7 +361,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#setListenerId(long)
          */
         public void setListenerId( long id )
@@ -370,7 +373,7 @@
 
         /*
          * (non-Javadoc)
-         * 
+         *
          * @see org.apache.jcs.engine.behavior.ICacheListener#getListenerId()
          */
         public long getListenerId()
@@ -381,4 +384,4 @@
         }
 
     }
-}
\ No newline at end of file
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/SystemPropertyUsageUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/SystemPropertyUsageUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/SystemPropertyUsageUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/SystemPropertyUsageUnitTest.java Thu May 10 09:03:42 2007
@@ -1,77 +1,80 @@
-package org.apache.jcs.engine;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-import org.apache.jcs.engine.control.CompositeCacheManager;
-import org.apache.jcs.utils.props.PropertyLoader;
-
-/**
- * Verify that system properties can override.
- */
-public class SystemPropertyUsageUnitTest
-    extends TestCase
-{
-
-    /**
-     * Verify that the system properties are used.
-     * @throws Exception
-     *  
-     */
-    public void testSystemPropertyUsage()
-        throws Exception
-    {
-        System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", "6789" );
-
-        JCS.setConfigFilename( "/TestSystemPropertyUsage.ccf" );
-
-        JCS jcs = JCS.getInstance( "someCacheNotInFile" );
-
-        assertEquals( "System property value is not reflected", jcs.getCacheAttributes().getMaxObjects(), Integer
-            .parseInt( "6789" ) );
-
-    }
-
-    /**
-     * Verify that the system properties are not used is specified.
-     * 
-     * @throws Exception
-     *  
-     */
-    public void testSystemPropertyUsage_inactive()
-        throws Exception
-    {
-        System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", "6789" );
-
-        CompositeCacheManager mgr = CompositeCacheManager.getUnconfiguredInstance();
-
-        Properties props = PropertyLoader.loadProperties( "TestSystemPropertyUsage.ccf" );
-
-        mgr.configure( props, false );
-
-        JCS jcs = JCS.getInstance( "someCacheNotInFile" );
-
-        assertFalse( "System property value should not be reflected",
-                     jcs.getCacheAttributes().getMaxObjects() == Integer.parseInt( props
-                         .getProperty( "jcs.default.cacheattributes.MaxObjects" ) ) );
-
-    }
-}
+package org.apache.jcs.engine;
+
+/*
+ * 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.
+ */
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.control.CompositeCacheManager;
+import org.apache.jcs.utils.props.PropertyLoader;
+
+/**
+ * Verify that system properties can override.
+ */
+public class SystemPropertyUsageUnitTest
+    extends TestCase
+{
+
+    /**
+     * Verify that the system properties are used.
+     * @throws Exception
+     *
+     */
+    public void testSystemPropertyUsage()
+        throws Exception
+    {
+        System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", "6789" );
+
+        JCS.setConfigFilename( "/TestSystemPropertyUsage.ccf" );
+
+        JCS jcs = JCS.getInstance( "someCacheNotInFile" );
+
+        assertEquals( "System property value is not reflected", jcs.getCacheAttributes().getMaxObjects(), Integer
+            .parseInt( "6789" ) );
+
+    }
+
+    /**
+     * Verify that the system properties are not used is specified.
+     *
+     * @throws Exception
+     *
+     */
+    public void testSystemPropertyUsage_inactive()
+        throws Exception
+    {
+        System.getProperties().setProperty( "jcs.default.cacheattributes.MaxObjects", "6789" );
+
+        CompositeCacheManager mgr = CompositeCacheManager.getUnconfiguredInstance();
+
+        Properties props = PropertyLoader.loadProperties( "TestSystemPropertyUsage.ccf" );
+
+        mgr.configure( props, false );
+
+        JCS jcs = JCS.getInstance( "someCacheNotInFile" );
+
+        assertFalse( "System property value should not be reflected",
+                     jcs.getCacheAttributes().getMaxObjects() == Integer.parseInt( props
+                         .getProperty( "jcs.default.cacheattributes.MaxObjects" ) ) );
+
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CacheManagerStatsUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CacheManagerStatsUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CacheManagerStatsUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CacheManagerStatsUnitTest.java Thu May 10 09:03:42 2007
@@ -1,68 +1,71 @@
-package org.apache.jcs.engine.control;
-
-/*
- * Copyright 2001-2004 The Apache Software Foundation.
- *
- * Licensed 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.
- */
-
-import org.apache.jcs.JCS;
-import org.apache.jcs.engine.stats.behavior.ICacheStats;
-
-import junit.framework.TestCase;
-
-/**
- * @author Aaron Smuts
- *
- */
-public class CacheManagerStatsUnitTest
-    extends TestCase
-{
-
-    /**
-     * Just get the stats after putting a couple entries in the cache.
-     * 
-     * @throws Exception
-     */
-    public void testSimpleGetStats() throws Exception
-    {
-        JCS cache = JCS.getInstance( "testCache1" );
-
-        // 1 miss, 1 hit, 1 put
-        cache.get( "testKey" );
-        cache.put( "testKey", "testdata" );
-        // should have 4 hits
-        cache.get( "testKey" );
-        cache.get( "testKey" );
-        cache.get( "testKey" );
-        cache.get( "testKey" );
-        
-        CompositeCacheManager mgr = CompositeCacheManager.getInstance();
-        String statsString = mgr.getStats();
-        
-        System.out.println( statsString );
-        
-        assertTrue( "Should have the cacheName in here.", statsString.indexOf("testCache1") != -1 );
-        assertTrue( "Should have the HitCountRam in here.", statsString.indexOf("HitCountRam") != -1 );
-        assertTrue( "Should have the 4 in here.", statsString.indexOf("4") != -1 );
-        
-        ICacheStats[] stats = mgr.getStatistics();
-        int statsLen = stats.length;
-        System.out.println( "statsLen = " + statsLen );
-        for ( int i = 0; i < statsLen; i++ )
-        {
-            // TODO finish
-        }
-    }
-    
-}
+package org.apache.jcs.engine.control;
+
+/*
+ * 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.
+ */
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.stats.behavior.ICacheStats;
+
+import junit.framework.TestCase;
+
+/**
+ * @author Aaron Smuts
+ *
+ */
+public class CacheManagerStatsUnitTest
+    extends TestCase
+{
+
+    /**
+     * Just get the stats after putting a couple entries in the cache.
+     *
+     * @throws Exception
+     */
+    public void testSimpleGetStats() throws Exception
+    {
+        JCS cache = JCS.getInstance( "testCache1" );
+
+        // 1 miss, 1 hit, 1 put
+        cache.get( "testKey" );
+        cache.put( "testKey", "testdata" );
+        // should have 4 hits
+        cache.get( "testKey" );
+        cache.get( "testKey" );
+        cache.get( "testKey" );
+        cache.get( "testKey" );
+
+        CompositeCacheManager mgr = CompositeCacheManager.getInstance();
+        String statsString = mgr.getStats();
+
+        System.out.println( statsString );
+
+        assertTrue( "Should have the cacheName in here.", statsString.indexOf("testCache1") != -1 );
+        assertTrue( "Should have the HitCountRam in here.", statsString.indexOf("HitCountRam") != -1 );
+        assertTrue( "Should have the 4 in here.", statsString.indexOf("4") != -1 );
+
+        ICacheStats[] stats = mgr.getStatistics();
+        int statsLen = stats.length;
+        System.out.println( "statsLen = " + statsLen );
+        for ( int i = 0; i < statsLen; i++ )
+        {
+            // TODO finish
+        }
+    }
+
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java Thu May 10 09:03:42 2007
@@ -1,429 +1,448 @@
-package org.apache.jcs.engine.control;
-
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-import org.apache.jcs.access.exception.CacheException;
-import org.apache.jcs.auxiliary.AuxiliaryCache;
-import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.jcs.engine.CacheElement;
-import org.apache.jcs.engine.CompositeCacheAttributes;
-import org.apache.jcs.engine.ElementAttributes;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
-import org.apache.jcs.engine.behavior.IElementAttributes;
-import org.apache.jcs.engine.stats.behavior.IStats;
-
-/**
- * Tests of the disk usage settings for the CompositeCache.
- * <p>
- * @author Aaron Smuts
- */
-public class CompositeCacheDiskUsageUnitTest
-    extends TestCase
-{
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestDiskCacheUsagePattern.ccf" );
-    }
-
-    /**
-     * Verify that the swap region is set to the correct pattern.
-     * <p>
-     * @throws CacheException
-     */
-    public void testSwapConfig() throws CacheException
-    {
-        JCS swap = JCS.getInstance( "Swap" );
-        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP, swap.getCacheAttributes().getDiskUsagePattern() );
-    }
-    
-    /**
-     * Verify that the swap region is set to the correct pattern.
-     * <p>
-     * @throws CacheException
-     */
-    public void testUpdateConfig() throws CacheException
-    {
-        JCS swap = JCS.getInstance( "Update" );
-        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE, swap.getCacheAttributes().getDiskUsagePattern() );
-    }    
-    
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the
-     * item is put to disk.
-     */
-    public void testSpoolAllowed()
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.spoolToDisk( inputElement );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
-        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
-    }
-
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the
-     * item is not put to disk.
-     */
-    public void testSpoolNotAllowed()
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.spoolToDisk( inputElement );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount );
-    }
-
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries.
-     * Verify that the item is put to disk.
-     * <p>
-     * This tests that the items are put to disk on a normal put when the usage pattern is set
-     * appropriately.
-     * @throws IOException
-     */
-    public void testUpdateAllowed()
-        throws IOException
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.updateAuxiliaries( inputElement, true );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
-        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
-    }
-
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with
-     * local only set to false. Verify that the item is put to disk.
-     * <p>
-     * This tests that the items are put to disk on a normal put when the usage pattern is set
-     * appropriately. The local setting should have no impact on whether the item goes to disk.
-     * <p>
-     * @throws IOException
-     */
-    public void testUpdateAllowed_localFalse()
-        throws IOException
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.updateAuxiliaries( inputElement, false );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
-        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
-    }
-
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to SWAP. Call updateAuxiliaries. Verify
-     * that the item is not put to disk.
-     * <p>
-     * This tests that the items are not put to disk on a normal put when the usage pattern is set
-     * to SWAP.
-     * <p>
-     * @throws IOException
-     */
-    public void testUpdateNotAllowed()
-        throws IOException
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.updateAuxiliaries( inputElement, true );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount );
-    }
-
-    /**
-     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries.
-     * Verify that the item is put to disk.
-     * <p>
-     * This tests that the items are put to disk on a normal put when the usage pattern is set
-     * appropriately.
-     * @throws IOException
-     */
-    public void testUpdateAllowed_withOtherCaches()
-        throws IOException
-    {
-        // SETUP
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
-
-        MockAuxCache mock = new MockAuxCache();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
-
-        MockAuxCache mockLateral = new MockAuxCache();
-        mockLateral.cacheType = AuxiliaryCache.LATERAL_CACHE;
-
-        cache.setAuxCaches( new AuxiliaryCache[] { mock, mockLateral } );
-
-        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
-
-        // DO WORK
-        cache.updateAuxiliaries( inputElement, false );
-
-        // VERIFY
-        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
-        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
-
-        assertEquals( "Wrong number of calls to the lateral cache update.", 1, mockLateral.updateCount );
-        assertEquals( "Wrong element updated with lateral.", inputElement, mockLateral.lastUpdatedItem );
-    }
-
-    /**
-     * Used to test the disk cache functionality.
-     * <p>
-     * @author Aaron Smuts
-     */
-    public class MockAuxCache
-        implements AuxiliaryCache
-    {
-        private static final long serialVersionUID = 1L;
-
-        /**
-         * The last item passed to update.
-         */
-        public ICacheElement lastUpdatedItem;
-
-        /**
-         * The number of times update was called.
-         */
-        public int updateCount = 0;
-
-        /**
-         * The type that should be returned from getCacheType.
-         */
-        public int cacheType = AuxiliaryCache.DISK_CACHE;
-
-        /**
-         * Resets counters and catchers.
-         */
-        public void reset()
-        {
-            updateCount = 0;
-            lastUpdatedItem = null;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
-         */
-        public void update( ICacheElement ce )
-            throws IOException
-        {
-            lastUpdatedItem = ce;
-            updateCount++;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
-         */
-        public ICacheElement get( Serializable key )
-            throws IOException
-        {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
-         */
-        public boolean remove( Serializable key )
-            throws IOException
-        {
-            // TODO Auto-generated method stub
-            return false;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#removeAll()
-         */
-        public void removeAll()
-            throws IOException
-        {
-            // TODO Auto-generated method stub
-
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#dispose()
-         */
-        public void dispose()
-            throws IOException
-        {
-            // TODO Auto-generated method stub
-
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getSize()
-         */
-        public int getSize()
-        {
-            // TODO Auto-generated method stub
-            return 0;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
-         */
-        public int getStatus()
-        {
-            // TODO Auto-generated method stub
-            return 0;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getCacheName()
-         */
-        public String getCacheName()
-        {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
-         */
-        public Set getGroupKeys( String group )
-            throws IOException
-        {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
-         */
-        public IStats getStatistics()
-        {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /*
-         * (non-Javadoc)
-         * @see org.apache.jcs.engine.behavior.ICache#getStats()
-         */
-        public String getStats()
-        {
-            // TODO Auto-generated method stub
-            return null;
-        }
-
-        /**
-         * Returns the setup cache type. This allows you to use this mock as multiple cache types.
-         * <p>
-         * (non-Javadoc)
-         * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
-         */
-        public int getCacheType()
-        {
-            return cacheType;
-        }
-
-        /**
-         * @return Returns the AuxiliaryCacheAttributes.
-         */
-        public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
-        {
-            return null;
-        }
-    }
-
-}
+package org.apache.jcs.engine.control;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.access.exception.CacheException;
+import org.apache.jcs.auxiliary.AuxiliaryCache;
+import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.CompositeCacheAttributes;
+import org.apache.jcs.engine.ElementAttributes;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.stats.behavior.IStats;
+
+/**
+ * Tests of the disk usage settings for the CompositeCache.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class CompositeCacheDiskUsageUnitTest
+    extends TestCase
+{
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestDiskCacheUsagePattern.ccf" );
+    }
+
+    /**
+     * Verify that the swap region is set to the correct pattern.
+     * <p>
+     * @throws CacheException
+     */
+    public void testSwapConfig() throws CacheException
+    {
+        JCS swap = JCS.getInstance( "Swap" );
+        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP, swap.getCacheAttributes().getDiskUsagePattern() );
+    }
+
+    /**
+     * Verify that the swap region is set to the correct pattern.
+     * <p>
+     * @throws CacheException
+     */
+    public void testUpdateConfig() throws CacheException
+    {
+        JCS swap = JCS.getInstance( "Update" );
+        assertEquals( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE, swap.getCacheAttributes().getDiskUsagePattern() );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to swap. Call spool. Verify that the
+     * item is put to disk.
+     */
+    public void testSpoolAllowed()
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.spoolToDisk( inputElement );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
+        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to not swap. Call spool. Verify that the
+     * item is not put to disk.
+     */
+    public void testSpoolNotAllowed()
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.spoolToDisk( inputElement );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries.
+     * Verify that the item is put to disk.
+     * <p>
+     * This tests that the items are put to disk on a normal put when the usage pattern is set
+     * appropriately.
+     * @throws IOException
+     */
+    public void testUpdateAllowed()
+        throws IOException
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.updateAuxiliaries( inputElement, true );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
+        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries with
+     * local only set to false. Verify that the item is put to disk.
+     * <p>
+     * This tests that the items are put to disk on a normal put when the usage pattern is set
+     * appropriately. The local setting should have no impact on whether the item goes to disk.
+     * <p>
+     * @throws IOException
+     */
+    public void testUpdateAllowed_localFalse()
+        throws IOException
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.updateAuxiliaries( inputElement, false );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
+        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to SWAP. Call updateAuxiliaries. Verify
+     * that the item is not put to disk.
+     * <p>
+     * This tests that the items are not put to disk on a normal put when the usage pattern is set
+     * to SWAP.
+     * <p>
+     * @throws IOException
+     */
+    public void testUpdateNotAllowed()
+        throws IOException
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_SWAP );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.updateAuxiliaries( inputElement, true );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 0, mock.updateCount );
+    }
+
+    /**
+     * Setup a disk cache. Configure the disk usage pattern to UPDATE. Call updateAuxiliaries.
+     * Verify that the item is put to disk.
+     * <p>
+     * This tests that the items are put to disk on a normal put when the usage pattern is set
+     * appropriately.
+     * @throws IOException
+     */
+    public void testUpdateAllowed_withOtherCaches()
+        throws IOException
+    {
+        // SETUP
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setDiskUsagePattern( ICompositeCacheAttributes.DISK_USAGE_PATTERN_UPDATE );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( "testSpoolAllowed", cattr, attr );
+
+        MockAuxCache mock = new MockAuxCache();
+        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+
+        MockAuxCache mockLateral = new MockAuxCache();
+        mockLateral.cacheType = AuxiliaryCache.LATERAL_CACHE;
+
+        cache.setAuxCaches( new AuxiliaryCache[] { mock, mockLateral } );
+
+        ICacheElement inputElement = new CacheElement( "testSpoolAllowed", "key", "value" );
+
+        // DO WORK
+        cache.updateAuxiliaries( inputElement, false );
+
+        // VERIFY
+        assertEquals( "Wrong number of calls to the disk cache update.", 1, mock.updateCount );
+        assertEquals( "Wrong element updated.", inputElement, mock.lastUpdatedItem );
+
+        assertEquals( "Wrong number of calls to the lateral cache update.", 1, mockLateral.updateCount );
+        assertEquals( "Wrong element updated with lateral.", inputElement, mockLateral.lastUpdatedItem );
+    }
+
+    /**
+     * Used to test the disk cache functionality.
+     * <p>
+     * @author Aaron Smuts
+     */
+    public class MockAuxCache
+        implements AuxiliaryCache
+    {
+        private static final long serialVersionUID = 1L;
+
+        /**
+         * The last item passed to update.
+         */
+        public ICacheElement lastUpdatedItem;
+
+        /**
+         * The number of times update was called.
+         */
+        public int updateCount = 0;
+
+        /**
+         * The type that should be returned from getCacheType.
+         */
+        public int cacheType = AuxiliaryCache.DISK_CACHE;
+
+        /**
+         * Resets counters and catchers.
+         */
+        public void reset()
+        {
+            updateCount = 0;
+            lastUpdatedItem = null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
+         */
+        public void update( ICacheElement ce )
+            throws IOException
+        {
+            lastUpdatedItem = ce;
+            updateCount++;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
+         */
+        public ICacheElement get( Serializable key )
+            throws IOException
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
+         */
+        public boolean remove( Serializable key )
+            throws IOException
+        {
+            // TODO Auto-generated method stub
+            return false;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#removeAll()
+         */
+        public void removeAll()
+            throws IOException
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#dispose()
+         */
+        public void dispose()
+            throws IOException
+        {
+            // TODO Auto-generated method stub
+
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getSize()
+         */
+        public int getSize()
+        {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
+         */
+        public int getStatus()
+        {
+            // TODO Auto-generated method stub
+            return 0;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getCacheName()
+         */
+        public String getCacheName()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
+         */
+        public Set getGroupKeys( String group )
+            throws IOException
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
+         */
+        public IStats getStatistics()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        /*
+         * (non-Javadoc)
+         * @see org.apache.jcs.engine.behavior.ICache#getStats()
+         */
+        public String getStats()
+        {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        /**
+         * Returns the setup cache type. This allows you to use this mock as multiple cache types.
+         * <p>
+         * (non-Javadoc)
+         * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
+         */
+        public int getCacheType()
+        {
+            return cacheType;
+        }
+
+        /**
+         * @return Returns the AuxiliaryCacheAttributes.
+         */
+        public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
+        {
+            return null;
+        }
+    }
+
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerMockImpl.java Thu May 10 09:03:42 2007
@@ -1,45 +1,64 @@
-package org.apache.jcs.engine.control;
-
-import org.apache.jcs.engine.CompositeCacheAttributes;
-import org.apache.jcs.engine.ElementAttributes;
-import org.apache.jcs.engine.behavior.ICompositeCacheManager;
-
-/**
- */
-public class CompositeCacheManagerMockImpl
-    implements ICompositeCacheManager
-{
-
-    private CompositeCache cache;
-    
-    /* (non-Javadoc)
-     * @see org.apache.jcs.engine.behavior.ICompositeCacheManager#getCache(java.lang.String)
-     */
-    public CompositeCache getCache( String cacheName )
-    {
-        if ( cache == null )
-        {
-            System.out.println( "Creating mock cache" );
-            CompositeCache newCache = new CompositeCache( cacheName, new CompositeCacheAttributes(), new ElementAttributes() );
-            this.setCache( newCache );
-        }
-        return cache;
-    }
-
-    /**
-     * @param cache The cache to set.
-     */
-    public void setCache( CompositeCache cache )
-    {
-        this.cache = cache;
-    }
-
-    /**
-     * @return Returns the cache.
-     */
-    public CompositeCache getCache()
-    {
-        return cache;
-    }
-
-}
+package org.apache.jcs.engine.control;
+
+/*
+ * 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.
+ */
+
+import org.apache.jcs.engine.CompositeCacheAttributes;
+import org.apache.jcs.engine.ElementAttributes;
+import org.apache.jcs.engine.behavior.ICompositeCacheManager;
+
+/**
+ */
+public class CompositeCacheManagerMockImpl
+    implements ICompositeCacheManager
+{
+
+    private CompositeCache cache;
+
+    /* (non-Javadoc)
+     * @see org.apache.jcs.engine.behavior.ICompositeCacheManager#getCache(java.lang.String)
+     */
+    public CompositeCache getCache( String cacheName )
+    {
+        if ( cache == null )
+        {
+            System.out.println( "Creating mock cache" );
+            CompositeCache newCache = new CompositeCache( cacheName, new CompositeCacheAttributes(), new ElementAttributes() );
+            this.setCache( newCache );
+        }
+        return cache;
+    }
+
+    /**
+     * @param cache The cache to set.
+     */
+    public void setCache( CompositeCache cache )
+    {
+        this.cache = cache;
+    }
+
+    /**
+     * @return Returns the cache.
+     */
+    public CompositeCache getCache()
+    {
+        return cache;
+    }
+
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerTester.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerTester.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerTester.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheManagerTester.java Thu May 10 09:03:42 2007
@@ -1,19 +1,22 @@
 package org.apache.jcs.engine.control;
 
 /*
- * Copyright 2002-2004 The Apache Software Foundation.
+ * 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
  *
- * Licensed 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
  *
- *     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.
+ * 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.
  */
 
 /**
@@ -23,7 +26,7 @@
 
     /**
      * Description of the Method
-     * 
+     *
      * @param args
      */
     public static void main( String args[] )

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java Thu May 10 09:03:42 2007
@@ -1,103 +1,122 @@
-package org.apache.jcs.engine.control;
-
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.auxiliary.AuxiliaryCache;
-import org.apache.jcs.auxiliary.AuxiliaryCacheMockImpl;
-import org.apache.jcs.engine.CacheElement;
-import org.apache.jcs.engine.CompositeCacheAttributes;
-import org.apache.jcs.engine.ElementAttributes;
-import org.apache.jcs.engine.behavior.ICache;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
-import org.apache.jcs.engine.behavior.IElementAttributes;
-import org.apache.jcs.engine.memory.MemoryCacheMockImpl;
-
-/**
- * Tests that directly engage the composite cache.
- * <p>
- * @author Aaron Smuts
- */
-public class CompositeCacheUnitTest
-    extends TestCase
-{
-    /**
-     * Verify that the freeMemoryElements method on the memory cache is called on shutdown if there
-     * is a disk cache.
-     * <p>
-     * @throws IOException
-     */
-    public void testShutdownMemoryFlush()
-        throws IOException
-    {
-        // SETUP
-        String cacheName = "testCacheName";
-        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setMemoryCacheName( mockMemoryCacheClassName );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
-
-        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
-        diskMock.cacheType = ICache.DISK_CACHE;
-        AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
-        cache.setAuxCaches( aux );
-
-        // DO WORK
-        int numToInsert = 10;
-        for ( int i = 0; i < numToInsert; i++ )
-        {
-            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
-            cache.update( element, false );
-        }
-
-        cache.dispose();
-
-        // VERIFY
-        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
-        assertEquals( "Wrong number freed.", numToInsert, memoryCache.lastNumberOfFreedElements );
-    }
-
-    /**
-     * Verify that the freeMemoryElements method on the memory cache is NOT called on shutdown if
-     * there is NOT a disk cache.
-     * <p>
-     * @throws IOException
-     */
-    public void testShutdownMemoryFlush_noDisk()
-        throws IOException
-    {
-        // SETUP
-        String cacheName = "testCacheName";
-        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setMemoryCacheName( mockMemoryCacheClassName );
-
-        IElementAttributes attr = new ElementAttributes();
-
-        CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
-
-        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
-        diskMock.cacheType = ICache.REMOTE_CACHE;
-        AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
-        cache.setAuxCaches( aux );
-
-        // DO WORK
-        int numToInsert = 10;
-        for ( int i = 0; i < numToInsert; i++ )
-        {
-            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
-            cache.update( element, false );
-        }
-
-        cache.dispose();
-
-        // VERIFY
-        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
-        assertEquals( "Wrong number freed.", 0, memoryCache.lastNumberOfFreedElements );
-    }
-}
+package org.apache.jcs.engine.control;
+
+/*
+ * 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.
+ */
+
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.auxiliary.AuxiliaryCache;
+import org.apache.jcs.auxiliary.AuxiliaryCacheMockImpl;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.CompositeCacheAttributes;
+import org.apache.jcs.engine.ElementAttributes;
+import org.apache.jcs.engine.behavior.ICache;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.memory.MemoryCacheMockImpl;
+
+/**
+ * Tests that directly engage the composite cache.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class CompositeCacheUnitTest
+    extends TestCase
+{
+    /**
+     * Verify that the freeMemoryElements method on the memory cache is called on shutdown if there
+     * is a disk cache.
+     * <p>
+     * @throws IOException
+     */
+    public void testShutdownMemoryFlush()
+        throws IOException
+    {
+        // SETUP
+        String cacheName = "testCacheName";
+        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setMemoryCacheName( mockMemoryCacheClassName );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
+
+        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+        diskMock.cacheType = ICache.DISK_CACHE;
+        AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
+        cache.setAuxCaches( aux );
+
+        // DO WORK
+        int numToInsert = 10;
+        for ( int i = 0; i < numToInsert; i++ )
+        {
+            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
+            cache.update( element, false );
+        }
+
+        cache.dispose();
+
+        // VERIFY
+        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
+        assertEquals( "Wrong number freed.", numToInsert, memoryCache.lastNumberOfFreedElements );
+    }
+
+    /**
+     * Verify that the freeMemoryElements method on the memory cache is NOT called on shutdown if
+     * there is NOT a disk cache.
+     * <p>
+     * @throws IOException
+     */
+    public void testShutdownMemoryFlush_noDisk()
+        throws IOException
+    {
+        // SETUP
+        String cacheName = "testCacheName";
+        String mockMemoryCacheClassName = "org.apache.jcs.engine.memory.MemoryCacheMockImpl";
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setMemoryCacheName( mockMemoryCacheClassName );
+
+        IElementAttributes attr = new ElementAttributes();
+
+        CompositeCache cache = new CompositeCache( cacheName, cattr, attr );
+
+        AuxiliaryCacheMockImpl diskMock = new AuxiliaryCacheMockImpl();
+        diskMock.cacheType = ICache.REMOTE_CACHE;
+        AuxiliaryCache[] aux = new AuxiliaryCache[] { diskMock };
+        cache.setAuxCaches( aux );
+
+        // DO WORK
+        int numToInsert = 10;
+        for ( int i = 0; i < numToInsert; i++ )
+        {
+            ICacheElement element = new CacheElement( cacheName, String.valueOf( i ), new Integer( i ) );
+            cache.update( element, false );
+        }
+
+        cache.dispose();
+
+        // VERIFY
+        MemoryCacheMockImpl memoryCache = (MemoryCacheMockImpl) cache.getMemoryCache();
+        assertEquals( "Wrong number freed.", 0, memoryCache.lastNumberOfFreedElements );
+    }
+}



---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org