commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1570993 [13/24] - in /commons/proper/jcs/trunk/src: assembly/ changes/ conf/ java/org/apache/commons/jcs/access/ java/org/apache/commons/jcs/access/exception/ java/org/apache/commons/jcs/admin/ java/org/apache/commons/jcs/auxiliary/ java/o...
Date Sun, 23 Feb 2014 10:37:52 GMT
Modified: commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/zip/CompressionUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/zip/CompressionUtil.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/zip/CompressionUtil.java (original)
+++ commons/proper/jcs/trunk/src/java/org/apache/commons/jcs/utils/zip/CompressionUtil.java Sun Feb 23 10:37:48 2014
@@ -1,199 +1,199 @@
-package org.apache.commons.jcs.utils.zip;
-
-/*
- * 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.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.zip.DataFormatException;
-import java.util.zip.Deflater;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.Inflater;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/** Compress / Decompress. */
-public final class CompressionUtil
-{
-    /** The logger */
-    private final static Log log = LogFactory.getLog( CompressionUtil.class );
-
-    /**
-     * no instances.
-     */
-    private CompressionUtil()
-    {
-        // NO OP
-    }
-
-    /**
-     * Decompress the byte array passed using a default buffer length of 1024.
-     * <p>
-     * @param input compressed byte array webservice response
-     * @return uncompressed byte array
-     */
-    public static byte[] decompressByteArray( final byte[] input )
-    {
-        return decompressByteArray( input, 1024 );
-    }
-
-    /**
-     * Decompress the byte array passed
-     * <p>
-     * @param input compressed byte array webservice response
-     * @param bufferLength buffer length
-     * @return uncompressed byte array
-     */
-    public static byte[] decompressByteArray( final byte[] input, final int bufferLength )
-    {
-        if ( null == input )
-        {
-            throw new IllegalArgumentException( "Input was null" );
-        }
-
-        // Create the decompressor and give it the data to compress
-        final Inflater decompressor = new Inflater();
-
-        decompressor.setInput( input );
-
-        // Create an expandable byte array to hold the decompressed data
-        final ByteArrayOutputStream baos = new ByteArrayOutputStream( input.length );
-
-        // Decompress the data
-        final byte[] buf = new byte[bufferLength];
-
-        try
-        {
-            while ( !decompressor.finished() )
-            {
-                int count = decompressor.inflate( buf );
-                baos.write( buf, 0, count );
-            }
-        }
-        catch ( DataFormatException ex )
-        {
-            log.error( "Problem decompressing.", ex );
-        }
-
-        try
-        {
-            baos.close();
-        }
-        catch ( IOException ex )
-        {
-            log.error( "Problem closing stream.", ex );
-        }
-
-        return baos.toByteArray();
-    }
-
-    /**
-     * Compress the byte array passed
-     * <p>
-     * @param input byte array
-     * @return compressed byte array
-     * @exception IOException thrown if we can't close the output stream
-     */
-    public static byte[] compressByteArray( byte[] input )
-        throws IOException
-    {
-        return compressByteArray( input, 1024 );
-    }
-
-    /**
-     * Compress the byte array passed
-     * <p>
-     * @param input byte array
-     * @param bufferLength buffer length
-     * @return compressed byte array
-     * @exception IOException thrown if we can't close the output stream
-     */
-    public static byte[] compressByteArray( byte[] input, int bufferLength )
-        throws IOException
-    {
-        // Compressor with highest level of compression
-        Deflater compressor = new Deflater();
-        compressor.setLevel( Deflater.BEST_COMPRESSION );
-
-        // Give the compressor the data to compress
-        compressor.setInput( input );
-        compressor.finish();
-
-        // Create an expandable byte array to hold the compressed data.
-        // It is not necessary that the compressed data will be smaller than
-        // the uncompressed data.
-        ByteArrayOutputStream bos = new ByteArrayOutputStream( input.length );
-
-        // Compress the data
-        byte[] buf = new byte[bufferLength];
-        while ( !compressor.finished() )
-        {
-            int count = compressor.deflate( buf );
-            bos.write( buf, 0, count );
-        }
-
-        bos.close();
-
-        // Get the compressed data
-        return bos.toByteArray();
-
-    }
-
-    /**
-     * decompress a gzip byte array, using a default buffer length of 1024
-     * <p>
-     * @param compressedByteArray gzip-compressed byte array
-     * @return decompressed byte array
-     * @throws IOException thrown if there was a failure to construct the GzipInputStream
-     */
-    public static byte[] decompressGzipByteArray( byte[] compressedByteArray )
-        throws IOException
-    {
-        return decompressGzipByteArray( compressedByteArray, 1024 );
-    }
-
-    /**
-     * decompress a gzip byte array, using a default buffer length of 1024
-     * <p>
-     * @param compressedByteArray gzip-compressed byte array
-     * @param bufferlength size of the buffer in bytes
-     * @return decompressed byte array
-     * @throws IOException thrown if there was a failure to construct the GzipInputStream
-     */
-    public static byte[] decompressGzipByteArray( byte[] compressedByteArray, int bufferlength )
-        throws IOException
-    {
-        ByteArrayOutputStream uncompressedStream = new ByteArrayOutputStream();
-
-        GZIPInputStream compressedStream = new GZIPInputStream( new ByteArrayInputStream( compressedByteArray ) );
-
-        byte[] buffer = new byte[bufferlength];
-
-        int index = -1;
-
-        while ( ( index = compressedStream.read( buffer ) ) != -1 )
-        {
-            uncompressedStream.write( buffer, 0, index );
-        }
-
-        return uncompressedStream.toByteArray();
-    }
-}
+package org.apache.commons.jcs.utils.zip;
+
+/*
+ * 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.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.zip.DataFormatException;
+import java.util.zip.Deflater;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.Inflater;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/** Compress / Decompress. */
+public final class CompressionUtil
+{
+    /** The logger */
+    private final static Log log = LogFactory.getLog( CompressionUtil.class );
+
+    /**
+     * no instances.
+     */
+    private CompressionUtil()
+    {
+        // NO OP
+    }
+
+    /**
+     * Decompress the byte array passed using a default buffer length of 1024.
+     * <p>
+     * @param input compressed byte array webservice response
+     * @return uncompressed byte array
+     */
+    public static byte[] decompressByteArray( final byte[] input )
+    {
+        return decompressByteArray( input, 1024 );
+    }
+
+    /**
+     * Decompress the byte array passed
+     * <p>
+     * @param input compressed byte array webservice response
+     * @param bufferLength buffer length
+     * @return uncompressed byte array
+     */
+    public static byte[] decompressByteArray( final byte[] input, final int bufferLength )
+    {
+        if ( null == input )
+        {
+            throw new IllegalArgumentException( "Input was null" );
+        }
+
+        // Create the decompressor and give it the data to compress
+        final Inflater decompressor = new Inflater();
+
+        decompressor.setInput( input );
+
+        // Create an expandable byte array to hold the decompressed data
+        final ByteArrayOutputStream baos = new ByteArrayOutputStream( input.length );
+
+        // Decompress the data
+        final byte[] buf = new byte[bufferLength];
+
+        try
+        {
+            while ( !decompressor.finished() )
+            {
+                int count = decompressor.inflate( buf );
+                baos.write( buf, 0, count );
+            }
+        }
+        catch ( DataFormatException ex )
+        {
+            log.error( "Problem decompressing.", ex );
+        }
+
+        try
+        {
+            baos.close();
+        }
+        catch ( IOException ex )
+        {
+            log.error( "Problem closing stream.", ex );
+        }
+
+        return baos.toByteArray();
+    }
+
+    /**
+     * Compress the byte array passed
+     * <p>
+     * @param input byte array
+     * @return compressed byte array
+     * @exception IOException thrown if we can't close the output stream
+     */
+    public static byte[] compressByteArray( byte[] input )
+        throws IOException
+    {
+        return compressByteArray( input, 1024 );
+    }
+
+    /**
+     * Compress the byte array passed
+     * <p>
+     * @param input byte array
+     * @param bufferLength buffer length
+     * @return compressed byte array
+     * @exception IOException thrown if we can't close the output stream
+     */
+    public static byte[] compressByteArray( byte[] input, int bufferLength )
+        throws IOException
+    {
+        // Compressor with highest level of compression
+        Deflater compressor = new Deflater();
+        compressor.setLevel( Deflater.BEST_COMPRESSION );
+
+        // Give the compressor the data to compress
+        compressor.setInput( input );
+        compressor.finish();
+
+        // Create an expandable byte array to hold the compressed data.
+        // It is not necessary that the compressed data will be smaller than
+        // the uncompressed data.
+        ByteArrayOutputStream bos = new ByteArrayOutputStream( input.length );
+
+        // Compress the data
+        byte[] buf = new byte[bufferLength];
+        while ( !compressor.finished() )
+        {
+            int count = compressor.deflate( buf );
+            bos.write( buf, 0, count );
+        }
+
+        bos.close();
+
+        // Get the compressed data
+        return bos.toByteArray();
+
+    }
+
+    /**
+     * decompress a gzip byte array, using a default buffer length of 1024
+     * <p>
+     * @param compressedByteArray gzip-compressed byte array
+     * @return decompressed byte array
+     * @throws IOException thrown if there was a failure to construct the GzipInputStream
+     */
+    public static byte[] decompressGzipByteArray( byte[] compressedByteArray )
+        throws IOException
+    {
+        return decompressGzipByteArray( compressedByteArray, 1024 );
+    }
+
+    /**
+     * decompress a gzip byte array, using a default buffer length of 1024
+     * <p>
+     * @param compressedByteArray gzip-compressed byte array
+     * @param bufferlength size of the buffer in bytes
+     * @return decompressed byte array
+     * @throws IOException thrown if there was a failure to construct the GzipInputStream
+     */
+    public static byte[] decompressGzipByteArray( byte[] compressedByteArray, int bufferlength )
+        throws IOException
+    {
+        ByteArrayOutputStream uncompressedStream = new ByteArrayOutputStream();
+
+        GZIPInputStream compressedStream = new GZIPInputStream( new ByteArrayInputStream( compressedByteArray ) );
+
+        byte[] buffer = new byte[bufferlength];
+
+        int index = -1;
+
+        while ( ( index = compressedStream.read( buffer ) ) != -1 )
+        {
+            uncompressedStream.write( buffer, 0, index );
+        }
+
+        return uncompressedStream.toByteArray();
+    }
+}

Modified: commons/proper/jcs/trunk/src/site/site.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/site/site.xml?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/site/site.xml (original)
+++ commons/proper/jcs/trunk/src/site/site.xml Sun Feb 23 10:37:48 2014
@@ -72,4 +72,4 @@
 
     </body>
 
-</project>
\ No newline at end of file
+</project>

Modified: commons/proper/jcs/trunk/src/test-conf/TestJCS-73.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test-conf/TestJCS-73.ccf?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test-conf/TestJCS-73.ccf (original)
+++ commons/proper/jcs/trunk/src/test-conf/TestJCS-73.ccf Sun Feb 23 10:37:48 2014
@@ -1,42 +1,42 @@
-# 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.
-# Cache configuration for the 'JCSConcurrentCacheAccessUnitTest' test.
-
-jcs.default=CACHE
-jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
-jcs.default.cacheattributes.MaxObjects=-1
-jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
-jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
-jcs.default.cacheattributes.UseMemoryShrinker=true
-jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10
-jcs.default.cacheattributes.ShrinkerIntervalSeconds=10
-jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
-jcs.default.elementattributes.IsRemote=false
-jcs.default.elementattributes.IsLateral=false
-jcs.default.elementattributes.IsSpool=true
-jcs.default.elementattributes.IsEternal=true
-
-jcs.auxiliary.CACHE=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
-jcs.auxiliary.CACHE.attributes=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
-jcs.auxiliary.CACHE.attributes.DiskPath=target/test-sandbox/concurrent_cache
-jcs.auxiliary.CACHE.attributes.MaxPurgatorySize=-1
-jcs.auxiliary.CACHE.attributes.MaxKeySize=-1
-jcs.auxiliary.CACHE.attributes.MaxRecycleBinSize=500
-jcs.auxiliary.CACHE.attributes.ShutdownSpoolTimeLimit=60
-jcs.auxiliary.CACHE.attributes.OptimizeAtRemoveCount=30000
-jcs.auxiliary.CACHE.attributes.OptimizeOnShutdown=true
-jcs.auxiliary.CACHE.attributes.EventQueueType=SINGLE
+# 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.
+# Cache configuration for the 'JCSConcurrentCacheAccessUnitTest' test.
+
+jcs.default=CACHE
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=-1
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache
+jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
+jcs.default.cacheattributes.UseMemoryShrinker=true
+jcs.default.cacheattributes.MaxMemoryIdleTimeSeconds=10
+jcs.default.cacheattributes.ShrinkerIntervalSeconds=10
+jcs.default.elementattributes=org.apache.commons.jcs.engine.ElementAttributes
+jcs.default.elementattributes.IsRemote=false
+jcs.default.elementattributes.IsLateral=false
+jcs.default.elementattributes.IsSpool=true
+jcs.default.elementattributes.IsEternal=true
+
+jcs.auxiliary.CACHE=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
+jcs.auxiliary.CACHE.attributes=org.apache.commons.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
+jcs.auxiliary.CACHE.attributes.DiskPath=target/test-sandbox/concurrent_cache
+jcs.auxiliary.CACHE.attributes.MaxPurgatorySize=-1
+jcs.auxiliary.CACHE.attributes.MaxKeySize=-1
+jcs.auxiliary.CACHE.attributes.MaxRecycleBinSize=500
+jcs.auxiliary.CACHE.attributes.ShutdownSpoolTimeLimit=60
+jcs.auxiliary.CACHE.attributes.OptimizeAtRemoveCount=30000
+jcs.auxiliary.CACHE.attributes.OptimizeOnShutdown=true
+jcs.auxiliary.CACHE.attributes.EventQueueType=SINGLE

Modified: commons/proper/jcs/trunk/src/test-conf/TestLHMLRUCache.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test-conf/TestLHMLRUCache.ccf?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test-conf/TestLHMLRUCache.ccf (original)
+++ commons/proper/jcs/trunk/src/test-conf/TestLHMLRUCache.ccf Sun Feb 23 10:37:48 2014
@@ -1,23 +1,23 @@
-# 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.
-# Cache configuration for the 'TestDiskCache' test. The memory cache has a
-# a maximum of 100 objects, so objects should get pushed into the disk cache
-
-jcs.default=
-jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
-jcs.default.cacheattributes.MaxObjects=100
-jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LHMLRUMemoryCache
\ No newline at end of file
+# 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.
+# Cache configuration for the 'TestDiskCache' test. The memory cache has a
+# a maximum of 100 objects, so objects should get pushed into the disk cache
+
+jcs.default=
+jcs.default.cacheattributes=org.apache.commons.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=100
+jcs.default.cacheattributes.MemoryCacheName=org.apache.commons.jcs.engine.memory.lru.LHMLRUMemoryCache

Modified: commons/proper/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf (original)
+++ commons/proper/jcs/trunk/src/test-conf/TestRemoteCacheEventLogging.ccf Sun Feb 23 10:37:48 2014
@@ -44,4 +44,4 @@ jcs.auxiliary.RC.attributes.RemoveUponRe
 jcs.auxiliary.RC.attributes.GetTimeoutMillis=-1
 # jcs.auxiliary.RC.attributes.ThreadPoolName=remote_cache_client
 # jcs.auxiliary.RC.attributes.GetOnly=false
-jcs.auxiliary.RC.cacheeventlogger=org.apache.commons.jcs.engine.logging.MockCacheEventLogger
\ No newline at end of file
+jcs.auxiliary.RC.cacheeventlogger=org.apache.commons.jcs.engine.logging.MockCacheEventLogger

Modified: commons/proper/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf (original)
+++ commons/proper/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf Sun Feb 23 10:37:48 2014
@@ -40,4 +40,4 @@ jcs.auxiliary.LTCP.attributes.TcpServers
 jcs.auxiliary.LTCP.attributes.TcpListenerPort=2001
 jcs.auxiliary.LTCP.attributes.AllowGet=false
 jcs.auxiliary.LTCP.attributes.IssueRemoveOnPut=true
-jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=true
\ No newline at end of file
+jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=true

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/ConcurrentRemovalLoadTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/ConcurrentRemovalLoadTest.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/ConcurrentRemovalLoadTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/ConcurrentRemovalLoadTest.java Sun Feb 23 10:37:48 2014
@@ -117,7 +117,7 @@ public class ConcurrentRemovalLoadTest
                 runTestPutThenRemoveCategorical( 701, 800 );
             }
         } );
-        
+
         suite.addTest( new RemovalTestUtil( "testRemoveCache1" )
         {
             @Override

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java Sun Feb 23 10:37:48 2014
@@ -1,165 +1,165 @@
-package org.apache.commons.jcs;
-
-/*
- * 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.concurrent.atomic.AtomicInteger;
-
-import junit.framework.Assert;
-import junit.framework.TestCase;
-
-import org.apache.commons.jcs.access.GroupCacheAccess;
-import org.apache.commons.jcs.access.exception.CacheException;
-
-/**
- * Test Case for JCS-73, modeled after the Groovy code by Alexander Kleymenov
- *
- * @author Thomas Vandahl
- *
- */
-public class JCSConcurrentCacheAccessUnitTest
-    extends TestCase
-{
-    /**
-     * the cache instance
-     */
-    protected GroupCacheAccess<Integer, String> cache;
-
-    /**
-     * the group name
-     */
-    protected String group = "group";
-
-    /**
-     * the error count
-     */
-    protected AtomicInteger errcount;
-
-    @Override
-	protected void setUp() throws Exception
-	{
-        super.setUp();
-        JCS.setConfigFilename( "/TestJCS-73.ccf" );
-        cache = JCS.getGroupCacheInstance( "cache" );
-        errcount = new AtomicInteger(0);
-	}
-
-    @Override
-    protected void tearDown()
-        throws Exception
-    {
-        super.tearDown();
-        cache.clear();
-        cache.dispose();
-    }
-
-    /**
-     * Worker thread
-     */
-    protected class Worker extends Thread
-    {
-    	@Override
-		public void run()
-		{
-			String name = getName();
-
-			for (int idx = 0; idx < 10000; idx++)
-			{
-				if (idx > 0)
-				{
-					// get previously stored value
-		            String res = cache.getFromGroup(Integer.valueOf(idx-1), group);
-
-		            if (res == null)
-		            {
-		                // null value got inspite of the fact it was placed in cache!
-		                System.out.println("ERROR: for " + idx + " in " + name);
-		                errcount.incrementAndGet();
-
-		                // try to get the value again:
-		                int n = 5;
-		                while (n-- > 0)
-		                {
-		                    res = cache.getFromGroup(Integer.valueOf(idx-1), group);
-		                    if (res != null)
-		                    {
-		                        // the value finally appeared in cache
-		                    	System.out.println("ERROR FIXED for " + idx + ": " + res + " " + name);
-		                    	errcount.decrementAndGet();
-		                        break;
-		                    }
-
-		                    System.out.println("ERROR STILL PERSISTS for " + idx + " in " + name);
-		                    try
-		                    {
-								Thread.sleep(1000);
-							}
-		                    catch (InterruptedException e)
-							{
-								// continue
-							}
-		                }
-		            }
-
-		            Assert.assertEquals("Values do not match", String.valueOf(idx-1), res);
-				}
-
-				 // put value in the cache
-		        try
-		        {
-					cache.putInGroup(Integer.valueOf(idx), group, String.valueOf(idx));
-				}
-		        catch (CacheException e)
-		        {
-		        	// continue
-				}
-
-		        if ((idx % 1000) == 0)
-		        {
-		        	System.out.println(name + " " + idx);
-		        }
-			}
-
-		}
-    }
-
-	/**
-     *
-     * @throws Exception
-     */
-    public void testConcurrentAccess()
-        throws Exception
-    {
-    	Worker[] worker = new Worker[10];
-
-        for (int i = 0; i < 10; i++)
-        {
-        	worker[i] = new Worker();
-        	worker[i].start();
-        }
-
-        for (int i = 0; i < 10; i++)
-        {
-        	worker[i].join();
-        }
-
-        assertEquals("Error count should be 0",  0, errcount.intValue());
-    }
-
-}
+package org.apache.commons.jcs;
+
+/*
+ * 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.concurrent.atomic.AtomicInteger;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.apache.commons.jcs.access.GroupCacheAccess;
+import org.apache.commons.jcs.access.exception.CacheException;
+
+/**
+ * Test Case for JCS-73, modeled after the Groovy code by Alexander Kleymenov
+ *
+ * @author Thomas Vandahl
+ *
+ */
+public class JCSConcurrentCacheAccessUnitTest
+    extends TestCase
+{
+    /**
+     * the cache instance
+     */
+    protected GroupCacheAccess<Integer, String> cache;
+
+    /**
+     * the group name
+     */
+    protected String group = "group";
+
+    /**
+     * the error count
+     */
+    protected AtomicInteger errcount;
+
+    @Override
+	protected void setUp() throws Exception
+	{
+        super.setUp();
+        JCS.setConfigFilename( "/TestJCS-73.ccf" );
+        cache = JCS.getGroupCacheInstance( "cache" );
+        errcount = new AtomicInteger(0);
+	}
+
+    @Override
+    protected void tearDown()
+        throws Exception
+    {
+        super.tearDown();
+        cache.clear();
+        cache.dispose();
+    }
+
+    /**
+     * Worker thread
+     */
+    protected class Worker extends Thread
+    {
+    	@Override
+		public void run()
+		{
+			String name = getName();
+
+			for (int idx = 0; idx < 10000; idx++)
+			{
+				if (idx > 0)
+				{
+					// get previously stored value
+		            String res = cache.getFromGroup(Integer.valueOf(idx-1), group);
+
+		            if (res == null)
+		            {
+		                // null value got inspite of the fact it was placed in cache!
+		                System.out.println("ERROR: for " + idx + " in " + name);
+		                errcount.incrementAndGet();
+
+		                // try to get the value again:
+		                int n = 5;
+		                while (n-- > 0)
+		                {
+		                    res = cache.getFromGroup(Integer.valueOf(idx-1), group);
+		                    if (res != null)
+		                    {
+		                        // the value finally appeared in cache
+		                    	System.out.println("ERROR FIXED for " + idx + ": " + res + " " + name);
+		                    	errcount.decrementAndGet();
+		                        break;
+		                    }
+
+		                    System.out.println("ERROR STILL PERSISTS for " + idx + " in " + name);
+		                    try
+		                    {
+								Thread.sleep(1000);
+							}
+		                    catch (InterruptedException e)
+							{
+								// continue
+							}
+		                }
+		            }
+
+		            Assert.assertEquals("Values do not match", String.valueOf(idx-1), res);
+				}
+
+				 // put value in the cache
+		        try
+		        {
+					cache.putInGroup(Integer.valueOf(idx), group, String.valueOf(idx));
+				}
+		        catch (CacheException e)
+		        {
+		        	// continue
+				}
+
+		        if ((idx % 1000) == 0)
+		        {
+		        	System.out.println(name + " " + idx);
+		        }
+			}
+
+		}
+    }
+
+	/**
+     *
+     * @throws Exception
+     */
+    public void testConcurrentAccess()
+        throws Exception
+    {
+    	Worker[] worker = new Worker[10];
+
+        for (int i = 0; i < 10; i++)
+        {
+        	worker[i] = new Worker();
+        	worker[i].start();
+        }
+
+        for (int i = 0; i < 10; i++)
+        {
+        	worker[i].join();
+        }
+
+        assertEquals("Error count should be 0",  0, errcount.intValue());
+    }
+
+}

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/TestLogConfigurationUtil.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/TestLogConfigurationUtil.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/TestLogConfigurationUtil.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/TestLogConfigurationUtil.java Sun Feb 23 10:37:48 2014
@@ -1,27 +1,46 @@
-package org.apache.commons.jcs;
-
-import java.io.StringWriter;
-
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PatternLayout;
-import org.apache.log4j.WriterAppender;
-
-/** Utility for testing log messages. */
-public class TestLogConfigurationUtil
-{
-    /**
-     * Configures a logger for the given name. This allows us to check the log output.
-     * <p>
-     * @param stringWriter string writer
-     * @param loggerName logger name
-     */
-    public static void configureLogger( StringWriter stringWriter, String loggerName )
-    {
-        Logger logger = Logger.getLogger( loggerName );
-        WriterAppender appender = new WriterAppender( new PatternLayout(), stringWriter );
-
-        logger.addAppender( appender );
-        logger.setLevel( Level.DEBUG );
-    }  
-}
+package org.apache.commons.jcs;
+
+/*
+ * 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.StringWriter;
+
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.WriterAppender;
+
+/** Utility for testing log messages. */
+public class TestLogConfigurationUtil
+{
+    /**
+     * Configures a logger for the given name. This allows us to check the log output.
+     * <p>
+     * @param stringWriter string writer
+     * @param loggerName logger name
+     */
+    public static void configureLogger( StringWriter stringWriter, String loggerName )
+    {
+        Logger logger = Logger.getLogger( loggerName );
+        WriterAppender appender = new WriterAppender( new PatternLayout(), stringWriter );
+
+        logger.addAppender( appender );
+        logger.setLevel( Level.DEBUG );
+    }
+}

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/CacheAccessUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/CacheAccessUnitTest.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/CacheAccessUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/access/CacheAccessUnitTest.java Sun Feb 23 10:37:48 2014
@@ -1,410 +1,410 @@
-package org.apache.commons.jcs.access;
-
-/*
- * 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.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.jcs.JCS;
-import org.apache.commons.jcs.access.exception.CacheException;
-import org.apache.commons.jcs.access.exception.ObjectExistsException;
-import org.apache.commons.jcs.engine.CompositeCacheAttributes;
-import org.apache.commons.jcs.engine.ElementAttributes;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes;
-import org.apache.commons.jcs.engine.behavior.IElementAttributes;
-
-/**
- * Tests the methods of the cache access class from which the class JCS extends.
- * <p>
- * @author Aaron Smuts
- */
-public class CacheAccessUnitTest
-    extends TestCase
-{
-    /**
-     * Verify that we get an object exists exception if the item is in the cache.
-     * @throws Exception
-     */
-    public void testPutSafe()
-        throws Exception
-    {
-        CacheAccess<String, String> access = JCS.getInstance( "test" );
-        assertNotNull( "We should have an access class", access );
-
-        String key = "mykey";
-        String value = "myvalue";
-
-        access.put( key, value );
-
-        String returnedValue1 = access.get( key );
-        assertEquals( "Wrong value returned.", value, returnedValue1 );
-
-        try
-        {
-            access.putSafe( key, "someothervalue" );
-            fail( "We should have received an eception since this key is alredy in the cache." );
-        }
-        catch ( CacheException e )
-        {
-            assertTrue( "Wrong type of exception.", e instanceof ObjectExistsException );
-            assertTrue( "Should have the key in the error message.", e.getMessage().indexOf( "[" + key + "]" ) != -1 );
-        }
-
-        String returnedValue2 = access.get( key );
-        assertEquals( "Wrong value returned.  Shoudl still be the original.", value, returnedValue2 );
-    }
-
-    /**
-     * Try to put a null key and verify that we get an exception.
-     * @throws Exception
-     */
-    public void testPutNullKey()
-        throws Exception
-    {
-        CacheAccess<String, String> access = JCS.getInstance( "test" );
-        assertNotNull( "We should have an access class", access );
-
-        String key = null;
-        String value = "myvalue";
-
-        try
-        {
-            access.put( key, value );
-            fail( "Should not have been able to put a null key." );
-        }
-        catch ( CacheException e )
-        {
-            assertTrue( "Should have the work null in the error message.", e.getMessage().indexOf( "null" ) != -1 );
-        }
-    }
-
-    /**
-     * Try to put a null value and verify that we get an exception.
-     * @throws Exception
-     */
-    public void testPutNullValue()
-        throws Exception
-    {
-        CacheAccess<String, String> access = JCS.getInstance( "test" );
-        assertNotNull( "We should have an access class", access );
-
-        String key = "myKey";
-        String value = null;
-
-        try
-        {
-            access.put( key, value );
-            fail( "Should not have been able to put a null object." );
-        }
-        catch ( CacheException e )
-        {
-            assertTrue( "Should have the work null in the error message.", e.getMessage().indexOf( "null" ) != -1 );
-        }
-    }
-
-    /**
-     * Verify that elements that go in the region after this call take the new attributes.
-     * @throws Exception
-     */
-    public void testSetDefaultElementAttributes()
-        throws Exception
-    {
-        CacheAccess<String, String> access = JCS.getInstance( "test" );
-        assertNotNull( "We should have an access class", access );
-
-        long maxLife = 9876;
-        IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
-
-        access.setDefaultElementAttributes( attr );
-
-        assertEquals( "Wrong element attributes.", attr.getMaxLifeSeconds(), access.getDefaultElementAttributes()
-            .getMaxLifeSeconds() );
-
-        String key = "mykey";
-        String value = "myvalue";
-
-        access.put( key, value );
-
-        ICacheElement<String, String> element = access.getCacheElement( key );
-
-        assertEquals( "Wrong max life.  Should have the new value.", maxLife, element.getElementAttributes()
-            .getMaxLifeSeconds() );
-    }
-
-    /**
-     * Verify that getCacheElements returns the elements requested based on the key.
-     * @throws Exception
-     */
-    public void testGetCacheElements()
-        throws Exception
-    {
-        //SETUP
-        CacheAccess<String, String> access = JCS.getInstance( "test" );
-        assertNotNull( "We should have an access class", access );
-
-        String keyOne = "mykeyone";
-        String keyTwo = "mykeytwo";
-        String keyThree = "mykeythree";
-        String valueOne = "myvalueone";
-        String valueTwo = "myvaluetwo";
-        String valueThree = "myvaluethree";
-
-        access.put( keyOne, valueOne );
-        access.put( keyTwo, valueTwo );
-        access.put( keyThree, valueThree );
-
-        Set<String> input = new HashSet<String>();
-        input.add( keyOne );
-        input.add( keyTwo );
-
-        //DO WORK
-        Map<String, ICacheElement<String, String>> result = access.getCacheElements( input );
-
-        //VERIFY
-        assertEquals( "map size", 2, result.size() );
-        ICacheElement<String, String> elementOne = result.get( keyOne );
-        assertEquals( "value one", keyOne, elementOne.getKey() );
-        assertEquals( "value one", valueOne, elementOne.getVal() );
-        ICacheElement<String, String> elementTwo = result.get( keyTwo );
-        assertEquals( "value two", keyTwo, elementTwo.getKey() );
-        assertEquals( "value two", valueTwo, elementTwo.getVal() );
-    }
-
-    /**
-     * Verify that we can get a region using the define region method.
-     * @throws Exception
-     */
-    public void testRegionDefiniton()
-        throws Exception
-    {
-        CacheAccess<String, String> access = JCS.defineRegion( "test" );
-        assertNotNull( "We should have an access class", access );
-    }
-
-    /**
-     * Verify that we can get a region using the define region method with cache attributes.
-     * @throws Exception
-     */
-    public void testRegionDefinitonWithAttributes()
-        throws Exception
-    {
-        ICompositeCacheAttributes ca = new CompositeCacheAttributes();
-
-        long maxIdleTime = 8765;
-        ca.setMaxMemoryIdleTimeSeconds( maxIdleTime );
-
-        CacheAccess<String, String> access = JCS.defineRegion( "testRegionDefinitonWithAttributes", ca );
-        assertNotNull( "We should have an access class", access );
-
-        ICompositeCacheAttributes ca2 = access.getCacheAttributes();
-        assertEquals( "Wrong idle time setting.", ca.getMaxMemoryIdleTimeSeconds(), ca2.getMaxMemoryIdleTimeSeconds() );
-    }
-
-    /**
-     * Verify that we can get a region using the define region method with cache attributes and
-     * elemetn attributes.
-     * @throws Exception
-     */
-    public void testRegionDefinitonWithBothAttributes()
-        throws Exception
-    {
-        ICompositeCacheAttributes ca = new CompositeCacheAttributes();
-
-        long maxIdleTime = 8765;
-        ca.setMaxMemoryIdleTimeSeconds( maxIdleTime );
-
-        long maxLife = 9876;
-        IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
-
-        CacheAccess<String, String> access = JCS.defineRegion( "testRegionDefinitonWithAttributes", ca, attr );
-        assertNotNull( "We should have an access class", access );
-
-        ICompositeCacheAttributes ca2 = access.getCacheAttributes();
-        assertEquals( "Wrong idle time setting.", ca.getMaxMemoryIdleTimeSeconds(), ca2.getMaxMemoryIdleTimeSeconds() );
-    }
-
-    /**
-     * Verify we can get some matching elements..
-     * <p>
-     * @throws Exception
-     */
-    public void testGetMatching_Normal()
-        throws Exception
-    {
-        // SETUP
-        int maxMemorySize = 1000;
-        String keyprefix1 = "MyPrefix1";
-        String keyprefix2 = "MyPrefix2";
-        String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache";
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setMemoryCacheName( memoryCacheClassName );
-        cattr.setMaxObjects( maxMemorySize );
-
-        long maxLife = 9876;
-        IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
-
-        CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
-
-        // DO WORK
-        int numToInsertPrefix1 = 10;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertPrefix1; i++ )
-        {
-            access.put( keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
-        }
-
-        int numToInsertPrefix2 = 50;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertPrefix2; i++ )
-        {
-            access.put( keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
-        }
-
-        Map<String, Integer> result1 = access.getMatching( keyprefix1 + ".+" );
-        Map<String, Integer> result2 = access.getMatching( keyprefix2 + "\\S+" );
-
-        // VERIFY
-        assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
-        assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
-        //System.out.println( result1 );
-
-        // verify that the elements are unwrapped
-        Set<String> keySet1 = result1.keySet();
-        Iterator<String> it1 = keySet1.iterator();
-        while ( it1.hasNext() )
-        {
-            Object key = it1.next();
-            Object value = result1.get( key );
-            assertFalse( "Should not be a cache element.", value instanceof ICacheElement );
-        }
-    }
-
-    /**
-     * Verify we can get some matching elements..
-     * <p>
-     * @throws Exception
-     */
-    public void testGetMatchingElements_Normal()
-        throws Exception
-    {
-        // SETUP
-        int maxMemorySize = 1000;
-        String keyprefix1 = "MyPrefix1";
-        String keyprefix2 = "MyPrefix2";
-        String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache";
-        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
-        cattr.setMemoryCacheName( memoryCacheClassName );
-        cattr.setMaxObjects( maxMemorySize );
-
-        long maxLife = 9876;
-        IElementAttributes attr = new ElementAttributes();
-        attr.setMaxLifeSeconds( maxLife );
-
-        CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
-
-        // DO WORK
-        int numToInsertPrefix1 = 10;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertPrefix1; i++ )
-        {
-            access.put( keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
-        }
-
-        int numToInsertPrefix2 = 50;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertPrefix2; i++ )
-        {
-            access.put( keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
-        }
-
-        Map<String, ICacheElement<String, Integer>> result1 = access.getMatchingCacheElements( keyprefix1 + "\\S+" );
-        Map<String, ICacheElement<String, Integer>> result2 = access.getMatchingCacheElements( keyprefix2 + ".+" );
-
-        // VERIFY
-        assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
-        assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
-        //System.out.println( result1 );
-
-        // verify that the elements are wrapped
-        Set<String> keySet1 = result1.keySet();
-        Iterator<String> it1 = keySet1.iterator();
-        while ( it1.hasNext() )
-        {
-            Object key = it1.next();
-            Object value = result1.get( key );
-            assertTrue( "Should be a cache element.", value instanceof ICacheElement );
-        }
-    }
-
-    /**
-     * Verify we can use the group cache.
-     * <p>
-     * @throws Exception
-     */
-    public void testGroupCache()
-        throws Exception
-    {
-        GroupCacheAccess<String, Integer> access = JCS.getGroupCacheInstance( "testGroup" );
-        String groupName1 = "testgroup1";
-        String groupName2 = "testgroup2";
-
-        Set<String> keys1 = access.getGroupKeys( groupName1 );
-        assertNotNull(keys1);
-        assertEquals(0, keys1.size());
-
-        Set<String> keys2 = access.getGroupKeys( groupName2 );
-        assertNotNull(keys2);
-        assertEquals(0, keys2.size());
-
-        // DO WORK
-        int numToInsertGroup1 = 10;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertGroup1; i++ )
-        {
-            access.putInGroup(String.valueOf( i ), groupName1, Integer.valueOf( i ) );
-        }
-
-        int numToInsertGroup2 = 50;
-        // insert with prefix1
-        for ( int i = 0; i < numToInsertGroup2; i++ )
-        {
-            access.putInGroup(String.valueOf( i ), groupName2, Integer.valueOf( i + 1 ) );
-        }
-
-        keys1 = access.getGroupKeys( groupName1 ); // Test for JCS-102
-        assertNotNull(keys1);
-        assertEquals("Wrong number returned 1:", 10, keys1.size());
-
-        keys2 = access.getGroupKeys( groupName2 );
-        assertNotNull(keys2);
-        assertEquals("Wrong number returned 2:", 50, keys2.size());
-
-        assertEquals(Integer.valueOf(5), access.getFromGroup("5", groupName1));
-        assertEquals(Integer.valueOf(6), access.getFromGroup("5", groupName2));
-    }
-}
+package org.apache.commons.jcs.access;
+
+/*
+ * 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.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.jcs.JCS;
+import org.apache.commons.jcs.access.exception.CacheException;
+import org.apache.commons.jcs.access.exception.ObjectExistsException;
+import org.apache.commons.jcs.engine.CompositeCacheAttributes;
+import org.apache.commons.jcs.engine.ElementAttributes;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.ICompositeCacheAttributes;
+import org.apache.commons.jcs.engine.behavior.IElementAttributes;
+
+/**
+ * Tests the methods of the cache access class from which the class JCS extends.
+ * <p>
+ * @author Aaron Smuts
+ */
+public class CacheAccessUnitTest
+    extends TestCase
+{
+    /**
+     * Verify that we get an object exists exception if the item is in the cache.
+     * @throws Exception
+     */
+    public void testPutSafe()
+        throws Exception
+    {
+        CacheAccess<String, String> access = JCS.getInstance( "test" );
+        assertNotNull( "We should have an access class", access );
+
+        String key = "mykey";
+        String value = "myvalue";
+
+        access.put( key, value );
+
+        String returnedValue1 = access.get( key );
+        assertEquals( "Wrong value returned.", value, returnedValue1 );
+
+        try
+        {
+            access.putSafe( key, "someothervalue" );
+            fail( "We should have received an eception since this key is alredy in the cache." );
+        }
+        catch ( CacheException e )
+        {
+            assertTrue( "Wrong type of exception.", e instanceof ObjectExistsException );
+            assertTrue( "Should have the key in the error message.", e.getMessage().indexOf( "[" + key + "]" ) != -1 );
+        }
+
+        String returnedValue2 = access.get( key );
+        assertEquals( "Wrong value returned.  Shoudl still be the original.", value, returnedValue2 );
+    }
+
+    /**
+     * Try to put a null key and verify that we get an exception.
+     * @throws Exception
+     */
+    public void testPutNullKey()
+        throws Exception
+    {
+        CacheAccess<String, String> access = JCS.getInstance( "test" );
+        assertNotNull( "We should have an access class", access );
+
+        String key = null;
+        String value = "myvalue";
+
+        try
+        {
+            access.put( key, value );
+            fail( "Should not have been able to put a null key." );
+        }
+        catch ( CacheException e )
+        {
+            assertTrue( "Should have the work null in the error message.", e.getMessage().indexOf( "null" ) != -1 );
+        }
+    }
+
+    /**
+     * Try to put a null value and verify that we get an exception.
+     * @throws Exception
+     */
+    public void testPutNullValue()
+        throws Exception
+    {
+        CacheAccess<String, String> access = JCS.getInstance( "test" );
+        assertNotNull( "We should have an access class", access );
+
+        String key = "myKey";
+        String value = null;
+
+        try
+        {
+            access.put( key, value );
+            fail( "Should not have been able to put a null object." );
+        }
+        catch ( CacheException e )
+        {
+            assertTrue( "Should have the work null in the error message.", e.getMessage().indexOf( "null" ) != -1 );
+        }
+    }
+
+    /**
+     * Verify that elements that go in the region after this call take the new attributes.
+     * @throws Exception
+     */
+    public void testSetDefaultElementAttributes()
+        throws Exception
+    {
+        CacheAccess<String, String> access = JCS.getInstance( "test" );
+        assertNotNull( "We should have an access class", access );
+
+        long maxLife = 9876;
+        IElementAttributes attr = new ElementAttributes();
+        attr.setMaxLifeSeconds( maxLife );
+
+        access.setDefaultElementAttributes( attr );
+
+        assertEquals( "Wrong element attributes.", attr.getMaxLifeSeconds(), access.getDefaultElementAttributes()
+            .getMaxLifeSeconds() );
+
+        String key = "mykey";
+        String value = "myvalue";
+
+        access.put( key, value );
+
+        ICacheElement<String, String> element = access.getCacheElement( key );
+
+        assertEquals( "Wrong max life.  Should have the new value.", maxLife, element.getElementAttributes()
+            .getMaxLifeSeconds() );
+    }
+
+    /**
+     * Verify that getCacheElements returns the elements requested based on the key.
+     * @throws Exception
+     */
+    public void testGetCacheElements()
+        throws Exception
+    {
+        //SETUP
+        CacheAccess<String, String> access = JCS.getInstance( "test" );
+        assertNotNull( "We should have an access class", access );
+
+        String keyOne = "mykeyone";
+        String keyTwo = "mykeytwo";
+        String keyThree = "mykeythree";
+        String valueOne = "myvalueone";
+        String valueTwo = "myvaluetwo";
+        String valueThree = "myvaluethree";
+
+        access.put( keyOne, valueOne );
+        access.put( keyTwo, valueTwo );
+        access.put( keyThree, valueThree );
+
+        Set<String> input = new HashSet<String>();
+        input.add( keyOne );
+        input.add( keyTwo );
+
+        //DO WORK
+        Map<String, ICacheElement<String, String>> result = access.getCacheElements( input );
+
+        //VERIFY
+        assertEquals( "map size", 2, result.size() );
+        ICacheElement<String, String> elementOne = result.get( keyOne );
+        assertEquals( "value one", keyOne, elementOne.getKey() );
+        assertEquals( "value one", valueOne, elementOne.getVal() );
+        ICacheElement<String, String> elementTwo = result.get( keyTwo );
+        assertEquals( "value two", keyTwo, elementTwo.getKey() );
+        assertEquals( "value two", valueTwo, elementTwo.getVal() );
+    }
+
+    /**
+     * Verify that we can get a region using the define region method.
+     * @throws Exception
+     */
+    public void testRegionDefiniton()
+        throws Exception
+    {
+        CacheAccess<String, String> access = JCS.defineRegion( "test" );
+        assertNotNull( "We should have an access class", access );
+    }
+
+    /**
+     * Verify that we can get a region using the define region method with cache attributes.
+     * @throws Exception
+     */
+    public void testRegionDefinitonWithAttributes()
+        throws Exception
+    {
+        ICompositeCacheAttributes ca = new CompositeCacheAttributes();
+
+        long maxIdleTime = 8765;
+        ca.setMaxMemoryIdleTimeSeconds( maxIdleTime );
+
+        CacheAccess<String, String> access = JCS.defineRegion( "testRegionDefinitonWithAttributes", ca );
+        assertNotNull( "We should have an access class", access );
+
+        ICompositeCacheAttributes ca2 = access.getCacheAttributes();
+        assertEquals( "Wrong idle time setting.", ca.getMaxMemoryIdleTimeSeconds(), ca2.getMaxMemoryIdleTimeSeconds() );
+    }
+
+    /**
+     * Verify that we can get a region using the define region method with cache attributes and
+     * elemetn attributes.
+     * @throws Exception
+     */
+    public void testRegionDefinitonWithBothAttributes()
+        throws Exception
+    {
+        ICompositeCacheAttributes ca = new CompositeCacheAttributes();
+
+        long maxIdleTime = 8765;
+        ca.setMaxMemoryIdleTimeSeconds( maxIdleTime );
+
+        long maxLife = 9876;
+        IElementAttributes attr = new ElementAttributes();
+        attr.setMaxLifeSeconds( maxLife );
+
+        CacheAccess<String, String> access = JCS.defineRegion( "testRegionDefinitonWithAttributes", ca, attr );
+        assertNotNull( "We should have an access class", access );
+
+        ICompositeCacheAttributes ca2 = access.getCacheAttributes();
+        assertEquals( "Wrong idle time setting.", ca.getMaxMemoryIdleTimeSeconds(), ca2.getMaxMemoryIdleTimeSeconds() );
+    }
+
+    /**
+     * Verify we can get some matching elements..
+     * <p>
+     * @throws Exception
+     */
+    public void testGetMatching_Normal()
+        throws Exception
+    {
+        // SETUP
+        int maxMemorySize = 1000;
+        String keyprefix1 = "MyPrefix1";
+        String keyprefix2 = "MyPrefix2";
+        String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache";
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setMemoryCacheName( memoryCacheClassName );
+        cattr.setMaxObjects( maxMemorySize );
+
+        long maxLife = 9876;
+        IElementAttributes attr = new ElementAttributes();
+        attr.setMaxLifeSeconds( maxLife );
+
+        CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
+
+        // DO WORK
+        int numToInsertPrefix1 = 10;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertPrefix1; i++ )
+        {
+            access.put( keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
+        }
+
+        int numToInsertPrefix2 = 50;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertPrefix2; i++ )
+        {
+            access.put( keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
+        }
+
+        Map<String, Integer> result1 = access.getMatching( keyprefix1 + ".+" );
+        Map<String, Integer> result2 = access.getMatching( keyprefix2 + "\\S+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
+        assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
+        //System.out.println( result1 );
+
+        // verify that the elements are unwrapped
+        Set<String> keySet1 = result1.keySet();
+        Iterator<String> it1 = keySet1.iterator();
+        while ( it1.hasNext() )
+        {
+            Object key = it1.next();
+            Object value = result1.get( key );
+            assertFalse( "Should not be a cache element.", value instanceof ICacheElement );
+        }
+    }
+
+    /**
+     * Verify we can get some matching elements..
+     * <p>
+     * @throws Exception
+     */
+    public void testGetMatchingElements_Normal()
+        throws Exception
+    {
+        // SETUP
+        int maxMemorySize = 1000;
+        String keyprefix1 = "MyPrefix1";
+        String keyprefix2 = "MyPrefix2";
+        String memoryCacheClassName = "org.apache.commons.jcs.engine.memory.lru.LRUMemoryCache";
+        ICompositeCacheAttributes cattr = new CompositeCacheAttributes();
+        cattr.setMemoryCacheName( memoryCacheClassName );
+        cattr.setMaxObjects( maxMemorySize );
+
+        long maxLife = 9876;
+        IElementAttributes attr = new ElementAttributes();
+        attr.setMaxLifeSeconds( maxLife );
+
+        CacheAccess<String, Integer> access = JCS.defineRegion( "testGetMatching_Normal", cattr, attr );
+
+        // DO WORK
+        int numToInsertPrefix1 = 10;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertPrefix1; i++ )
+        {
+            access.put( keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
+        }
+
+        int numToInsertPrefix2 = 50;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertPrefix2; i++ )
+        {
+            access.put( keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
+        }
+
+        Map<String, ICacheElement<String, Integer>> result1 = access.getMatchingCacheElements( keyprefix1 + "\\S+" );
+        Map<String, ICacheElement<String, Integer>> result2 = access.getMatchingCacheElements( keyprefix2 + ".+" );
+
+        // VERIFY
+        assertEquals( "Wrong number returned 1:", numToInsertPrefix1, result1.size() );
+        assertEquals( "Wrong number returned 2:", numToInsertPrefix2, result2.size() );
+        //System.out.println( result1 );
+
+        // verify that the elements are wrapped
+        Set<String> keySet1 = result1.keySet();
+        Iterator<String> it1 = keySet1.iterator();
+        while ( it1.hasNext() )
+        {
+            Object key = it1.next();
+            Object value = result1.get( key );
+            assertTrue( "Should be a cache element.", value instanceof ICacheElement );
+        }
+    }
+
+    /**
+     * Verify we can use the group cache.
+     * <p>
+     * @throws Exception
+     */
+    public void testGroupCache()
+        throws Exception
+    {
+        GroupCacheAccess<String, Integer> access = JCS.getGroupCacheInstance( "testGroup" );
+        String groupName1 = "testgroup1";
+        String groupName2 = "testgroup2";
+
+        Set<String> keys1 = access.getGroupKeys( groupName1 );
+        assertNotNull(keys1);
+        assertEquals(0, keys1.size());
+
+        Set<String> keys2 = access.getGroupKeys( groupName2 );
+        assertNotNull(keys2);
+        assertEquals(0, keys2.size());
+
+        // DO WORK
+        int numToInsertGroup1 = 10;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertGroup1; i++ )
+        {
+            access.putInGroup(String.valueOf( i ), groupName1, Integer.valueOf( i ) );
+        }
+
+        int numToInsertGroup2 = 50;
+        // insert with prefix1
+        for ( int i = 0; i < numToInsertGroup2; i++ )
+        {
+            access.putInGroup(String.valueOf( i ), groupName2, Integer.valueOf( i + 1 ) );
+        }
+
+        keys1 = access.getGroupKeys( groupName1 ); // Test for JCS-102
+        assertNotNull(keys1);
+        assertEquals("Wrong number returned 1:", 10, keys1.size());
+
+        keys2 = access.getGroupKeys( groupName2 );
+        assertNotNull(keys2);
+        assertEquals("Wrong number returned 2:", 50, keys2.size());
+
+        assertEquals(Integer.valueOf(5), access.getFromGroup("5", groupName1));
+        assertEquals(Integer.valueOf(6), access.getFromGroup("5", groupName2));
+    }
+}

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/admin/TestJMX.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/admin/TestJMX.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/admin/TestJMX.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/admin/TestJMX.java Sun Feb 23 10:37:48 2014
@@ -1,38 +1,38 @@
-package org.apache.commons.jcs.admin;
-
-/*
- * 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.jcs.JCS;
-import org.apache.commons.jcs.access.CacheAccess;
-
-/**
- * Helper class to test the JMX registration
- */
-public class TestJMX
-{
-	public static void main(String[] args) throws Exception
-	{
-		CacheAccess<String, String> cache = JCS.getInstance("test");
-
-		cache.put("key", "value");
-        System.out.println("Waiting...");
-        Thread.sleep(Long.MAX_VALUE);
-	}
-}
+package org.apache.commons.jcs.admin;
+
+/*
+ * 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.jcs.JCS;
+import org.apache.commons.jcs.access.CacheAccess;
+
+/**
+ * Helper class to test the JMX registration
+ */
+public class TestJMX
+{
+	public static void main(String[] args) throws Exception
+	{
+		CacheAccess<String, String> cache = JCS.getInstance("test");
+
+		cache.put("key", "value");
+        System.out.println("Waiting...");
+        Thread.sleep(Long.MAX_VALUE);
+	}
+}

Modified: commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java?rev=1570993&r1=1570992&r2=1570993&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/commons/jcs/auxiliary/AuxiliaryCacheConfiguratorUnitTest.java Sun Feb 23 10:37:48 2014
@@ -1,111 +1,130 @@
-package org.apache.commons.jcs.auxiliary;
-
-import java.util.Properties;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.control.MockElementSerializer;
-import org.apache.commons.jcs.engine.logging.MockCacheEventLogger;
-import org.apache.commons.jcs.utils.serialization.StandardSerializer;
-
-/** Unit tests for the auxiliary cache configurator. */
-public class AuxiliaryCacheConfiguratorUnitTest
-    extends TestCase
-{
-    /**
-     * Verify that we don't get an error.
-     */
-    public void testParseCacheEventLogger_Null()
-    {
-        // SETUP
-        Properties props = new Properties();
-
-        // DO WORK
-        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator.parseCacheEventLogger( props,
-                                                                                                               "junk" );
-
-        // VERIFY
-        assertNull( "Should not have a logger.", result );
-    }
-
-    /**
-     * Verify that we don't get an error.
-     */
-    public void testParseCacheEventLogger_NullName()
-    {
-        // SETUP
-        Properties props = new Properties();
-
-        // DO WORK
-        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator.parseCacheEventLogger( props,
-                                                                                                               null );
-
-        // VERIFY
-        assertNull( "Should not have a logger.", result );
-    }
-
-    /**
-     * Verify that we can parse the event logger.
-     */
-    public void testParseCacheEventLogger_Normal()
-    {
-        // SETUP
-        String auxPrefix = "jcs.auxiliary." + "MYAux";
-        String testPropertyValue = "This is the value";
-        String className = MockCacheEventLogger.class.getName();
-
-        Properties props = new Properties();
-        props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX, className );
-        props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX
-            + AuxiliaryCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue );
-
-        // DO WORK
-        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator
-            .parseCacheEventLogger( props, auxPrefix );
-
-        // VERIFY
-        assertNotNull( "Should have a logger.", result );
-        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty() );
-    }
-
-    /**
-     * Verify that we can parse the ElementSerializer.
-     */
-    public void testParseElementSerializer_Normal()
-    {
-        // SETUP
-        String auxPrefix = "jcs.auxiliary." + "MYAux";
-        String testPropertyValue = "This is the value";
-        String className = MockElementSerializer.class.getName();
-
-        Properties props = new Properties();
-        props.put( auxPrefix + AuxiliaryCacheConfigurator.SERIALIZER_PREFIX, className );
-        props.put( auxPrefix + AuxiliaryCacheConfigurator.SERIALIZER_PREFIX
-            + AuxiliaryCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue );
-
-        // DO WORK
-        MockElementSerializer result = (MockElementSerializer) AuxiliaryCacheConfigurator
-            .parseElementSerializer( props, auxPrefix );
-
-        // VERIFY
-        assertNotNull( "Should have a Serializer.", result );
-        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty() );
-    }
-
-    /**
-     * Verify that we can parse the ElementSerializer.
-     */
-    public void testParseElementSerializer_Null()
-    {
-        // SETUP
-        Properties props = new Properties();
-
-        // DO WORK
-        IElementSerializer result = AuxiliaryCacheConfigurator
-            .parseElementSerializer( props, "junk" );
-
-        // VERIFY
-        assertTrue( "Should have the default Serializer.", result instanceof StandardSerializer );
-    }
-}
+package org.apache.commons.jcs.auxiliary;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.util.Properties;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.jcs.engine.behavior.IElementSerializer;
+import org.apache.commons.jcs.engine.control.MockElementSerializer;
+import org.apache.commons.jcs.engine.logging.MockCacheEventLogger;
+import org.apache.commons.jcs.utils.serialization.StandardSerializer;
+
+/** Unit tests for the auxiliary cache configurator. */
+public class AuxiliaryCacheConfiguratorUnitTest
+    extends TestCase
+{
+    /**
+     * Verify that we don't get an error.
+     */
+    public void testParseCacheEventLogger_Null()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator.parseCacheEventLogger( props,
+                                                                                                               "junk" );
+
+        // VERIFY
+        assertNull( "Should not have a logger.", result );
+    }
+
+    /**
+     * Verify that we don't get an error.
+     */
+    public void testParseCacheEventLogger_NullName()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator.parseCacheEventLogger( props,
+                                                                                                               null );
+
+        // VERIFY
+        assertNull( "Should not have a logger.", result );
+    }
+
+    /**
+     * Verify that we can parse the event logger.
+     */
+    public void testParseCacheEventLogger_Normal()
+    {
+        // SETUP
+        String auxPrefix = "jcs.auxiliary." + "MYAux";
+        String testPropertyValue = "This is the value";
+        String className = MockCacheEventLogger.class.getName();
+
+        Properties props = new Properties();
+        props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX, className );
+        props.put( auxPrefix + AuxiliaryCacheConfigurator.CACHE_EVENT_LOGGER_PREFIX
+            + AuxiliaryCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue );
+
+        // DO WORK
+        MockCacheEventLogger result = (MockCacheEventLogger) AuxiliaryCacheConfigurator
+            .parseCacheEventLogger( props, auxPrefix );
+
+        // VERIFY
+        assertNotNull( "Should have a logger.", result );
+        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty() );
+    }
+
+    /**
+     * Verify that we can parse the ElementSerializer.
+     */
+    public void testParseElementSerializer_Normal()
+    {
+        // SETUP
+        String auxPrefix = "jcs.auxiliary." + "MYAux";
+        String testPropertyValue = "This is the value";
+        String className = MockElementSerializer.class.getName();
+
+        Properties props = new Properties();
+        props.put( auxPrefix + AuxiliaryCacheConfigurator.SERIALIZER_PREFIX, className );
+        props.put( auxPrefix + AuxiliaryCacheConfigurator.SERIALIZER_PREFIX
+            + AuxiliaryCacheConfigurator.ATTRIBUTE_PREFIX + ".testProperty", testPropertyValue );
+
+        // DO WORK
+        MockElementSerializer result = (MockElementSerializer) AuxiliaryCacheConfigurator
+            .parseElementSerializer( props, auxPrefix );
+
+        // VERIFY
+        assertNotNull( "Should have a Serializer.", result );
+        assertEquals( "Property should be set.", testPropertyValue, result.getTestProperty() );
+    }
+
+    /**
+     * Verify that we can parse the ElementSerializer.
+     */
+    public void testParseElementSerializer_Null()
+    {
+        // SETUP
+        Properties props = new Properties();
+
+        // DO WORK
+        IElementSerializer result = AuxiliaryCacheConfigurator
+            .parseElementSerializer( props, "junk" );
+
+        // VERIFY
+        assertTrue( "Should have the default Serializer.", result instanceof StandardSerializer );
+    }
+}



Mime
View raw message