You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2008/04/11 20:43:31 UTC

svn commit: r647264 [4/6] - in /jakarta/jcs/trunk: ./ src/java/org/apache/jcs/access/ src/java/org/apache/jcs/access/behavior/ src/java/org/apache/jcs/auxiliary/ src/java/org/apache/jcs/auxiliary/disk/ src/java/org/apache/jcs/auxiliary/lateral/ src/jav...

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java Fri Apr 11 11:43:26 2008
@@ -1,201 +1,218 @@
-package org.apache.jcs.auxiliary.disk.jdbc;
-
-/*
- * 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.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-
-/**
- * Runs basic tests for the JDBC disk cache.
- *
- * @author Aaron Smuts
- *
- */
-public class JDBCDiskCacheUnitTest
-    extends TestCase
-{
-
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestJDBCDiskCache.ccf" );
-    }
-
-    /**
-     * Test the basic JDBC disk cache functionality with a hsql backing.
-     *
-     * @throws Exception
-     */
-    public void testSimpleJDBCPutGetWithHSQL()
-        throws Exception
-    {
-        System.setProperty( "hsqldb.cache_scale", "8" );
-
-        String rafroot = "target";
-        Properties p = new Properties();
-        String driver = p.getProperty( "driver", "org.hsqldb.jdbcDriver" );
-        String url = p.getProperty( "url", "jdbc:hsqldb:" );
-        String database = p.getProperty( "database", rafroot + "/cache_hsql_db" );
-        String user = p.getProperty( "user", "sa" );
-        String password = p.getProperty( "password", "" );
-
-        new org.hsqldb.jdbcDriver();
-        Class.forName( driver ).newInstance();
-        Connection cConn = DriverManager.getConnection( url + database, user, password );
-
-        setupTABLE( cConn );
-
-        runTestForRegion( "testCache1", 200 );
-    }
-
-    /**
-     * Adds items to cache, gets them, and removes them. The item count is more
-     * than the size of the memory cache, so items should spool to disk.
-     *
-     * @param region
-     *            Name of the region to access
-     * @param items
-     *
-     * @exception Exception
-     *                If an error occurs
-     */
-    public void runTestForRegion( String region, int items )
-        throws Exception
-    {
-        JCS jcs = JCS.getInstance( region );
-
-        System.out.println( "BEFORE PUT \n" + jcs.getStats() );
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        System.out.println( jcs.getStats() );
-
-        Thread.sleep( 1000 );
-
-        System.out.println( jcs.getStats() );
-
-        // Test that all items are in cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
-        }
-
-        // Remove all the items
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.remove( i + ":key" );
-        }
-
-        // Verify removal
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
-        }
-    }
-
-    /**
-     * SETUP TABLE FOR CACHE
-     *
-     * @param cConn
-     */
-    void setupTABLE( Connection cConn )
-    {
-        boolean newT = true;
-
-        StringBuffer createSql = new StringBuffer();
-        createSql.append( "CREATE CACHED TABLE JCS_STORE2 " );
-        createSql.append( "( " );
-        createSql.append( "CACHE_KEY             VARCHAR(250)          NOT NULL, " );
-        createSql.append( "REGION                VARCHAR(250)          NOT NULL, " );
-        createSql.append( "ELEMENT               BINARY, " );
-        createSql.append( "CREATE_TIME           DATE, " );
-        createSql.append( "CREATE_TIME_SECONDS   BIGINT, " );
-        createSql.append( "MAX_LIFE_SECONDS      BIGINT, " );
-        createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS      BIGINT, " );
-        createSql.append( "IS_ETERNAL            CHAR(1), " );
-        createSql.append( "PRIMARY KEY (CACHE_KEY, REGION) " );
-        createSql.append( ");" );
-
-        Statement sStatement = null;
-        try
-        {
-            sStatement = cConn.createStatement();
-        }
-        catch ( SQLException e )
-        {
-            e.printStackTrace();
-        }
-
-        try
-        {
-            sStatement.executeQuery( createSql.toString() );
-            sStatement.close();
-        }
-        catch ( SQLException e )
-        {
-            if ( e.toString().indexOf( "already exists" ) != -1 )
-            {
-                newT = false;
-            }
-            else
-            {
-                // TODO figure out if it exists prior to trying to create it.
-                // log.error( "Problem creating table.", e );
-                e.printStackTrace();
-            }
-        }
-
-        String setupData[] = { "create index iKEY on JCS_STORE2 (CACHE_KEY, REGION)" };
-
-        if ( newT )
-        {
-            for ( int i = 1; i < setupData.length; i++ )
-            {
-                try
-                {
-                    sStatement.executeQuery( setupData[i] );
-                }
-                catch ( SQLException e )
-                {
-                    System.out.println( "Exception: " + e );
-                }
-            }
-        } // end ifnew
-    }
-}
+package org.apache.jcs.auxiliary.disk.jdbc;
+
+/*
+ * 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.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * Runs basic tests for the JDBC disk cache.
+ *
+ * @author Aaron Smuts
+ *
+ */
+public class JDBCDiskCacheUnitTest
+    extends TestCase
+{
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestJDBCDiskCache.ccf" );
+    }
+
+    /**
+     * Test the basic JDBC disk cache functionality with a hsql backing.
+     *
+     * @throws Exception
+     */
+    public void testSimpleJDBCPutGetWithHSQL()
+        throws Exception
+    {
+        System.setProperty( "hsqldb.cache_scale", "8" );
+
+        String rafroot = "target";
+        Properties p = new Properties();
+        String driver = p.getProperty( "driver", "org.hsqldb.jdbcDriver" );
+        String url = p.getProperty( "url", "jdbc:hsqldb:" );
+        String database = p.getProperty( "database", rafroot + "/cache_hsql_db" );
+        String user = p.getProperty( "user", "sa" );
+        String password = p.getProperty( "password", "" );
+
+        new org.hsqldb.jdbcDriver();
+        Class.forName( driver ).newInstance();
+        Connection cConn = DriverManager.getConnection( url + database, user, password );
+
+        setupTABLE( cConn );
+
+        runTestForRegion( "testCache1", 200 );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more
+     * than the size of the memory cache, so items should spool to disk.
+     *
+     * @param region
+     *            Name of the region to access
+     * @param items
+     *
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int items )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        System.out.println( "BEFORE PUT \n" + jcs.getStats() );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        System.out.println( jcs.getStats() );
+
+        Thread.sleep( 1000 );
+
+        System.out.println( jcs.getStats() );
+
+        // Test that all items are in cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
+        }
+
+        // Test that getElements returns all the expected values
+        Set keys = new HashSet();
+        for ( int i = 0; i <= items; i++ )
+        {
+            keys.add( i + ":key" );
+        }
+
+        Map elements = jcs.getCacheElements( keys );
+        for ( int i = 0; i <= items; i++ )
+        {
+            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            assertNotNull( "element " + i + ":key is missing", element );
+            assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
+        }
+
+        // Remove all the items
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+    }
+
+    /**
+     * SETUP TABLE FOR CACHE
+     *
+     * @param cConn
+     */
+    void setupTABLE( Connection cConn )
+    {
+        boolean newT = true;
+
+        StringBuffer createSql = new StringBuffer();
+        createSql.append( "CREATE CACHED TABLE JCS_STORE2 " );
+        createSql.append( "( " );
+        createSql.append( "CACHE_KEY             VARCHAR(250)          NOT NULL, " );
+        createSql.append( "REGION                VARCHAR(250)          NOT NULL, " );
+        createSql.append( "ELEMENT               BINARY, " );
+        createSql.append( "CREATE_TIME           DATE, " );
+        createSql.append( "CREATE_TIME_SECONDS   BIGINT, " );
+        createSql.append( "MAX_LIFE_SECONDS      BIGINT, " );
+        createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS      BIGINT, " );
+        createSql.append( "IS_ETERNAL            CHAR(1), " );
+        createSql.append( "PRIMARY KEY (CACHE_KEY, REGION) " );
+        createSql.append( ");" );
+
+        Statement sStatement = null;
+        try
+        {
+            sStatement = cConn.createStatement();
+        }
+        catch ( SQLException e )
+        {
+            e.printStackTrace();
+        }
+
+        try
+        {
+            sStatement.executeQuery( createSql.toString() );
+            sStatement.close();
+        }
+        catch ( SQLException e )
+        {
+            if ( e.toString().indexOf( "already exists" ) != -1 )
+            {
+                newT = false;
+            }
+            else
+            {
+                // TODO figure out if it exists prior to trying to create it.
+                // log.error( "Problem creating table.", e );
+                e.printStackTrace();
+            }
+        }
+
+        String setupData[] = { "create index iKEY on JCS_STORE2 (CACHE_KEY, REGION)" };
+
+        if ( newT )
+        {
+            for ( int i = 1; i < setupData.length; i++ )
+            {
+                try
+                {
+                    sStatement.executeQuery( setupData[i] );
+                }
+                catch ( SQLException e )
+                {
+                    System.out.println( "Exception: " + e );
+                }
+            }
+        } // end ifnew
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java Fri Apr 11 11:43:26 2008
@@ -1,155 +1,171 @@
-package org.apache.jcs.auxiliary.disk.jdbc.hsql;
-
-/*
- * 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.extensions.ActiveTestSuite;
-import junit.framework.Test;
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-
-/**
- * Test which exercises the indexed disk cache. This one uses three different regions for thre
- * threads.
- */
-public class HSQLDiskCacheConcurrentUnitTest
-    extends TestCase
-{
-    /**
-     * Number of items to cache, twice the configured maxObjects for the memory cache regions.
-     */
-    private static int items = 100;
-
-    /**
-     * Constructor for the TestDiskCache object.
-     * @param testName
-     */
-    public HSQLDiskCacheConcurrentUnitTest( String testName )
-    {
-        super( testName );
-    }
-
-    /**
-     * Main method passes this test to the text test runner.
-     * <p>
-     * @param args
-     */
-    public static void main( String args[] )
-    {
-        String[] testCaseName = { HSQLDiskCacheConcurrentUnitTest.class.getName() };
-        junit.textui.TestRunner.main( testCaseName );
-    }
-
-    /**
-     * A unit test suite for JUnit. Uses ActiveTestSuite to run multiple tests concurrently.
-     * <p>
-     * @return The test suite
-     */
-    public static Test suite()
-    {
-        ActiveTestSuite suite = new ActiveTestSuite();
-
-        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache1" )
-        {
-            public void runTest()
-                throws Exception
-            {
-                this.runTestForRegion( "indexedRegion1" );
-            }
-        } );
-
-        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache2" )
-        {
-            public void runTest()
-                throws Exception
-            {
-                this.runTestForRegion( "indexedRegion2" );
-            }
-        } );
-
-        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache3" )
-        {
-            public void runTest()
-                throws Exception
-            {
-                this.runTestForRegion( "indexedRegion3" );
-            }
-        } );
-
-        return suite;
-    }
-
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestHSQLDiskCacheConcurrent.ccf" );
-    }
-
-    /**
-     * Adds items to cache, gets them, and removes them. The item count is more than the size of the
-     * memory cache, so items should spool to disk.
-     * <p>
-     * @param region Name of the region to access
-     * @exception Exception If an error occurs
-     */
-    public void runTestForRegion( String region )
-        throws Exception
-    {
-        JCS jcs = JCS.getInstance( region );
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        System.out.println( jcs.getStats() );
-
-        // Thread.sleep( 1000 );
-
-        // System.out.println( jcs.getStats() );
-
-        // Test that all items are in cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
-        }
-
-        // Remove all the items
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.remove( i + ":key" );
-        }
-
-        // Verify removal
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
-        }
-    }
-}
+package org.apache.jcs.auxiliary.disk.jdbc.hsql;
+
+/*
+ * 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.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * Test which exercises the indexed disk cache. This one uses three different regions for thre
+ * threads.
+ */
+public class HSQLDiskCacheConcurrentUnitTest
+    extends TestCase
+{
+    /**
+     * Number of items to cache, twice the configured maxObjects for the memory cache regions.
+     */
+    private static int items = 100;
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * @param testName
+     */
+    public HSQLDiskCacheConcurrentUnitTest( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Main method passes this test to the text test runner.
+     * <p>
+     * @param args
+     */
+    public static void main( String args[] )
+    {
+        String[] testCaseName = { HSQLDiskCacheConcurrentUnitTest.class.getName() };
+        junit.textui.TestRunner.main( testCaseName );
+    }
+
+    /**
+     * A unit test suite for JUnit. Uses ActiveTestSuite to run multiple tests concurrently.
+     * <p>
+     * @return The test suite
+     */
+    public static Test suite()
+    {
+        ActiveTestSuite suite = new ActiveTestSuite();
+
+        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache1" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion1" );
+            }
+        } );
+
+        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache2" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion2" );
+            }
+        } );
+
+        suite.addTest( new HSQLDiskCacheConcurrentUnitTest( "testHSQLDiskCache3" )
+        {
+            public void runTest()
+                throws Exception
+            {
+                this.runTestForRegion( "indexedRegion3" );
+            }
+        } );
+
+        return suite;
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestHSQLDiskCacheConcurrent.ccf" );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more than the size of the
+     * memory cache, so items should spool to disk.
+     * <p>
+     * @param region Name of the region to access
+     * @exception Exception If an error occurs
+     */
+    public void runTestForRegion( String region )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        System.out.println( jcs.getStats() );
+
+        // Test that all items are in cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
+        }
+
+        // Test that getElements returns all the expected values
+        Set keys = new HashSet();
+        for ( int i = 0; i <= items; i++ )
+        {
+            keys.add( i + ":key" );
+        }
+
+        Map elements = jcs.getCacheElements( keys );
+        for ( int i = 0; i <= items; i++ )
+        {
+            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            assertNotNull( "element " + i + ":key is missing", element );
+            assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
+        }
+
+        // Remove all the items
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java Fri Apr 11 11:43:26 2008
@@ -1,168 +1,188 @@
-package org.apache.jcs.auxiliary.disk.jdbc.hsql;
-
-/*
- * 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;
-
-/**
- * Test which exercises the indexed disk cache. This one uses three different regions for thre
- * threads.
- */
-public class HSQLDiskCacheUnitTest
-    extends TestCase
-{
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestHSQLDiskCache.ccf" );
-    }
-
-    /**
-     * Adds items to cache, gets them, and removes them. The item count is more than the size of the
-     * memory cache, so items should spool to disk.
-     * <p>
-     * @param region Name of the region to access
-     * @exception Exception If an error occurs
-     */
-    public void testBasicPutRemove()
-        throws Exception
-    {
-        int items = 20;
-
-        String region = "testBasicPutRemove";
-
-        JCS jcs = JCS.getInstance( region );
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        //SleepUtil.sleepAtLeast( 1000 );
-
-        System.out.println( jcs.getStats() );
-
-        // Test that all items are in cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
-        }
-
-        // Remove all the items
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.remove( i + ":key" );
-        }
-
-        // Verify removal
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
-        }
-    }
-
-    /**
-     * Verify that remove all work son a region where it is not prohibited.
-     * <p>
-     * @throws CacheException
-     * @throws InterruptedException
-     */
-    public void testRemoveAll()
-        throws CacheException, InterruptedException
-    {
-        String region = "removeAllAllowed";
-        JCS jcs = JCS.getInstance( region );
-
-        int items = 20;
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        // a db thread could be updating when we call remove all?
-        // there was a race on remove all, an element may be put to disk after it is called even
-        // though the put
-        // was called before clear.
-        // I discovered it and removed it.
-        // Thread.sleep( 500 );
-
-        System.out.println( jcs.getStats() );
-
-        jcs.clear();
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertNull( "value should be null key = [" + i + ":key] value = [" + value + "]", value );
-        }
-    }
-
-    /**
-     * Verify that remove all does not work on a region where it is prohibited.
-     * <p>
-     * @throws CacheException
-     * @throws InterruptedException
-     */
-    public void testRemoveAllProhibition()
-        throws CacheException, InterruptedException
-    {
-        String region = "noRemoveAll";
-        JCS jcs = JCS.getInstance( region );
-
-        int items = 20;
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        // a db thread could be updating the disk when
-        // Thread.sleep( 500 );
-
-        System.out.println( jcs.getStats() );
-
-        jcs.clear();
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
-        }
-    }
-}
+package org.apache.jcs.auxiliary.disk.jdbc.hsql;
+
+/*
+ * 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.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.access.exception.CacheException;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * Test which exercises the indexed disk cache. This one uses three different regions for thre
+ * threads.
+ */
+public class HSQLDiskCacheUnitTest
+    extends TestCase
+{
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestHSQLDiskCache.ccf" );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more than the size of the
+     * memory cache, so items should spool to disk.
+     * <p>
+     * @exception Exception If an error occurs
+     */
+    public void testBasicPutRemove()
+        throws Exception
+    {
+        int items = 20;
+
+        String region = "testBasicPutRemove";
+
+        JCS jcs = JCS.getInstance( region );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        //SleepUtil.sleepAtLeast( 1000 );
+
+        System.out.println( jcs.getStats() );
+
+        // Test that all items are in cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
+        }
+
+        // Test that getElements returns all the expected values
+        Set keys = new HashSet();
+        for ( int i = 0; i <= items; i++ )
+        {
+            keys.add( i + ":key" );
+        }
+
+        Map elements = jcs.getCacheElements( keys );
+        for ( int i = 0; i <= items; i++ )
+        {
+            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            assertNotNull( "element " + i + ":key is missing", element );
+            assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
+        }
+
+
+        // Remove all the items
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+    }
+
+    /**
+     * Verify that remove all work son a region where it is not prohibited.
+     * <p>
+     * @throws CacheException
+     * @throws InterruptedException
+     */
+    public void testRemoveAll()
+        throws CacheException, InterruptedException
+    {
+        String region = "removeAllAllowed";
+        JCS jcs = JCS.getInstance( region );
+
+        int items = 20;
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        // a db thread could be updating when we call remove all?
+        // there was a race on remove all, an element may be put to disk after it is called even
+        // though the put
+        // was called before clear.
+        // I discovered it and removed it.
+        // Thread.sleep( 500 );
+
+        System.out.println( jcs.getStats() );
+
+        jcs.clear();
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertNull( "value should be null key = [" + i + ":key] value = [" + value + "]", value );
+        }
+    }
+
+    /**
+     * Verify that remove all does not work on a region where it is prohibited.
+     * <p>
+     * @throws CacheException
+     * @throws InterruptedException
+     */
+    public void testRemoveAllProhibition()
+        throws CacheException, InterruptedException
+    {
+        String region = "noRemoveAll";
+        JCS jcs = JCS.getInstance( region );
+
+        int items = 20;
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        // a db thread could be updating the disk when
+        // Thread.sleep( 500 );
+
+        System.out.println( jcs.getStats() );
+
+        jcs.clear();
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
+        }
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java Fri Apr 11 11:43:26 2008
@@ -1,201 +1,218 @@
-package org.apache.jcs.auxiliary.disk.jdbc.mysql;
-
-/*
- * 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.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.jcs.JCS;
-
-/**
- * Runs basic tests for the JDBC disk cache.
- *
- * @author Aaron Smuts
- *
- */
-public class MySQLDiskCacheHsqlBackedUnitTest
-    extends TestCase
-{
-
-    /**
-     * Test setup
-     */
-    public void setUp()
-    {
-        JCS.setConfigFilename( "/TestMySQLDiskCache.ccf" );
-    }
-
-    /**
-     * Test the basic JDBC disk cache functionality with a hsql backing.
-     *
-     * @throws Exception
-     */
-    public void testSimpleJDBCPutGetWithHSQL()
-        throws Exception
-    {
-        System.setProperty( "hsqldb.cache_scale", "8" );
-
-        String rafroot = "target";
-        Properties p = new Properties();
-        String driver = p.getProperty( "driver", "org.hsqldb.jdbcDriver" );
-        String url = p.getProperty( "url", "jdbc:hsqldb:" );
-        String database = p.getProperty( "database", rafroot + "/MySQLDiskCacheHsqlBackedUnitTest" );
-        String user = p.getProperty( "user", "sa" );
-        String password = p.getProperty( "password", "" );
-
-        new org.hsqldb.jdbcDriver();
-        Class.forName( driver ).newInstance();
-        Connection cConn = DriverManager.getConnection( url + database, user, password );
-
-        setupTABLE( cConn );
-
-        runTestForRegion( "testCache1", 30 );
-    }
-
-    /**
-     * Adds items to cache, gets them, and removes them. The item count is more
-     * than the size of the memory cache, so items should spool to disk.
-     *
-     * @param region
-     *            Name of the region to access
-     * @param items
-     *
-     * @exception Exception
-     *                If an error occurs
-     */
-    public void runTestForRegion( String region, int items )
-        throws Exception
-    {
-        JCS jcs = JCS.getInstance( region );
-
-        System.out.println( "BEFORE PUT \n" + jcs.getStats() );
-
-        // Add items to cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.put( i + ":key", region + " data " + i );
-        }
-
-        System.out.println( jcs.getStats() );
-
-        Thread.sleep( 1000 );
-
-        System.out.println( jcs.getStats() );
-
-        // Test that all items are in cache
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            String value = (String) jcs.get( i + ":key" );
-
-            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
-        }
-
-        // Remove all the items
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            jcs.remove( i + ":key" );
-        }
-
-        // Verify removal
-
-        for ( int i = 0; i <= items; i++ )
-        {
-            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
-        }
-    }
-
-    /**
-     * SETUP TABLE FOR CACHE
-     *
-     * @param cConn
-     */
-    void setupTABLE( Connection cConn )
-    {
-        boolean newT = true;
-
-        StringBuffer createSql = new StringBuffer();
-        createSql.append( "CREATE CACHED TABLE JCS_STORE_MYSQL " );
-        createSql.append( "( " );
-        createSql.append( "CACHE_KEY             VARCHAR(250)          NOT NULL, " );
-        createSql.append( "REGION                VARCHAR(250)          NOT NULL, " );
-        createSql.append( "ELEMENT               BINARY, " );
-        createSql.append( "CREATE_TIME           DATE, " );
-        createSql.append( "CREATE_TIME_SECONDS   BIGINT, " );
-        createSql.append( "MAX_LIFE_SECONDS      BIGINT, " );
-        createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS      BIGINT, " );
-        createSql.append( "IS_ETERNAL            CHAR(1), " );
-        createSql.append( "PRIMARY KEY (CACHE_KEY, REGION) " );
-        createSql.append( ");" );
-
-        Statement sStatement = null;
-        try
-        {
-            sStatement = cConn.createStatement();
-        }
-        catch ( SQLException e )
-        {
-            e.printStackTrace();
-        }
-
-        try
-        {
-            sStatement.executeQuery( createSql.toString() );
-            sStatement.close();
-        }
-        catch ( SQLException e )
-        {
-            if ( e.toString().indexOf( "already exists" ) != -1 )
-            {
-                newT = false;
-            }
-            else
-            {
-                // TODO figure out if it exists prior to trying to create it.
-                // log.error( "Problem creating table.", e );
-                e.printStackTrace();
-            }
-        }
-
-        String setupData[] = { "create index iKEY on JCS_STORE_MYSQL (CACHE_KEY, REGION)" };
-
-        if ( newT )
-        {
-            for ( int i = 1; i < setupData.length; i++ )
-            {
-                try
-                {
-                    sStatement.executeQuery( setupData[i] );
-                }
-                catch ( SQLException e )
-                {
-                    System.out.println( "Exception: " + e );
-                }
-            }
-        } // end ifnew
-    }
-}
+package org.apache.jcs.auxiliary.disk.jdbc.mysql;
+
+/*
+ * 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.sql.Connection;
+import java.sql.DriverManager;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * Runs basic tests for the JDBC disk cache.
+ *
+ * @author Aaron Smuts
+ *
+ */
+public class MySQLDiskCacheHsqlBackedUnitTest
+    extends TestCase
+{
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestMySQLDiskCache.ccf" );
+    }
+
+    /**
+     * Test the basic JDBC disk cache functionality with a hsql backing.
+     *
+     * @throws Exception
+     */
+    public void testSimpleJDBCPutGetWithHSQL()
+        throws Exception
+    {
+        System.setProperty( "hsqldb.cache_scale", "8" );
+
+        String rafroot = "target";
+        Properties p = new Properties();
+        String driver = p.getProperty( "driver", "org.hsqldb.jdbcDriver" );
+        String url = p.getProperty( "url", "jdbc:hsqldb:" );
+        String database = p.getProperty( "database", rafroot + "/MySQLDiskCacheHsqlBackedUnitTest" );
+        String user = p.getProperty( "user", "sa" );
+        String password = p.getProperty( "password", "" );
+
+        new org.hsqldb.jdbcDriver();
+        Class.forName( driver ).newInstance();
+        Connection cConn = DriverManager.getConnection( url + database, user, password );
+
+        setupTABLE( cConn );
+
+        runTestForRegion( "testCache1", 30 );
+    }
+
+    /**
+     * Adds items to cache, gets them, and removes them. The item count is more
+     * than the size of the memory cache, so items should spool to disk.
+     *
+     * @param region
+     *            Name of the region to access
+     * @param items
+     *
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int items )
+        throws Exception
+    {
+        JCS jcs = JCS.getInstance( region );
+
+        System.out.println( "BEFORE PUT \n" + jcs.getStats() );
+
+        // Add items to cache
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.put( i + ":key", region + " data " + i );
+        }
+
+        System.out.println( jcs.getStats() );
+
+        Thread.sleep( 1000 );
+
+        System.out.println( jcs.getStats() );
+
+        // Test that all items are in cache
+        for ( int i = 0; i <= items; i++ )
+        {
+            String value = (String) jcs.get( i + ":key" );
+
+            assertEquals( "key = [" + i + ":key] value = [" + value + "]", region + " data " + i, value );
+        }
+
+        // Test that getElements returns all the expected values
+        Set keys = new HashSet();
+        for ( int i = 0; i <= items; i++ )
+        {
+            keys.add( i + ":key" );
+        }
+
+        Map elements = jcs.getCacheElements( keys );
+        for ( int i = 0; i <= items; i++ )
+        {
+            ICacheElement element = (ICacheElement) elements.get( i + ":key" );
+            assertNotNull( "element " + i + ":key is missing", element );
+            assertEquals( "value " + i + ":key", region + " data " + i, element.getVal() );
+        }
+
+        // Remove all the items
+        for ( int i = 0; i <= items; i++ )
+        {
+            jcs.remove( i + ":key" );
+        }
+
+        // Verify removal
+
+        for ( int i = 0; i <= items; i++ )
+        {
+            assertNull( "Removed key should be null: " + i + ":key", jcs.get( i + ":key" ) );
+        }
+    }
+
+    /**
+     * SETUP TABLE FOR CACHE
+     *
+     * @param cConn
+     */
+    void setupTABLE( Connection cConn )
+    {
+        boolean newT = true;
+
+        StringBuffer createSql = new StringBuffer();
+        createSql.append( "CREATE CACHED TABLE JCS_STORE_MYSQL " );
+        createSql.append( "( " );
+        createSql.append( "CACHE_KEY             VARCHAR(250)          NOT NULL, " );
+        createSql.append( "REGION                VARCHAR(250)          NOT NULL, " );
+        createSql.append( "ELEMENT               BINARY, " );
+        createSql.append( "CREATE_TIME           DATE, " );
+        createSql.append( "CREATE_TIME_SECONDS   BIGINT, " );
+        createSql.append( "MAX_LIFE_SECONDS      BIGINT, " );
+        createSql.append( "SYSTEM_EXPIRE_TIME_SECONDS      BIGINT, " );
+        createSql.append( "IS_ETERNAL            CHAR(1), " );
+        createSql.append( "PRIMARY KEY (CACHE_KEY, REGION) " );
+        createSql.append( ");" );
+
+        Statement sStatement = null;
+        try
+        {
+            sStatement = cConn.createStatement();
+        }
+        catch ( SQLException e )
+        {
+            e.printStackTrace();
+        }
+
+        try
+        {
+            sStatement.executeQuery( createSql.toString() );
+            sStatement.close();
+        }
+        catch ( SQLException e )
+        {
+            if ( e.toString().indexOf( "already exists" ) != -1 )
+            {
+                newT = false;
+            }
+            else
+            {
+                // TODO figure out if it exists prior to trying to create it.
+                // log.error( "Problem creating table.", e );
+                e.printStackTrace();
+            }
+        }
+
+        String setupData[] = { "create index iKEY on JCS_STORE_MYSQL (CACHE_KEY, REGION)" };
+
+        if ( newT )
+        {
+            for ( int i = 1; i < setupData.length; i++ )
+            {
+                try
+                {
+                    sStatement.executeQuery( setupData[i] );
+                }
+                catch ( SQLException e )
+                {
+                    System.out.println( "Exception: " + e );
+                }
+            }
+        } // end ifnew
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java Fri Apr 11 11:43:26 2008
@@ -33,11 +33,13 @@
 public class LateralTCPFilterRemoveHashCodeUnitTest
     extends TestCase
 {
-
-    //private static boolean isSysOut = false;
-
+    /** Does the test print to system out. */
     private static boolean isSysOut = true;
+    //private static boolean isSysOut = false;
 
+    /** The port the server will listen to. */
+    private int serverPort = 1118;
+    
     /**
      * Constructor for the TestDiskCache object.
      *
@@ -53,6 +55,8 @@
      */
     public void setUp()
     {
+        System.setProperty( "jcs.auxiliary.LTCP.attributes.TcpServers", "localhost:" + serverPort );
+
         JCS.setConfigFilename( "/TestTCPLateralRemoveFilter.ccf" );
     }
 
@@ -91,7 +95,7 @@
         TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
         lattr2.setTcpListenerPort( 1102 );
         lattr2.setTransmissionTypeName( "TCP" );
-        lattr2.setTcpServer( "localhost:1110" );
+        lattr2.setTcpServer( "localhost:1118" );
         lattr2.setIssueRemoveOnPut( true );
         // should still try to remove
         lattr2.setAllowPut( false );

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java Fri Apr 11 11:43:26 2008
@@ -29,17 +29,20 @@
 
 /**
  * Tests the issue remove on put fuctionality.
- *
  * @author asmuts
  */
 public class LateralTCPIssueRemoveOnPutUnitTest
     extends TestCase
 {
+    /** Should log data go to system out. */
     private static boolean isSysOut = true;
 
+    /** The port the server will listen to. */
+    private int serverPort = 1118;
+    
     /**
      * Constructor for the TestDiskCache object.
-     *
+     * <p>
      * @param testName
      */
     public LateralTCPIssueRemoveOnPutUnitTest( String testName )
@@ -51,12 +54,13 @@
      * Test setup
      */
     public void setUp()
-    {
+    {        
+        System.setProperty( "jcs.auxiliary.LTCP.attributes.TcpServers", "localhost:" + serverPort );
+        
         JCS.setConfigFilename( "/TestTCPLateralIssueRemoveCache.ccf" );
     }
 
     /**
-     *
      * @throws Exception
      */
     public void testPutLocalPutRemoteGetBusyVerifyRemoved()
@@ -66,13 +70,10 @@
     }
 
     /**
-     * Verify that a standard put works.
-     *
-     * Get the cache configured from a file. Create a tcp service to talk to
-     * that cache. Put via the servive. Verify that the cache got the data.
-     *
+     * Verify that a standard put works. Get the cache configured from a file. Create a tcp service
+     * to talk to that cache. Put via the servive. Verify that the cache got the data.
+     * <p>
      * @throws Exception
-     *
      */
     public void testStandardPut()
         throws Exception
@@ -86,7 +87,7 @@
         TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
         lattr2.setTcpListenerPort( 1102 );
         lattr2.setTransmissionTypeName( "TCP" );
-        lattr2.setTcpServer( "localhost:1110" );
+        lattr2.setTcpServer( "localhost:" + serverPort );
         lattr2.setIssueRemoveOnPut( false );
         // should still try to remove
         // lattr2.setAllowPut( false );
@@ -111,17 +112,14 @@
     }
 
     /**
-     * This tests issues tons of puts. It also check to see that a key that was
-     * put in was removed by the clients remove command.
-     *
-     * @param region
-     *            Name of the region to access
+     * This tests issues tons of puts. It also check to see that a key that was put in was removed
+     * by the clients remove command.
+     * <p>
+     * @param region Name of the region to access
      * @param range
      * @param numOps
      * @param testNum
-     *
-     * @exception Exception
-     *                If an error occurs
+     * @exception Exception If an error occurs
      */
     public void runTestForRegion( String region, int range, int numOps, int testNum )
         throws Exception
@@ -136,7 +134,7 @@
         TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
         lattr2.setTcpListenerPort( 1102 );
         lattr2.setTransmissionTypeName( "TCP" );
-        lattr2.setTcpServer( "localhost:1110" );
+        lattr2.setTcpServer( "localhost:" + serverPort );
         lattr2.setIssueRemoveOnPut( true );
         // should still try to remove
         lattr2.setAllowPut( false );
@@ -214,8 +212,7 @@
     }
 
     /**
-     * @param s
-     *            String to be printed
+     * @param s String to be printed
      */
     public static void p( String s )
     {
@@ -224,4 +221,4 @@
             System.out.println( s );
         }
     }
-}
+}
\ No newline at end of file

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientMockImpl.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientMockImpl.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientMockImpl.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheClientMockImpl.java Fri Apr 11 11:43:26 2008
@@ -1,250 +1,241 @@
-package org.apache.jcs.auxiliary.remote;
-
-/*
- * 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.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
-import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient;
-import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
-import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
-import org.apache.jcs.engine.CacheConstants;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.stats.behavior.IStats;
-
-/**
- * Used for testing the no wait.
- * <p>
- * @author Aaron Smuts
- */
-public class RemoteCacheClientMockImpl
-    implements IRemoteCacheClient
-{
-    private static final long serialVersionUID = 1L;
-
-    private final static Log log = LogFactory.getLog( RemoteCacheClientMockImpl.class );
-
-    /**
-     * List of ICacheElement objects passed into update.
-     */
-    public List updateList = new LinkedList();
-
-    /**
-     * List of key objects passed into remove.
-     */
-    public List removeList = new LinkedList();
-
-    /** status to return. */
-    public int status = CacheConstants.STATUS_ALIVE;
-
-    /** Can setup values to return from get. values must be ICacheElement */
-    public Map getSetupMap = new HashMap();
-
-    /**
-     * The last service passed to fixCache
-     */
-    public IRemoteCacheService fixed;
-
-    /**
-     * Attributes.
-     */
-    public RemoteCacheAttributes attributes = new RemoteCacheAttributes();
-
-    /**
-     * Stores the last argument as fixed.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#fixCache(org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService)
-     */
-    public void fixCache( IRemoteCacheService remote )
-    {
-        fixed = remote;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListenerId()
-     */
-    public long getListenerId()
-    {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListener()
-     */
-    public IRemoteCacheListener getListener()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /**
-     * Adds the argument to the updatedList.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
-     */
-    public void update( ICacheElement ce )
-        throws IOException
-    {
-        updateList.add( ce );
-    }
-
-    /**
-     * Looks in the getSetupMap for a value.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
-     */
-    public ICacheElement get( Serializable key )
-        throws IOException
-    {
-        log.info( "get [" + key + "]" );
-        return (ICacheElement) getSetupMap.get( key );
-    }
-
-    /**
-     * Adds the key to the remove list.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
-     */
-    public boolean remove( Serializable key )
-        throws IOException
-    {
-        removeList.add( key );
-        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;
-    }
-
-    /**
-     * Returns the status setup variable. (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
-     */
-    public int getStatus()
-    {
-        return status;
-    }
-
-    /*
-     * (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;
-    }
-
-    /**
-     * Returns the setup attributes. By default they are not null.
-     * <p>
-     * (non-Javadoc)
-     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getAuxiliaryCacheAttributes()
-     */
-    public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
-    {
-        return attributes;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.jcs.engine.behavior.ICache#getStats()
-     */
-    public String getStats()
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
-
-    /*
-     * (non-Javadoc)
-     * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
-     */
-    public int getCacheType()
-    {
-        // TODO Auto-generated method stub
-        return 0;
-    }
-
-}
+package org.apache.jcs.auxiliary.remote;
+
+/*
+ * 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.Serializable;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jcs.auxiliary.AuxiliaryCacheAttributes;
+import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient;
+import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
+import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService;
+import org.apache.jcs.engine.CacheConstants;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.stats.behavior.IStats;
+
+/**
+ * Used for testing the no wait.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class RemoteCacheClientMockImpl
+    implements IRemoteCacheClient
+{
+    /** For serialization. Don't change. */
+    private static final long serialVersionUID = 1L;
+
+    /** log instance */
+    private final static Log log = LogFactory.getLog( RemoteCacheClientMockImpl.class );
+
+    /** List of ICacheElement objects passed into update. */
+    public List updateList = new LinkedList();
+
+    /** List of key objects passed into remove. */
+    public List removeList = new LinkedList();
+
+    /** status to return. */
+    public int status = CacheConstants.STATUS_ALIVE;
+
+    /** Can setup values to return from get. values must be ICacheElement */
+    public Map getSetupMap = new HashMap();
+
+    /** Can setup values to return from get. values must be Map<Serializable, ICacheElement> */
+    public Map getMultipleSetupMap = new HashMap();
+
+    /** The last service passed to fixCache */
+    public IRemoteCacheService fixed;
+
+    /** Attributes. */
+    public RemoteCacheAttributes attributes = new RemoteCacheAttributes();
+
+    /**
+     * Stores the last argument as fixed.
+     * <p>
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#fixCache(org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheService)
+     */
+    public void fixCache( IRemoteCacheService remote )
+    {
+        fixed = remote;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListenerId()
+     */
+    public long getListenerId()
+    {
+        return 0;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#getListener()
+     */
+    public IRemoteCacheListener getListener()
+    {
+        return null;
+    }
+
+    /**
+     * Adds the argument to the updatedList.
+     * <p>
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#update(org.apache.jcs.engine.behavior.ICacheElement)
+     */
+    public void update( ICacheElement ce )
+    {
+        updateList.add( ce );
+    }
+
+    /**
+     * Looks in the getSetupMap for a value.
+     * <p>
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#get(java.io.Serializable)
+     */
+    public ICacheElement get( Serializable key )
+    {
+        log.info( "get [" + key + "]" );
+        return (ICacheElement) getSetupMap.get( key );
+    }
+
+    /**
+     * Gets multiple items from the cache based on the given set of keys.
+     * <p>
+     * @param keys
+     * @return a map of Serializable key to ICacheElement element, or an empty map if there is no data in cache for any of these keys
+     */
+    public Map getMultiple( Set keys )
+    {
+        log.info( "get [" + keys + "]" );
+        return (Map) getMultipleSetupMap.get( keys );
+    }
+
+    /**
+     * Adds the key to the remove list.
+     * <p>
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#remove(java.io.Serializable)
+     */
+    public boolean remove( Serializable key )
+    {
+        removeList.add( key );
+        return false;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#removeAll()
+     */
+    public void removeAll()
+    {
+        // do nothing
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#dispose()
+     */
+    public void dispose()
+    {
+        // do nothing
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getSize()
+     */
+    public int getSize()
+    {
+        return 0;
+    }
+
+    /**
+     * Returns the status setup variable. (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatus()
+     */
+    public int getStatus()
+    {
+        return status;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getCacheName()
+     */
+    public String getCacheName()
+    {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getGroupKeys(java.lang.String)
+     */
+    public Set getGroupKeys( String group )
+    {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
+     */
+    public IStats getStatistics()
+    {
+        return null;
+    }
+
+    /**
+     * Returns the setup attributes. By default they are not null.
+     * <p>
+     * (non-Javadoc)
+     * @see org.apache.jcs.auxiliary.AuxiliaryCache#getAuxiliaryCacheAttributes()
+     */
+    public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes()
+    {
+        return attributes;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.engine.behavior.ICache#getStats()
+     */
+    public String getStats()
+    {
+        return null;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
+     */
+    public int getCacheType()
+    {
+        return 0;
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java?rev=647264&r1=647263&r2=647264&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java (original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java Fri Apr 11 11:43:26 2008
@@ -1,182 +1,215 @@
-package org.apache.jcs.auxiliary.remote;
-
-/*
- * 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.engine.CacheConstants;
-import org.apache.jcs.engine.CacheElement;
-import org.apache.jcs.engine.behavior.ICacheElement;
-import org.apache.jcs.engine.behavior.ICacheEventQueue;
-import org.apache.jcs.utils.timing.SleepUtil;
-
-/**
- * Unit tests for the remote cache no wait. The no wait manages a queue on top of the client.
- * <p>
- * @author Aaron Smuts
- */
-public class RemoteCacheNoWaitUnitTest
-    extends TestCase
-{
-    /**
-     * Simply verify that the client gets updated via the no wait.
-     * <p>
-     * @throws Exception
-     */
-    public void testUpdate()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        ICacheElement element = new CacheElement( "testUpdate", "key", "value" );
-
-        // DO WORK
-        noWait.update( element );
-
-        SleepUtil.sleepAtLeast( 10 );
-
-        // VERIFY
-        assertEquals( "Wrong number updated.", 1, client.updateList.size() );
-        assertEquals( "Wrong element", element, client.updateList.get( 0 ) );
-    }
-
-    /**
-     * Simply verify that the client get is called from the no wait.
-     * <p>
-     * @throws Exception
-     */
-    public void testGet()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        ICacheElement input = new CacheElement( "testUpdate", "key", "value" );
-        client.getSetupMap.put( "key", input );
-
-        // DO WORK
-        ICacheElement result = noWait.get( "key" );
-
-        // VERIFY
-        assertEquals( "Wrong element", input, result );
-    }
-
-    /**
-     * Simply verify that the client gets updated via the no wait.
-     * <p>
-     * @throws Exception
-     */
-    public void testRemove()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        String input = "MyKey";
-
-        // DO WORK
-        noWait.remove( input );
-
-        SleepUtil.sleepAtLeast( 10 );
-
-        // VERIFY
-        assertEquals( "Wrong number updated.", 1, client.removeList.size() );
-        assertEquals( "Wrong key", input, client.removeList.get( 0 ) );
-    }
-
-    /**
-     * Simply verify that the client status is returned in the stats.
-     * <p>
-     * @throws Exception
-     */
-    public void testGetStats()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        client.status = CacheConstants.STATUS_ALIVE;
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        // DO WORK
-        String result = noWait.getStats();
-
-        // VERIFY
-        assertTrue( "Status should contain 'ALIVE'", result.indexOf( "ALIVE" ) != -1 );
-    }
-
-    /**
-     * Simply verify that we get a status of error if the cache is in error..
-     * <p>
-     * @throws Exception
-     */
-    public void testGetStatus_error()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        client.status = CacheConstants.STATUS_ERROR;
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        // DO WORK
-        int result = noWait.getStatus();
-
-        // VERIFY
-        assertEquals( "Wrong status", CacheConstants.STATUS_ERROR, result );
-    }
-
-    /**
-     * Simply verify that the serviced supplied to fix is passed onto the client. Verify that the
-     * original event queue is destroyed. A new event queue willbe plugged in on fix.
-     * <p>
-     * @throws Exception
-     */
-    public void testFixCache()
-        throws Exception
-    {
-        // SETUP
-        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
-        client.status = CacheConstants.STATUS_ALIVE;
-        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
-
-        RemoteCacheServiceMockImpl service = new RemoteCacheServiceMockImpl();
-
-        ICacheElement element = new CacheElement( "testUpdate", "key", "value" );
-
-        // DO WORK
-        noWait.update( element );
-        SleepUtil.sleepAtLeast( 10 );
-        ICacheEventQueue originalQueue = noWait.getCacheEventQueue();
-
-        noWait.fixCache( service );
-
-        noWait.update( element );
-        SleepUtil.sleepAtLeast( 10 );
-        ICacheEventQueue newQueue = noWait.getCacheEventQueue();
-
-        // VERIFY
-        assertEquals( "Wrong status", service, client.fixed );
-        assertFalse( "Original queue should not alive", originalQueue.isAlive() );
-        assertTrue( "New queue should be alive." + newQueue, newQueue.isAlive() );
-    }
-}
+package org.apache.jcs.auxiliary.remote;
+
+/*
+ * 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.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.engine.CacheConstants;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheEventQueue;
+import org.apache.jcs.utils.timing.SleepUtil;
+
+/**
+ * Unit tests for the remote cache no wait. The no wait manages a queue on top of the client.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class RemoteCacheNoWaitUnitTest
+    extends TestCase
+{
+    /**
+     * Simply verify that the client gets updated via the no wait.
+     * <p>
+     * @throws Exception
+     */
+    public void testUpdate()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        ICacheElement element = new CacheElement( "testUpdate", "key", "value" );
+
+        // DO WORK
+        noWait.update( element );
+
+        SleepUtil.sleepAtLeast( 10 );
+
+        // VERIFY
+        assertEquals( "Wrong number updated.", 1, client.updateList.size() );
+        assertEquals( "Wrong element", element, client.updateList.get( 0 ) );
+    }
+
+    /**
+     * Simply verify that the client get is called from the no wait.
+     * <p>
+     * @throws Exception
+     */
+    public void testGet()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        ICacheElement input = new CacheElement( "testUpdate", "key", "value" );
+        client.getSetupMap.put( "key", input );
+
+        // DO WORK
+        ICacheElement result = noWait.get( "key" );
+
+        // VERIFY
+        assertEquals( "Wrong element", input, result );
+    }
+
+    /**
+     * Simply verify that the client getMultiple is called from the no wait.
+     * <p>
+     * @throws Exception
+     */
+    public void testGetMultiple()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        ICacheElement inputElement = new CacheElement( "testUpdate", "key", "value" );
+        Map inputMap = new HashMap();
+        inputMap.put( "key", inputElement );
+
+        Set keys = new HashSet();
+        keys.add( "key" );
+
+        client.getMultipleSetupMap.put( keys, inputMap );
+
+        // DO WORK
+        Map result = noWait.getMultiple( keys );
+
+        // VERIFY
+        assertEquals( "elements map", inputMap, result );
+    }
+
+    /**
+     * Simply verify that the client gets updated via the no wait.
+     * <p>
+     * @throws Exception
+     */
+    public void testRemove()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        String input = "MyKey";
+
+        // DO WORK
+        noWait.remove( input );
+
+        SleepUtil.sleepAtLeast( 10 );
+
+        // VERIFY
+        assertEquals( "Wrong number updated.", 1, client.removeList.size() );
+        assertEquals( "Wrong key", input, client.removeList.get( 0 ) );
+    }
+
+    /**
+     * Simply verify that the client status is returned in the stats.
+     * <p>
+     * @throws Exception
+     */
+    public void testGetStats()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        client.status = CacheConstants.STATUS_ALIVE;
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        // DO WORK
+        String result = noWait.getStats();
+
+        // VERIFY
+        assertTrue( "Status should contain 'ALIVE'", result.indexOf( "ALIVE" ) != -1 );
+    }
+
+    /**
+     * Simply verify that we get a status of error if the cache is in error..
+     * <p>
+     * @throws Exception
+     */
+    public void testGetStatus_error()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        client.status = CacheConstants.STATUS_ERROR;
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        // DO WORK
+        int result = noWait.getStatus();
+
+        // VERIFY
+        assertEquals( "Wrong status", CacheConstants.STATUS_ERROR, result );
+    }
+
+    /**
+     * Simply verify that the serviced supplied to fix is passed onto the client. Verify that the
+     * original event queue is destroyed. A new event queue willbe plugged in on fix.
+     * <p>
+     * @throws Exception
+     */
+    public void testFixCache()
+        throws Exception
+    {
+        // SETUP
+        RemoteCacheClientMockImpl client = new RemoteCacheClientMockImpl();
+        client.status = CacheConstants.STATUS_ALIVE;
+        RemoteCacheNoWait noWait = new RemoteCacheNoWait( client );
+
+        RemoteCacheServiceMockImpl service = new RemoteCacheServiceMockImpl();
+
+        ICacheElement element = new CacheElement( "testUpdate", "key", "value" );
+
+        // DO WORK
+        noWait.update( element );
+        SleepUtil.sleepAtLeast( 10 );
+        ICacheEventQueue originalQueue = noWait.getCacheEventQueue();
+
+        noWait.fixCache( service );
+
+        noWait.update( element );
+        SleepUtil.sleepAtLeast( 10 );
+        ICacheEventQueue newQueue = noWait.getCacheEventQueue();
+
+        // VERIFY
+        assertEquals( "Wrong status", service, client.fixed );
+        assertFalse( "Original queue should not alive", originalQueue.isAlive() );
+        assertTrue( "New queue should be alive." + newQueue, newQueue.isAlive() );
+    }
+}



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