Download Firefox: WindowsMac OS X
logo       
Google Custom Search
    AddThis Social Bookmark Button

svn commit: r536904 [33/38] - in /jakarta/jcs/trunk: ./ auxiliary-builds/ja: msg#00030

Subject: svn commit: r536904 [33/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/engine/control/event/ElementEventHandlerMockImpl.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/ElementEventHandlerMockImpl.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/ElementEventHandlerMockImpl.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/ElementEventHandlerMockImpl.java
 Thu May 10 09:03:42 2007
@@ -1,193 +1,196 @@
-package org.apache.jcs.engine.control.event;
-
-/*
- * 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.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import org.apache.jcs.engine.control.event.behavior.IElementEvent;
-import org.apache.jcs.engine.control.event.behavior.IElementEventConstants;
-import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
-
-/**
- * 
- * @author aaronsm
- *  
- */
-public class ElementEventHandlerMockImpl
-    implements IElementEventHandler
-{
-
-    /**
-     * Times called.
-     */
-    private int callCount = 0;
-    
-    private final static Log log = LogFactory.getLog( 
ElementEventHandlerMockImpl.class );
-    
-    // ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE
-    private int spoolCount = 0;
-
-    // ELEMENT_EVENT_SPOOLED_NOT_ALLOWED
-    private int spoolNotAllowedCount = 0;
-
-    // ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE
-    private int spoolNoDiskCount = 0;
-
-    // ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND
-    private int exceededMaxLifeBackgroundCount = 0;
-    
-    // ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND
-    private int exceededIdleTimeBackgroundCount = 0;
-    
-    /*
-     * (non-Javadoc)
-     * 
-     * @see 
org.apache.jcs.engine.control.event.behavior.IElementEventHandler#handleElementEvent(org.apache.jcs.engine.control.event.behavior.IElementEvent)
-     */
-    public synchronized void handleElementEvent( IElementEvent event )
-    {
-        
-        setCallCount( getCallCount() + 1 );
-        
-        if ( log.isDebugEnabled() )
-        {
-            log.debug( "HANDLER -- HANDLER -- HANDLER -- ---EVENT CODE = " + 
event.getElementEvent() );
-            log.debug( "/n/n EVENT CODE = " + event.getElementEvent() + " 
***************************" );            
-        }
-
-        if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE )
-        {
-            setSpoolCount( getSpoolCount() + 1 );
-        }
-        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_NOT_ALLOWED )
-        {
-            setSpoolNotAllowedCount( getSpoolNotAllowedCount() + 1 );
-        }
-        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE )
-        {
-            setSpoolNoDiskCount( getSpoolNoDiskCount() + 1 );
-        }
-        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND )
-        {
-            setExceededMaxLifeBackgroundCount( 
getExceededMaxLifeBackgroundCount() + 1 );
-        }
-        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND )
-        {
-            setExceededIdleTimeBackgroundCount( 
getExceededIdleTimeBackgroundCount() + 1 );
-        }
-    }
-
-    /**
-     * @param spoolCount
-     *            The spoolCount to set.
-     */
-    public void setSpoolCount( int spoolCount )
-    {
-        this.spoolCount = spoolCount;
-    }
-
-    /**
-     * @return Returns the spoolCount.
-     */
-    public int getSpoolCount()
-    {
-        return spoolCount;
-    }
-
-    /**
-     * @param spoolNotAllowedCount
-     *            The spoolNotAllowedCount to set.
-     */
-    public void setSpoolNotAllowedCount( int spoolNotAllowedCount )
-    {
-        this.spoolNotAllowedCount = spoolNotAllowedCount;
-    }
-
-    /**
-     * @return Returns the spoolNotAllowedCount.
-     */
-    public int getSpoolNotAllowedCount()
-    {
-        return spoolNotAllowedCount;
-    }
-
-    /**
-     * @param spoolNoDiskCount
-     *            The spoolNoDiskCount to set.
-     */
-    public void setSpoolNoDiskCount( int spoolNoDiskCount )
-    {
-        this.spoolNoDiskCount = spoolNoDiskCount;
-    }
-
-    /**
-     * @return Returns the spoolNoDiskCount.
-     */
-    public int getSpoolNoDiskCount()
-    {
-        return spoolNoDiskCount;
-    }
-
-    /**
-     * @param exceededMaxLifeBackground The exceededMaxLifeBackground to set.
-     */
-    public void setExceededMaxLifeBackgroundCount( int 
exceededMaxLifeBackground )
-    {
-        this.exceededMaxLifeBackgroundCount = exceededMaxLifeBackground;
-    }
-
-    /**
-     * @return Returns the exceededMaxLifeBackground.
-     */
-    public int getExceededMaxLifeBackgroundCount()
-    {
-        return exceededMaxLifeBackgroundCount;
-    }
-
-    /**
-     * @param callCount The callCount to set.
-     */
-    public void setCallCount( int callCount )
-    {
-        this.callCount = callCount;
-    }
-
-    /**
-     * @return Returns the callCount.
-     */
-    public int getCallCount()
-    {
-        return callCount;
-    }
-
-    /**
-     * @param exceededIdleTimeBackground The exceededIdleTimeBackground to set.
-     */
-    public void setExceededIdleTimeBackgroundCount( int 
exceededIdleTimeBackground )
-    {
-        this.exceededIdleTimeBackgroundCount = exceededIdleTimeBackground;
-    }
-
-    /**
-     * @return Returns the exceededIdleTimeBackground.
-     */
-    public int getExceededIdleTimeBackgroundCount()
-    {
-        return exceededIdleTimeBackgroundCount;
-    }    
-}
+package org.apache.jcs.engine.control.event;
+
+/*
+ * 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.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.apache.jcs.engine.control.event.behavior.IElementEvent;
+import org.apache.jcs.engine.control.event.behavior.IElementEventConstants;
+import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
+
+/**
+ *
+ * @author aaronsm
+ *
+ */
+public class ElementEventHandlerMockImpl
+    implements IElementEventHandler
+{
+
+    /**
+     * Times called.
+     */
+    private int callCount = 0;
+
+    private final static Log log = LogFactory.getLog( 
ElementEventHandlerMockImpl.class );
+
+    // ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE
+    private int spoolCount = 0;
+
+    // ELEMENT_EVENT_SPOOLED_NOT_ALLOWED
+    private int spoolNotAllowedCount = 0;
+
+    // ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE
+    private int spoolNoDiskCount = 0;
+
+    // ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND
+    private int exceededMaxLifeBackgroundCount = 0;
+
+    // ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND
+    private int exceededIdleTimeBackgroundCount = 0;
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see 
org.apache.jcs.engine.control.event.behavior.IElementEventHandler#handleElementEvent(org.apache.jcs.engine.control.event.behavior.IElementEvent)
+     */
+    public synchronized void handleElementEvent( IElementEvent event )
+    {
+
+        setCallCount( getCallCount() + 1 );
+
+        if ( log.isDebugEnabled() )
+        {
+            log.debug( "HANDLER -- HANDLER -- HANDLER -- ---EVENT CODE = " + 
event.getElementEvent() );
+            log.debug( "/n/n EVENT CODE = " + event.getElementEvent() + " 
***************************" );
+        }
+
+        if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE )
+        {
+            setSpoolCount( getSpoolCount() + 1 );
+        }
+        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_NOT_ALLOWED )
+        {
+            setSpoolNotAllowedCount( getSpoolNotAllowedCount() + 1 );
+        }
+        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE )
+        {
+            setSpoolNoDiskCount( getSpoolNoDiskCount() + 1 );
+        }
+        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_EXCEEDED_MAXLIFE_BACKGROUND )
+        {
+            setExceededMaxLifeBackgroundCount( 
getExceededMaxLifeBackgroundCount() + 1 );
+        }
+        else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_EXCEEDED_IDLETIME_BACKGROUND )
+        {
+            setExceededIdleTimeBackgroundCount( 
getExceededIdleTimeBackgroundCount() + 1 );
+        }
+    }
+
+    /**
+     * @param spoolCount
+     *            The spoolCount to set.
+     */
+    public void setSpoolCount( int spoolCount )
+    {
+        this.spoolCount = spoolCount;
+    }
+
+    /**
+     * @return Returns the spoolCount.
+     */
+    public int getSpoolCount()
+    {
+        return spoolCount;
+    }
+
+    /**
+     * @param spoolNotAllowedCount
+     *            The spoolNotAllowedCount to set.
+     */
+    public void setSpoolNotAllowedCount( int spoolNotAllowedCount )
+    {
+        this.spoolNotAllowedCount = spoolNotAllowedCount;
+    }
+
+    /**
+     * @return Returns the spoolNotAllowedCount.
+     */
+    public int getSpoolNotAllowedCount()
+    {
+        return spoolNotAllowedCount;
+    }
+
+    /**
+     * @param spoolNoDiskCount
+     *            The spoolNoDiskCount to set.
+     */
+    public void setSpoolNoDiskCount( int spoolNoDiskCount )
+    {
+        this.spoolNoDiskCount = spoolNoDiskCount;
+    }
+
+    /**
+     * @return Returns the spoolNoDiskCount.
+     */
+    public int getSpoolNoDiskCount()
+    {
+        return spoolNoDiskCount;
+    }
+
+    /**
+     * @param exceededMaxLifeBackground The exceededMaxLifeBackground to set.
+     */
+    public void setExceededMaxLifeBackgroundCount( int 
exceededMaxLifeBackground )
+    {
+        this.exceededMaxLifeBackgroundCount = exceededMaxLifeBackground;
+    }
+
+    /**
+     * @return Returns the exceededMaxLifeBackground.
+     */
+    public int getExceededMaxLifeBackgroundCount()
+    {
+        return exceededMaxLifeBackgroundCount;
+    }
+
+    /**
+     * @param callCount The callCount to set.
+     */
+    public void setCallCount( int callCount )
+    {
+        this.callCount = callCount;
+    }
+
+    /**
+     * @return Returns the callCount.
+     */
+    public int getCallCount()
+    {
+        return callCount;
+    }
+
+    /**
+     * @param exceededIdleTimeBackground The exceededIdleTimeBackground to set.
+     */
+    public void setExceededIdleTimeBackgroundCount( int 
exceededIdleTimeBackground )
+    {
+        this.exceededIdleTimeBackgroundCount = exceededIdleTimeBackground;
+    }
+
+    /**
+     * @return Returns the exceededIdleTimeBackground.
+     */
+    public int getExceededIdleTimeBackgroundCount()
+    {
+        return exceededIdleTimeBackgroundCount;
+    }
+}

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/SimpleEventHandlingUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/control/event/SimpleEventHandlingUnitTest.java
 Thu May 10 09:03:42 2007
@@ -1,309 +1,312 @@
-package org.apache.jcs.engine.control.event;
-
-/*
- * 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 junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-import org.apache.jcs.JCS;
-import org.apache.jcs.engine.behavior.IElementAttributes;
-import org.apache.jcs.engine.control.event.behavior.IElementEvent;
-import org.apache.jcs.engine.control.event.behavior.IElementEventConstants;
-import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
-
-/**
- * This test suite verifies that the basic ElementEvent are called as they
- * should be.
- * 
- * 
- * @version $Id: TestSimpleEventHandling.java,v 1.1 2005/02/01 00:01:59 asmuts
- *          Exp $
- */
-public class SimpleEventHandlingUnitTest
-    extends TestCase
-{
-
-    private static int items = 20000;
-
-    /**
-     * Constructor for test case.
-     * 
-     * @param testName
-     *            Description of the Parameter
-     */
-    public SimpleEventHandlingUnitTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * Run at command line.
-     * 
-     * @param args
-     *            Description of the Parameter
-     */
-    public static void main( String args[] )
-    {
-        String[] testCaseName = { SimpleEventHandlingUnitTest.class.getName() 
};
-        junit.textui.TestRunner.main( testCaseName );
-    }
-
-    /**
-     * A unit test suite for JUnit
-     * 
-     * @return The test suite
-     */
-    public static Test suite()
-    {
-        return new TestSuite( SimpleEventHandlingUnitTest.class );
-    }
-
-    /**
-     * Test setup with expected configuration parameters.
-     *  
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestSimpleEventHandling.ccf" );
-    }
-
-    /**
-     * Verify that the spooled event is called as expected.
-     * 
-     * 
-     * @exception Exception
-     *                Description of the Exception
-     */
-    public void testSpoolEvent()
-        throws Exception
-    {
-        MyEventHandler meh = new MyEventHandler();
-
-        JCS jcs = JCS.getInstance( "WithDisk" );
-        // this should add the event handler to all items as they are created.
-        IElementAttributes attributes = jcs.getDefaultElementAttributes();
-        attributes.addElementEventHandler( meh );
-        jcs.setDefaultElementAttributes( attributes );
-
-        // put them in
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", "data" + i );
-        }
-
-        // wait a bit for it to finish
-        Thread.sleep( items / 20 );
-
-        // test to see if the count is right
-        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE events 
[" + meh.getSpoolCount()
-            + "] does not equal the number expected [" + items + "]", 
meh.getSpoolCount() >= items );
-
-    }
-
-    /**
-     * Test overflow with no disk configured for the region.
-     * 
-     * @throws Exception
-     */
-    public void testSpoolNoDiskEvent()
-        throws Exception
-    {
-        JCS jcs = JCS.getInstance( "NoDisk" );
-
-        MyEventHandler meh = new MyEventHandler();
-
-        // this should add the event handler to all items as they are created.
-        IElementAttributes attributes = jcs.getDefaultElementAttributes();
-        attributes.addElementEventHandler( meh );
-        jcs.setDefaultElementAttributes( attributes );
-
-        // put them in
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", "data" + i );
-        }
-
-        // wait a bit for it to finish
-        Thread.sleep( items / 20 );
-
-        // test to see if the count is right
-        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE 
events  [" + meh.getSpoolNoDiskCount()
-            + "] does not equal the number expected.", 
meh.getSpoolNoDiskCount() >= items );
-
-    }
-
-    /**
-     * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event.
-     * 
-     * @throws Exception
-     */
-    public void testSpoolNotAllowedEvent()
-        throws Exception
-    {
-        MyEventHandler meh = new MyEventHandler();
-
-        JCS jcs = JCS.getInstance( "DiskButNotAllowed" );
-        // this should add the event handler to all items as they are created.
-        IElementAttributes attributes = jcs.getDefaultElementAttributes();
-        attributes.addElementEventHandler( meh );
-        jcs.setDefaultElementAttributes( attributes );
-
-        // put them in
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", "data" + i );
-        }
-
-        // wait a bit for it to finish
-        Thread.sleep( items / 20 );
-
-        // test to see if the count is right
-        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" 
+ meh.getSpoolNotAllowedCount()
-            + "] does not equal the number expected.", 
meh.getSpoolNotAllowedCount() >= items );
-
-    }
-
-    
-    /**
-     * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event.
-     * 
-     * @throws Exception
-     */
-    public void testSpoolNotAllowedEventOnItem()
-        throws Exception
-    {
-        MyEventHandler meh = new MyEventHandler();
-
-        JCS jcs = JCS.getInstance( "DiskButNotAllowed" );
-        // this should add the event handler to all items as they are created.
-        //IElementAttributes attributes = jcs.getDefaultElementAttributes();
-        //attributes.addElementEventHandler( meh );
-        //jcs.setDefaultElementAttributes( attributes );
-
-        // put them in
-        for ( int i = 0; i <= items; i++ )
-        {
-            IElementAttributes attributes = jcs.getDefaultElementAttributes();
-            attributes.addElementEventHandler( meh );
-            jcs.put( i + ":key", "data" + i, attributes );
-        }
-
-        // wait a bit for it to finish
-        Thread.sleep( items / 20 );
-
-        // test to see if the count is right
-        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" 
+ meh.getSpoolNotAllowedCount()
-            + "] does not equal the number expected.", 
meh.getSpoolNotAllowedCount() >= items );
-
-    }
-    /**
-     * Simple event counter used to verify test results.
-     * 
-     * @author aaronsm
-     *  
-     */
-    public class MyEventHandler
-        implements IElementEventHandler
-    {
-
-        private int spoolCount = 0;
-
-        private int spoolNotAllowedCount = 0;
-
-        private int spoolNoDiskCount = 0;
-
-        /*
-         * (non-Javadoc)
-         * 
-         * @see 
org.apache.jcs.engine.control.event.behavior.IElementEventHandler#handleElementEvent(org.apache.jcs.engine.control.event.behavior.IElementEvent)
-         */
-        public synchronized void handleElementEvent( IElementEvent event )
-        {
-            //System.out.println( "Handling Event of Type " +
-            // event.getElementEvent() );
-
-            if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE )
-            {
-                //System.out.println( "Handling Event of Type
-                // ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE, " + getSpoolCount() );
-                setSpoolCount( getSpoolCount() + 1 );
-            }
-            else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_NOT_ALLOWED )
-            {
-                setSpoolNotAllowedCount( getSpoolNotAllowedCount() + 1 );
-            }
-            else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE )
-            {
-                setSpoolNoDiskCount( getSpoolNoDiskCount() + 1 );
-            }
-        }
-
-        /**
-         * @param spoolCount
-         *            The spoolCount to set.
-         */
-        protected void setSpoolCount( int spoolCount )
-        {
-            this.spoolCount = spoolCount;
-        }
-
-        /**
-         * @return Returns the spoolCount.
-         */
-        protected int getSpoolCount()
-        {
-            return spoolCount;
-        }
-
-        /**
-         * @param spoolNotAllowedCount
-         *            The spoolNotAllowedCount to set.
-         */
-        protected void setSpoolNotAllowedCount( int spoolNotAllowedCount )
-        {
-            this.spoolNotAllowedCount = spoolNotAllowedCount;
-        }
-
-        /**
-         * @return Returns the spoolNotAllowedCount.
-         */
-        protected int getSpoolNotAllowedCount()
-        {
-            return spoolNotAllowedCount;
-        }
-
-        /**
-         * @param spoolNoDiskCount
-         *            The spoolNoDiskCount to set.
-         */
-        protected void setSpoolNoDiskCount( int spoolNoDiskCount )
-        {
-            this.spoolNoDiskCount = spoolNoDiskCount;
-        }
-
-        /**
-         * @return Returns the spoolNoDiskCount.
-         */
-        protected int getSpoolNoDiskCount()
-        {
-            return spoolNoDiskCount;
-        }
-
-    }
-
-}
\ No newline at end of file
+package org.apache.jcs.engine.control.event;
+
+/*
+ * 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 junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.behavior.IElementAttributes;
+import org.apache.jcs.engine.control.event.behavior.IElementEvent;
+import org.apache.jcs.engine.control.event.behavior.IElementEventConstants;
+import org.apache.jcs.engine.control.event.behavior.IElementEventHandler;
+
+/**
+ * This test suite verifies that the basic ElementEvent are called as they
+ * should be.
+ *
+ *
+ * @version $Id: TestSimpleEventHandling.java,v 1.1 2005/02/01 00:01:59 asmuts
+ *          Exp $
+ */
+public class SimpleEventHandlingUnitTest
+    extends TestCase
+{
+
+    private static int items = 20000;
+
+    /**
+     * Constructor for test case.
+     *
+     * @param testName
+     *            Description of the Parameter
+     */
+    public SimpleEventHandlingUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Run at command line.
+     *
+     * @param args
+     *            Description of the Parameter
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { SimpleEventHandlingUnitTest.class.getName() 
};
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit
+     *
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        return new TestSuite( SimpleEventHandlingUnitTest.class );
+    }
+
+    /**
+     * Test setup with expected configuration parameters.
+     *
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestSimpleEventHandling.ccf" );
+    }
+
+    /**
+     * Verify that the spooled event is called as expected.
+     *
+     *
+     * @exception Exception
+     *                Description of the Exception
+     */
+    public void testSpoolEvent()
+        throws Exception
+    {
+        MyEventHandler meh = new MyEventHandler();
+
+        JCS jcs = JCS.getInstance( "WithDisk" );
+        // this should add the event handler to all items as they are created.
+        IElementAttributes attributes = jcs.getDefaultElementAttributes();
+        attributes.addElementEventHandler( meh );
+        jcs.setDefaultElementAttributes( attributes );
+
+        // put them in
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", "data" + i );
+        }
+
+        // wait a bit for it to finish
+        Thread.sleep( items / 20 );
+
+        // test to see if the count is right
+        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE events 
[" + meh.getSpoolCount()
+            + "] does not equal the number expected [" + items + "]", 
meh.getSpoolCount() >= items );
+
+    }
+
+    /**
+     * Test overflow with no disk configured for the region.
+     *
+     * @throws Exception
+     */
+    public void testSpoolNoDiskEvent()
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( "NoDisk" );
+
+        MyEventHandler meh = new MyEventHandler();
+
+        // this should add the event handler to all items as they are created.
+        IElementAttributes attributes = jcs.getDefaultElementAttributes();
+        attributes.addElementEventHandler( meh );
+        jcs.setDefaultElementAttributes( attributes );
+
+        // put them in
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", "data" + i );
+        }
+
+        // wait a bit for it to finish
+        Thread.sleep( items / 20 );
+
+        // test to see if the count is right
+        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE 
events  [" + meh.getSpoolNoDiskCount()
+            + "] does not equal the number expected.", 
meh.getSpoolNoDiskCount() >= items );
+
+    }
+
+    /**
+     * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event.
+     *
+     * @throws Exception
+     */
+    public void testSpoolNotAllowedEvent()
+        throws Exception
+    {
+        MyEventHandler meh = new MyEventHandler();
+
+        JCS jcs = JCS.getInstance( "DiskButNotAllowed" );
+        // this should add the event handler to all items as they are created.
+        IElementAttributes attributes = jcs.getDefaultElementAttributes();
+        attributes.addElementEventHandler( meh );
+        jcs.setDefaultElementAttributes( attributes );
+
+        // put them in
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", "data" + i );
+        }
+
+        // wait a bit for it to finish
+        Thread.sleep( items / 20 );
+
+        // test to see if the count is right
+        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" 
+ meh.getSpoolNotAllowedCount()
+            + "] does not equal the number expected.", 
meh.getSpoolNotAllowedCount() >= items );
+
+    }
+
+
+    /**
+     * Test the ELEMENT_EVENT_SPOOLED_NOT_ALLOWED event.
+     *
+     * @throws Exception
+     */
+    public void testSpoolNotAllowedEventOnItem()
+        throws Exception
+    {
+        MyEventHandler meh = new MyEventHandler();
+
+        JCS jcs = JCS.getInstance( "DiskButNotAllowed" );
+        // this should add the event handler to all items as they are created.
+        //IElementAttributes attributes = jcs.getDefaultElementAttributes();
+        //attributes.addElementEventHandler( meh );
+        //jcs.setDefaultElementAttributes( attributes );
+
+        // put them in
+        for ( int i = 0; i <= items; i++ )
+        {
+            IElementAttributes attributes = jcs.getDefaultElementAttributes();
+            attributes.addElementEventHandler( meh );
+            jcs.put( i + ":key", "data" + i, attributes );
+        }
+
+        // wait a bit for it to finish
+        Thread.sleep( items / 20 );
+
+        // test to see if the count is right
+        assertTrue( "The number of ELEMENT_EVENT_SPOOLED_NOT_ALLOWED events [" 
+ meh.getSpoolNotAllowedCount()
+            + "] does not equal the number expected.", 
meh.getSpoolNotAllowedCount() >= items );
+
+    }
+    /**
+     * Simple event counter used to verify test results.
+     *
+     * @author aaronsm
+     *
+     */
+    public class MyEventHandler
+        implements IElementEventHandler
+    {
+
+        private int spoolCount = 0;
+
+        private int spoolNotAllowedCount = 0;
+
+        private int spoolNoDiskCount = 0;
+
+        /*
+         * (non-Javadoc)
+         *
+         * @see 
org.apache.jcs.engine.control.event.behavior.IElementEventHandler#handleElementEvent(org.apache.jcs.engine.control.event.behavior.IElementEvent)
+         */
+        public synchronized void handleElementEvent( IElementEvent event )
+        {
+            //System.out.println( "Handling Event of Type " +
+            // event.getElementEvent() );
+
+            if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE )
+            {
+                //System.out.println( "Handling Event of Type
+                // ELEMENT_EVENT_SPOOLED_DISK_AVAILABLE, " + getSpoolCount() );
+                setSpoolCount( getSpoolCount() + 1 );
+            }
+            else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_NOT_ALLOWED )
+            {
+                setSpoolNotAllowedCount( getSpoolNotAllowedCount() + 1 );
+            }
+            else if ( event.getElementEvent() == 
IElementEventConstants.ELEMENT_EVENT_SPOOLED_DISK_NOT_AVAILABLE )
+            {
+                setSpoolNoDiskCount( getSpoolNoDiskCount() + 1 );
+            }
+        }
+
+        /**
+         * @param spoolCount
+         *            The spoolCount to set.
+         */
+        protected void setSpoolCount( int spoolCount )
+        {
+            this.spoolCount = spoolCount;
+        }
+
+        /**
+         * @return Returns the spoolCount.
+         */
+        protected int getSpoolCount()
+        {
+            return spoolCount;
+        }
+
+        /**
+         * @param spoolNotAllowedCount
+         *            The spoolNotAllowedCount to set.
+         */
+        protected void setSpoolNotAllowedCount( int spoolNotAllowedCount )
+        {
+            this.spoolNotAllowedCount = spoolNotAllowedCount;
+        }
+
+        /**
+         * @return Returns the spoolNotAllowedCount.
+         */
+        protected int getSpoolNotAllowedCount()
+        {
+            return spoolNotAllowedCount;
+        }
+
+        /**
+         * @param spoolNoDiskCount
+         *            The spoolNoDiskCount to set.
+         */
+        protected void setSpoolNoDiskCount( int spoolNoDiskCount )
+        {
+            this.spoolNoDiskCount = spoolNoDiskCount;
+        }
+
+        /**
+         * @return Returns the spoolNoDiskCount.
+         */
+        protected int getSpoolNoDiskCount()
+        {
+            return spoolNoDiskCount;
+        }
+
+    }
+
+}

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/MemoryCacheMockImpl.java
 Thu May 10 09:03:42 2007
@@ -1,167 +1,170 @@
-package org.apache.jcs.engine.memory;
-
-/*
- * 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.io.IOException;
-import java.io.Serializable;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
-import org.apache.jcs.engine.control.CompositeCache;
-import org.apache.jcs.engine.stats.behavior.IStats;
-
-/**
- * Mock implementation of a memory cache for testing things like the memory
- * shrinker.
- * <p>
- * @author Aaron Smuts
- */
-public class MemoryCacheMockImpl
-    implements MemoryCache
-{
-    private ICompositeCacheAttributes cacheAttr;
-
-    private HashMap map = new HashMap();
-
-    /**
-     * The number of times waterfall was called.
-     */
-    public int waterfallCallCount = 0;
-
-    /**
-     * The number passed to the last call of free elements.
-     */
-    public int lastNumberOfFreedElements = 0;
-    
-    public void initialize( CompositeCache cache )
-    {
-        // TODO Auto-generated method stub
-    }
-
-    public void dispose()
-        throws IOException
-    {
-        // TODO Auto-generated method stub
-
-    }
-
-    public int getSize()
-    {
-        return map.size();
-    }
-
-    public IStats getStatistics()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Iterator getIterator()
-    {
-        // return
-        return null;
-    }
-
-    public Object[] getKeyArray()
-    {
-        return map.keySet().toArray();
-    }
-
-    public boolean remove( Serializable key )
-        throws IOException
-    {
-        return map.remove( key ) != null;
-    }
-
-    public void removeAll()
-        throws IOException
-    {
-        map.clear();
-    }
-
-    public ICacheElement get( Serializable key )
-        throws IOException
-    {
-        return (ICacheElement) map.get( key );
-    }
-
-    public ICacheElement getQuiet( Serializable key )
-        throws IOException
-    {
-        return (ICacheElement) map.get( key );
-    }
-
-    public void waterfal( ICacheElement ce )
-        throws IOException
-    {
-        waterfallCallCount++;
-    }
-
-    public void update( ICacheElement ce )
-        throws IOException
-    {
-        if ( ce != null )
-        {
-            map.put( ce.getKey(), ce );
-        }
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.apache.jcs.engine.memory.MemoryCache#getCacheAttributes()
-     */
-    public ICompositeCacheAttributes getCacheAttributes()
-    {
-        return cacheAttr;
-    }
-
-    /*
-     * (non-Javadoc)
-     * 
-     * @see 
org.apache.jcs.engine.memory.MemoryCache#setCacheAttributes(org.apache.jcs.engine.behavior.ICompositeCacheAttributes)
-     */
-    public void setCacheAttributes( ICompositeCacheAttributes cattr )
-    {
-        this.cacheAttr = cattr;
-    }
-
-    public CompositeCache getCompositeCache()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    public Set getGroupKeys( String group )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.jcs.engine.memory.MemoryCache#freeElements(int)
-     */
-    public int freeElements( int numberToFree )
-        throws IOException
-    {
-        lastNumberOfFreedElements = numberToFree;
-        return 0;
-    }
-}
+package org.apache.jcs.engine.memory;
+
+/*
+ * 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.HashMap;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.stats.behavior.IStats;
+
+/**
+ * Mock implementation of a memory cache for testing things like the memory
+ * shrinker.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class MemoryCacheMockImpl
+    implements MemoryCache
+{
+    private ICompositeCacheAttributes cacheAttr;
+
+    private HashMap map = new HashMap();
+
+    /**
+     * The number of times waterfall was called.
+     */
+    public int waterfallCallCount = 0;
+
+    /**
+     * The number passed to the last call of free elements.
+     */
+    public int lastNumberOfFreedElements = 0;
+
+    public void initialize( CompositeCache cache )
+    {
+        // TODO Auto-generated method stub
+    }
+
+    public void dispose()
+        throws IOException
+    {
+        // TODO Auto-generated method stub
+
+    }
+
+    public int getSize()
+    {
+        return map.size();
+    }
+
+    public IStats getStatistics()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Iterator getIterator()
+    {
+        // return
+        return null;
+    }
+
+    public Object[] getKeyArray()
+    {
+        return map.keySet().toArray();
+    }
+
+    public boolean remove( Serializable key )
+        throws IOException
+    {
+        return map.remove( key ) != null;
+    }
+
+    public void removeAll()
+        throws IOException
+    {
+        map.clear();
+    }
+
+    public ICacheElement get( Serializable key )
+        throws IOException
+    {
+        return (ICacheElement) map.get( key );
+    }
+
+    public ICacheElement getQuiet( Serializable key )
+        throws IOException
+    {
+        return (ICacheElement) map.get( key );
+    }
+
+    public void waterfal( ICacheElement ce )
+        throws IOException
+    {
+        waterfallCallCount++;
+    }
+
+    public void update( ICacheElement ce )
+        throws IOException
+    {
+        if ( ce != null )
+        {
+            map.put( ce.getKey(), ce );
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see org.apache.jcs.engine.memory.MemoryCache#getCacheAttributes()
+     */
+    public ICompositeCacheAttributes getCacheAttributes()
+    {
+        return cacheAttr;
+    }
+
+    /*
+     * (non-Javadoc)
+     *
+     * @see 
org.apache.jcs.engine.memory.MemoryCache#setCacheAttributes(org.apache.jcs.engine.behavior.ICompositeCacheAttributes)
+     */
+    public void setCacheAttributes( ICompositeCacheAttributes cattr )
+    {
+        this.cacheAttr = cattr;
+    }
+
+    public CompositeCache getCompositeCache()
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Set getGroupKeys( String group )
+    {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.jcs.engine.memory.MemoryCache#freeElements(int)
+     */
+    public int freeElements( int numberToFree )
+        throws IOException
+    {
+        lastNumberOfFreedElements = numberToFree;
+        return 0;
+    }
+}

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
 Thu May 10 09:03:42 2007
@@ -1,19 +1,22 @@
 package org.apache.jcs.engine.memory.lru;
 
 /*
- * 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 junit.extensions.ActiveTestSuite;
@@ -28,7 +31,7 @@
 /**
  * Test which exercises the LRUMemory cache. This one uses three different
  * regions for three threads.
- * 
+ *
  * @version $Id$
  */
 public class LRUMemoryCacheConcurrentUnitTest
@@ -42,7 +45,7 @@
 
     /**
      * Constructor for the TestDiskCache object.
-     * 
+     *
      * @param testName
      */
     public LRUMemoryCacheConcurrentUnitTest( String testName )
@@ -52,7 +55,7 @@
 
     /**
      * Main method passes this test to the text test runner.
-     * 
+     *
      * @param args
      */
     public static void main( String args[] )
@@ -63,7 +66,7 @@
 
     /**
      * A unit test suite for JUnit
-     * 
+     *
      * @return The test suite
      */
     public static Test suite()
@@ -83,7 +86,7 @@
          * suite.addTest( new TestDiskCache( "testIndexedDiskCache2" ) { public
          * void runTest() throws Exception { this.runTestForRegion(
          * "indexedRegion2" ); } } );
-         * 
+         *
          * suite.addTest( new TestDiskCache( "testIndexedDiskCache3" ) { public
          * void runTest() throws Exception { this.runTestForRegion(
          * "indexedRegion3" ); } } );
@@ -102,10 +105,10 @@
     /**
      * Adds items to cache, gets them, and removes them. The item count is more
      * than the size of the memory cache, so items should be dumped.
-     * 
+     *
      * @param region
      *            Name of the region to access
-     * 
+     *
      * @exception Exception
      *                If an error occurs
      */

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/LRUvsMRUPerformanceTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/LRUvsMRUPerformanceTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/LRUvsMRUPerformanceTest.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/LRUvsMRUPerformanceTest.java
 Thu May 10 09:03:42 2007
@@ -1,163 +1,182 @@
-package org.apache.jcs.engine.memory.mru;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.JCS;
-import org.apache.jcs.engine.memory.lru.LRUMemoryCache;
-
-/**
- * Tests the performance difference between the LRU and the MRU
- * 
- */
-public class LRUvsMRUPerformanceTest
-    extends TestCase
-{
-
-    float ratioPut = 0;
-
-    float ratioGet = 0;
-
-    float target = 1.20f;
-
-    int loops = 20;
-
-    int tries = 10000;
-
-    /**
-     * A unit test for JUnit
-     * 
-     * @exception Exception
-     *                Description of the Exception
-     */
-    public void testSimpleLoad()
-        throws Exception
-    {
-        Log log1 = LogFactory.getLog( LRUMemoryCache.class );
-        if ( log1.isDebugEnabled() )
-        {
-            System.out.println( "The log level must be at info or above for 
the a performance test." );
-            return;
-        }
-        Log log2 = LogFactory.getLog( MRUMemoryCache.class );
-        if ( log2.isDebugEnabled() )
-        {
-            System.out.println( "The log level must be at info or above for 
the a performance test." );
-            return;
-        }
-        doWork();
-
-        assertTrue( "Ratio is unacceptible.", this.ratioPut < target );
-        assertTrue( "Ratio is unacceptible.", this.ratioGet < target );
-    }
-
-    /**
-     * Runs the test
-     */
-    public void doWork()
-    {
-
-        long start = 0;
-        long end = 0;
-        long time = 0;
-        float tPer = 0;
-
-        long putTotalLRU = 0;
-        long getTotalLRU = 0;
-        long putTotalMRU = 0;
-        long getTotalMRU = 0;
-
-        try
-        {
-
-            JCS.setConfigFilename( "/TestMRUCache.ccf" );
-            JCS cache = JCS.getInstance( "lruDefined" );
-            JCS mru = JCS.getInstance( "mruDefined" );
-
-            System.out.println( "LRU = " + cache );
-
-            for ( int j = 0; j < loops; j++ )
-            {
-
-                System.out.println( "Beginning loop " + j );
-
-                String name = "LRU      ";
-                start = System.currentTimeMillis();
-                for ( int i = 0; i < tries; i++ )
-                {
-                    cache.put( "key:" + i, "data" + i );
-                }
-                end = System.currentTimeMillis();
-                time = end - start;
-                putTotalLRU += time;
-                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
-                System.out.println( name + " put time for " + tries + " = " + 
time + "; millis per = " + tPer );
-
-                start = System.currentTimeMillis();
-                for ( int i = 0; i < tries; i++ )
-                {
-                    cache.get( "key:" + i );
-                }
-                end = System.currentTimeMillis();
-                time = end - start;
-                getTotalLRU += time;
-                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
-                System.out.println( name + " get time for " + tries + " = " + 
time + "; millis per = " + tPer );
-
-                // 
/////////////////////////////////////////////////////////////
-                name = "MRU";
-                start = System.currentTimeMillis();
-                for ( int i = 0; i < tries; i++ )
-                {
-                    mru.put( "key:" + i, "data" + i );
-                }
-                end = System.currentTimeMillis();
-                time = end - start;
-                putTotalMRU += time;
-                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
-                System.out.println( name + " put time for " + tries + " = " + 
time + "; millis per = " + tPer );
-
-                start = System.currentTimeMillis();
-                for ( int i = 0; i < tries; i++ )
-                {
-                    mru.get( "key:" + i );
-                }
-                end = System.currentTimeMillis();
-                time = end - start;
-                getTotalMRU += time;
-                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
-                System.out.println( name + " get time for " + tries + " = " + 
time + "; millis per = " + tPer );
-
-                System.out.println( "\n" );
-            }
-
-        }
-        catch ( Exception e )
-        {
-            e.printStackTrace( System.out );
-            System.out.println( e );
-        }
-
-        long putAvJCS = putTotalLRU / loops;
-        long getAvJCS = getTotalLRU / loops;
-        long putAvHashtable = putTotalMRU / loops;
-        long getAvHashtable = getTotalMRU / loops;
-
-        System.out.println( "Finished " + loops + " loops of " + tries + " 
gets and puts" );
-
-        System.out.println( "\n" );
-        System.out.println( "Put average for JCS       = " + putAvJCS );
-        System.out.println( "Put average for MRU = " + putAvHashtable );
-        ratioPut = Float.intBitsToFloat( (int) putAvJCS ) / 
Float.intBitsToFloat( (int) putAvHashtable );
-        System.out.println( "JCS puts took " + ratioPut + " times the 
Hashtable, the goal is <" + target + "x" );
-
-        System.out.println( "\n" );
-        System.out.println( "Get average for JCS       = " + getAvJCS );
-        System.out.println( "Get average for MRU = " + getAvHashtable );
-        ratioGet = Float.intBitsToFloat( (int) getAvJCS ) / 
Float.intBitsToFloat( (int) getAvHashtable );
-        System.out.println( "JCS gets took " + ratioGet + " times the 
Hashtable, the goal is <" + target + "x" );
-
-    }
-
-}
+package org.apache.jcs.engine.memory.mru;
+
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.memory.lru.LRUMemoryCache;
+
+/**
+ * Tests the performance difference between the LRU and the MRU
+ *
+ */
+public class LRUvsMRUPerformanceTest
+    extends TestCase
+{
+
+    float ratioPut = 0;
+
+    float ratioGet = 0;
+
+    float target = 1.20f;
+
+    int loops = 20;
+
+    int tries = 10000;
+
+    /**
+     * A unit test for JUnit
+     *
+     * @exception Exception
+     *                Description of the Exception
+     */
+    public void testSimpleLoad()
+        throws Exception
+    {
+        Log log1 = LogFactory.getLog( LRUMemoryCache.class );
+        if ( log1.isDebugEnabled() )
+        {
+            System.out.println( "The log level must be at info or above for 
the a performance test." );
+            return;
+        }
+        Log log2 = LogFactory.getLog( MRUMemoryCache.class );
+        if ( log2.isDebugEnabled() )
+        {
+            System.out.println( "The log level must be at info or above for 
the a performance test." );
+            return;
+        }
+        doWork();
+
+        assertTrue( "Ratio is unacceptible.", this.ratioPut < target );
+        assertTrue( "Ratio is unacceptible.", this.ratioGet < target );
+    }
+
+    /**
+     * Runs the test
+     */
+    public void doWork()
+    {
+
+        long start = 0;
+        long end = 0;
+        long time = 0;
+        float tPer = 0;
+
+        long putTotalLRU = 0;
+        long getTotalLRU = 0;
+        long putTotalMRU = 0;
+        long getTotalMRU = 0;
+
+        try
+        {
+
+            JCS.setConfigFilename( "/TestMRUCache.ccf" );
+            JCS cache = JCS.getInstance( "lruDefined" );
+            JCS mru = JCS.getInstance( "mruDefined" );
+
+            System.out.println( "LRU = " + cache );
+
+            for ( int j = 0; j < loops; j++ )
+            {
+
+                System.out.println( "Beginning loop " + j );
+
+                String name = "LRU      ";
+                start = System.currentTimeMillis();
+                for ( int i = 0; i < tries; i++ )
+                {
+                    cache.put( "key:" + i, "data" + i );
+                }
+                end = System.currentTimeMillis();
+                time = end - start;
+                putTotalLRU += time;
+                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
+                System.out.println( name + " put time for " + tries + " = " + 
time + "; millis per = " + tPer );
+
+                start = System.currentTimeMillis();
+                for ( int i = 0; i < tries; i++ )
+                {
+                    cache.get( "key:" + i );
+                }
+                end = System.currentTimeMillis();
+                time = end - start;
+                getTotalLRU += time;
+                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
+                System.out.println( name + " get time for " + tries + " = " + 
time + "; millis per = " + tPer );
+
+                // 
/////////////////////////////////////////////////////////////
+                name = "MRU";
+                start = System.currentTimeMillis();
+                for ( int i = 0; i < tries; i++ )
+                {
+                    mru.put( "key:" + i, "data" + i );
+                }
+                end = System.currentTimeMillis();
+                time = end - start;
+                putTotalMRU += time;
+                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
+                System.out.println( name + " put time for " + tries + " = " + 
time + "; millis per = " + tPer );
+
+                start = System.currentTimeMillis();
+                for ( int i = 0; i < tries; i++ )
+                {
+                    mru.get( "key:" + i );
+                }
+                end = System.currentTimeMillis();
+                time = end - start;
+                getTotalMRU += time;
+                tPer = Float.intBitsToFloat( (int) time ) / 
Float.intBitsToFloat( tries );
+                System.out.println( name + " get time for " + tries + " = " + 
time + "; millis per = " + tPer );
+
+                System.out.println( "\n" );
+            }
+
+        }
+        catch ( Exception e )
+        {
+            e.printStackTrace( System.out );
+            System.out.println( e );
+        }
+
+        long putAvJCS = putTotalLRU / loops;
+        long getAvJCS = getTotalLRU / loops;
+        long putAvHashtable = putTotalMRU / loops;
+        long getAvHashtable = getTotalMRU / loops;
+
+        System.out.println( "Finished " + loops + " loops of " + tries + " 
gets and puts" );
+
+        System.out.println( "\n" );
+        System.out.println( "Put average for JCS       = " + putAvJCS );
+        System.out.println( "Put average for MRU = " + putAvHashtable );
+        ratioPut = Float.intBitsToFloat( (int) putAvJCS ) / 
Float.intBitsToFloat( (int) putAvHashtable );
+        System.out.println( "JCS puts took " + ratioPut + " times the 
Hashtable, the goal is <" + target + "x" );
+
+        System.out.println( "\n" );
+        System.out.println( "Get average for JCS       = " + getAvJCS );
+        System.out.println( "Get average for MRU = " + getAvHashtable );
+        ratioGet = Float.intBitsToFloat( (int) getAvJCS ) / 
Float.intBitsToFloat( (int) getAvHashtable );
+        System.out.println( "JCS gets took " + ratioGet + " times the 
Hashtable, the goal is <" + target + "x" );
+
+    }
+
+}

Modified: 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
URL: 
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java?view=diff&rev=536904&r1=536903&r2=536904
==============================================================================
--- 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
 (original)
+++ 
jakarta/jcs/trunk/src/test/org/apache/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
 Thu May 10 09:03:42 2007
@@ -1,281 +1,300 @@
-package org.apache.jcs.engine.memory.mru;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-import org.apache.jcs.access.exception.CacheException;
-import org.apache.jcs.engine.CacheElement;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.control.CompositeCache;
-import org.apache.jcs.engine.control.CompositeCacheManager;
-
-/**
- * Tests for the test MRU implementation that uses the java linked list class.
- * This is more a set of tests for the hub than for the MRU, since we don't 
care
- * about the MRU.
- * 
- * @author Aaron Smuts
- * 
- */
-public class MRUMemoryCacheUnitTest
-    extends TestCase
-{
-
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestMRUCache.ccf" );
-    }
-
-    /**
-     * Verify that the mru gets used by a non-defined region when it is set as
-     * the defualt in the default region.
-     * 
-     * @throws CacheException
-     */
-    public void testLoadFromCCF()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testPutGet" );
-        String memoryCacheName = 
cache.getCacheAttributes().getMemoryCacheName();
-        assertTrue( "Cache name should have MRU in it.", 
memoryCacheName.indexOf( "MRUMemoryCache" ) != -1 );
-    }
-
-    /**
-     * put twice as many as the max. verify that the second half is in the
-     * cache.
-     * 
-     * @throws CacheException
-     */
-    public void testPutGetThroughHub()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max * 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        // Test that first items are not in the cache
-        for ( int i = max; i >= 0; i-- )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
-        }
-
-        // Test that last items are in cache
-        // skip 2 for the buffer.
-        for ( int i = max + 2; i < items; i++ )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertEquals( "myregion" + " data " + i, value );
-        }
-
-    }
-
-    /**
-     * Put twice as many as the max, twice. verify that the second half is in
-     * the cache.
-     * 
-     * @throws CacheException
-     */
-    public void testPutGetThroughHubTwice()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max * 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        // Test that first items are not in the cache
-        for ( int i = max; i >= 0; i-- )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
-        }
-
-        // Test that last items are in cache
-        // skip 2 for the buffer.
-        for ( int i = max + 2; i < items; i++ )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertEquals( "myregion" + " data " + i, value );
-        }
-
-    }
-
-    /**
-     * put the max and remove each. verify that they are all null.
-     * 
-     * @throws CacheException
-     */
-    public void testPutRemoveThroughHub()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max * 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.remove( i + ":key" );
-        }
-
-        // Test that first items are not in the cache
-        for ( int i = max; i >= 0; i-- )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
-        }
-    }
-
-    /**
-     * put the max and clear. verify that no elements remain.
-     * 
-     * @throws CacheException
-     */
-    public void testClearThroughHub()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max * 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        cache.clear();
-
-        // Test that first items are not in the cache
-        for ( int i = max; i >= 0; i-- )
-        {
-            String value = (String) cache.get( i + ":key" );
-            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
-        }
-    }
-
-    /**
-     * put twice the max and clear. verify that no elements remain.
-     * 
-     * @throws CacheException
-     */
-    public void testGetStatsThroughHub()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testGetStatsThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max * 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( i + ":key", "myregion" + " data " + i );
-        }
-
-        String stats = cache.getStats();
-
-        System.out.println( stats );
-
-        // TODO improve stats check
-        assertTrue( "Should have 200 puts", stats.indexOf( "2000" ) != -1 );
-    }
-
-    /**
-     * Put half the max and clear. get the key array and verify that it has the
-     * correct number of items.
-     * 
-     * @throws Exception
-     */
-    public void testGetKeyArray()
-        throws Exception
-    {
-        CompositeCacheManager cacheMgr = 
CompositeCacheManager.getUnconfiguredInstance();
-        cacheMgr.configure( "/TestMRUCache.ccf" );
-        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );
-
-        MRUMemoryCache mru = new MRUMemoryCache();
-        mru.initialize( cache );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max / 2;
-
-        for ( int i = 0; i < items; i++ )
-        {
-            ICacheElement ice = new CacheElement( cache.getCacheName(), i + 
":key", cache.getCacheName() + " data " + i );
-            ice.setElementAttributes( cache.getElementAttributes() );
-            mru.update( ice );
-        }
-
-        Object[] keys = mru.getKeyArray();
-
-        assertEquals( "Wrong number of keys.", items, keys.length );
-    }
-
-    
-    /**
-     * Add a few keys with the delimeter.  Remove them.
-     * 
-     * 
-     * @throws CacheException
-     */
-    public void testRemovePartialThroughHub()
-        throws CacheException
-    {
-        JCS cache = JCS.getInstance( "testGetStatsThroughHub" );
-
-        int max = cache.getCacheAttributes().getMaxObjects();
-        int items = max / 2;
-        
-        cache.put( "test", "data" );
-        
-        String root = "myroot";
-        
-        for ( int i = 0; i < items; i++ )
-        {
-            cache.put( root + ":" + i + ":key", "myregion" + " data " + i );
-        }
-        
-        // Test that last items are in cache
-        for ( int i = 0; i < items; i++ )
-        {
-            String value = (String) cache.get( root + ":" + i + ":key" );
-            assertEquals( "myregion" + " data " + i, value );
-        }
-        
-        // remove partial
-        cache.remove( root + ":" );
-        
-        for ( int i = 0; i < items; i++ )
-        {
-            assertNull( "Should have been removed by partial loop.", 
cache.get( root + ":" + i + ":key" ) );
-        }
-        
-        assertNotNull( "Other item should be in the cache.", cache.get( "test" 
) );
-        
-    }
-}
+package org.apache.jcs.engine.memory.mru;
+
+/*
+ * 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 junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.access.exception.CacheException;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.control.CompositeCache;
+import org.apache.jcs.engine.control.CompositeCacheManager;
+
+/**
+ * Tests for the test MRU implementation that uses the java linked list class.
+ * This is more a set of tests for the hub than for the MRU, since we don't 
care
+ * about the MRU.
+ *
+ * @author Aaron Smuts
+ *
+ */
+public class MRUMemoryCacheUnitTest
+    extends TestCase
+{
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestMRUCache.ccf" );
+    }
+
+    /**
+     * Verify that the mru gets used by a non-defined region when it is set as
+     * the defualt in the default region.
+     *
+     * @throws CacheException
+     */
+    public void testLoadFromCCF()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testPutGet" );
+        String memoryCacheName = 
cache.getCacheAttributes().getMemoryCacheName();
+        assertTrue( "Cache name should have MRU in it.", 
memoryCacheName.indexOf( "MRUMemoryCache" ) != -1 );
+    }
+
+    /**
+     * put twice as many as the max. verify that the second half is in the
+     * cache.
+     *
+     * @throws CacheException
+     */
+    public void testPutGetThroughHub()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max * 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        // Test that first items are not in the cache
+        for ( int i = max; i >= 0; i-- )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
+        }
+
+        // Test that last items are in cache
+        // skip 2 for the buffer.
+        for ( int i = max + 2; i < items; i++ )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertEquals( "myregion" + " data " + i, value );
+        }
+
+    }
+
+    /**
+     * Put twice as many as the max, twice. verify that the second half is in
+     * the cache.
+     *
+     * @throws CacheException
+     */
+    public void testPutGetThroughHubTwice()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max * 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        // Test that first items are not in the cache
+        for ( int i = max; i >= 0; i-- )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
+        }
+
+        // Test that last items are in cache
+        // skip 2 for the buffer.
+        for ( int i = max + 2; i < items; i++ )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertEquals( "myregion" + " data " + i, value );
+        }
+
+    }
+
+    /**
+     * put the max and remove each. verify that they are all null.
+     *
+     * @throws CacheException
+     */
+    public void testPutRemoveThroughHub()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max * 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.remove( i + ":key" );
+        }
+
+        // Test that first items are not in the cache
+        for ( int i = max; i >= 0; i-- )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
+        }
+    }
+
+    /**
+     * put the max and clear. verify that no elements remain.
+     *
+     * @throws CacheException
+     */
+    public void testClearThroughHub()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testPutGetThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max * 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        cache.clear();
+
+        // Test that first items are not in the cache
+        for ( int i = max; i >= 0; i-- )
+        {
+            String value = (String) cache.get( i + ":key" );
+            assertNull( "Should not have value for key [" + i + ":key" + "] in 
the cache.", value );
+        }
+    }
+
+    /**
+     * put twice the max and clear. verify that no elements remain.
+     *
+     * @throws CacheException
+     */
+    public void testGetStatsThroughHub()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testGetStatsThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max * 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( i + ":key", "myregion" + " data " + i );
+        }
+
+        String stats = cache.getStats();
+
+        System.out.println( stats );
+
+        // TODO improve stats check
+        assertTrue( "Should have 200 puts", stats.indexOf( "2000" ) != -1 );
+    }
+
+    /**
+     * Put half the max and clear. get the key array and verify that it has the
+     * correct number of items.
+     *
+     * @throws Exception
+     */
+    public void testGetKeyArray()
+        throws Exception
+    {
+        CompositeCacheManager cacheMgr = 
CompositeCacheManager.getUnconfiguredInstance();
+        cacheMgr.configure( "/TestMRUCache.ccf" );
+        CompositeCache cache = cacheMgr.getCache( "testGetKeyArray" );
+
+        MRUMemoryCache mru = new MRUMemoryCache();
+        mru.initialize( cache );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max / 2;
+
+        for ( int i = 0; i < items; i++ )
+        {
+            ICacheElement ice = new CacheElement( cache.getCacheName(), i + 
":key", cache.getCacheName() + " data " + i );
+            ice.setElementAttributes( cache.getElementAttributes() );
+            mru.update( ice );
+        }
+
+        Object[] keys = mru.getKeyArray();
+
+        assertEquals( "Wrong number of keys.", items, keys.length );
+    }
+
+
+    /**
+     * Add a few keys with the delimeter.  Remove them.
+     *
+     *
+     * @throws CacheException
+     */
+    public void testRemovePartialThroughHub()
+        throws CacheException
+    {
+        JCS cache = JCS.getInstance( "testGetStatsThroughHub" );
+
+        int max = cache.getCacheAttributes().getMaxObjects();
+        int items = max / 2;
+
+        cache.put( "test", "data" );
+
+        String root = "myroot";
+
+        for ( int i = 0; i < items; i++ )
+        {
+            cache.put( root + ":" + i + ":key", "myregion" + " data " + i );
+        }
+
+        // Test that last items are in cache
+        for ( int i = 0; i < items; i++ )
+        {
+            String value = (String) cache.get( root + ":" + i + ":key" );
+            assertEquals( "myregion" + " data " + i, value );
+        }
+
+        // remove partial
+        cache.remove( root + ":" );
+
+        for ( int i = 0; i < items; i++ )
+        {
+            assertNull( "Should have been removed by partial loop.", 
cache.get( root + ":" + i + ":key" ) );
+        }
+
+        assertNotNull( "Other item should be in the cache.", cache.get( "test" 
) );
+
+    }
+}


<Prev in Thread] Current Thread [Next in Thread>