You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by tv...@apache.org on 2014/05/02 16:24:19 UTC

svn commit: r1591929 - in /commons/proper/jcs/trunk/commons-jcs-jcache/src: main/java/org/apache/commons/jcs/jcache/ test/java/org/apache/commons/jcs/jcache/

Author: tv
Date: Fri May  2 14:24:19 2014
New Revision: 1591929

URL: http://svn.apache.org/r1591929
Log:
Centralize thread factories, fix formatting

Modified:
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CachingProviderTest.java
    commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/Speed.java

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCache.java Fri May  2 14:24:19 2014
@@ -18,17 +18,18 @@
  */
 package org.apache.commons.jcs.jcache;
 
-import org.apache.commons.jcs.access.CacheAccess;
-import org.apache.commons.jcs.access.exception.CacheException;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.IElementSerializer;
-import org.apache.commons.jcs.engine.control.CompositeCache;
-import org.apache.commons.jcs.jcache.jmx.JCSCacheMXBean;
-import org.apache.commons.jcs.jcache.jmx.JCSCacheStatisticsMXBean;
-import org.apache.commons.jcs.jcache.jmx.JMXs;
-import org.apache.commons.jcs.jcache.proxy.ExceptionWrapperHandler;
-import org.apache.commons.jcs.utils.serialization.StandardSerializer;
-import org.apache.commons.jcs.utils.threadpool.ThreadPoolManager;
+import static org.apache.commons.jcs.jcache.Asserts.assertNotNull;
+
+import java.io.Serializable;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 import javax.cache.Cache;
 import javax.cache.CacheManager;
@@ -50,18 +51,19 @@ import javax.cache.processor.EntryProces
 import javax.cache.processor.EntryProcessorException;
 import javax.cache.processor.EntryProcessorResult;
 import javax.management.ObjectName;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
 
-import static org.apache.commons.jcs.jcache.Asserts.assertNotNull;
+import org.apache.commons.jcs.access.CacheAccess;
+import org.apache.commons.jcs.access.exception.CacheException;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.IElementSerializer;
+import org.apache.commons.jcs.engine.control.CompositeCache;
+import org.apache.commons.jcs.jcache.jmx.JCSCacheMXBean;
+import org.apache.commons.jcs.jcache.jmx.JCSCacheStatisticsMXBean;
+import org.apache.commons.jcs.jcache.jmx.JMXs;
+import org.apache.commons.jcs.jcache.proxy.ExceptionWrapperHandler;
+import org.apache.commons.jcs.utils.serialization.StandardSerializer;
+import org.apache.commons.jcs.utils.threadpool.DaemonThreadFactory;
+import org.apache.commons.jcs.utils.threadpool.ThreadPoolManager;
 
 // TODO: get statistics locally correct then correct even if distributed
 public class JCSCache<K extends Serializable, V extends Serializable, C extends CompleteConfiguration<K, V>> implements Cache<K, V>
@@ -83,14 +85,14 @@ public class JCSCache<K extends Serializ
     private final ExecutorService pool;
 
     public JCSCache(final ClassLoader classLoader, final CacheManager mgr, final JCSConfiguration<K, V> configuration,
-                    final CompositeCache<K, JCSElement<V>> cache, final Properties properties)
+            final CompositeCache<K, JCSElement<V>> cache, final Properties properties)
     {
         manager = mgr;
         delegate = new CacheAccess<K, JCSElement<V>>(cache);
         config = configuration;
-        pool = properties != null && properties.containsKey(POOL_SIZE_PROPERTY)?
-                Executors.newFixedThreadPool(Integer.parseInt(properties.getProperty(POOL_SIZE_PROPERTY)), new ThreadPoolManager.MyThreadFactory()) :
-                Executors.newCachedThreadPool(new ThreadPoolManager.MyThreadFactory());
+        DaemonThreadFactory threadFactory = new DaemonThreadFactory("JCS-JCache-");
+        pool = properties != null && properties.containsKey(POOL_SIZE_PROPERTY) ? Executors.newFixedThreadPool(
+                Integer.parseInt(properties.getProperty(POOL_SIZE_PROPERTY)), threadFactory) : Executors.newCachedThreadPool(threadFactory);
 
         final Factory<CacheLoader<K, V>> cacheLoaderFactory = configuration.getCacheLoaderFactory();
         if (cacheLoaderFactory == null)
@@ -99,7 +101,8 @@ public class JCSCache<K extends Serializ
         }
         else
         {
-            loader = ExceptionWrapperHandler.newProxy(classLoader, cacheLoaderFactory.create(), CacheLoaderException.class, CacheLoader.class);
+            loader = ExceptionWrapperHandler
+                    .newProxy(classLoader, cacheLoaderFactory.create(), CacheLoaderException.class, CacheLoader.class);
         }
 
         final Factory<CacheWriter<? super K, ? super V>> cacheWriterFactory = configuration.getCacheWriterFactory();
@@ -109,7 +112,8 @@ public class JCSCache<K extends Serializ
         }
         else
         {
-            writer = ExceptionWrapperHandler.newProxy(classLoader, cacheWriterFactory.create(), CacheWriterException.class, CacheWriter.class);
+            writer = ExceptionWrapperHandler
+                    .newProxy(classLoader, cacheWriterFactory.create(), CacheWriterException.class, CacheWriter.class);
         }
 
         final Factory<ExpiryPolicy> expiryPolicyFactory = configuration.getExpiryPolicyFactory();
@@ -132,16 +136,10 @@ public class JCSCache<K extends Serializ
         final String mgrStr = manager.getURI().toString().replaceAll(",|:|=|\n", ".");
         try
         {
-            cacheConfigObjectName = new ObjectName(
-                    "javax.cache:type=CacheConfiguration," +
-                            "CacheManager=" + mgrStr + "," +
-                            "Cache=" + cache.getCacheName()
-            );
-            cacheStatsObjectName = new ObjectName(
-                    "javax.cache:type=CacheStatistics," +
-                            "CacheManager=" + mgrStr + "," +
-                            "Cache=" + cache.getCacheName()
-            );
+            cacheConfigObjectName = new ObjectName("javax.cache:type=CacheConfiguration," + "CacheManager=" + mgrStr + "," + "Cache="
+                    + cache.getCacheName());
+            cacheStatsObjectName = new ObjectName("javax.cache:type=CacheStatistics," + "CacheManager=" + mgrStr + "," + "Cache="
+                    + cache.getCacheName());
         }
         catch (final Exception e)
         {
@@ -223,7 +221,7 @@ public class JCSCache<K extends Serializ
         assertNotClosed();
         for (final K k : keys)
         {
-            assertNotNull(k , "key");
+            assertNotNull(k, "key");
         }
 
         final Set<K> names = (Set<K>) keys;
@@ -288,13 +286,14 @@ public class JCSCache<K extends Serializ
         try
         {
             final JCSElement<V> oldElt = delegate.get(key);
-            final V old = oldElt != null? oldElt.getElement() : null;
+            final V old = oldElt != null ? oldElt.getElement() : null;
 
             final boolean storeByValue = config.isStoreByValue();
             final V value = storeByValue ? copy(rawValue) : rawValue;
 
             final boolean created = old == null;
-            final JCSElement<V> element = new JCSElement<V>(value, created ? expiryPolicy.getExpiryForCreation() : expiryPolicy.getExpiryForUpdate());
+            final JCSElement<V> element = new JCSElement<V>(value, created ? expiryPolicy.getExpiryForCreation()
+                    : expiryPolicy.getExpiryForUpdate());
             if (element.isExpired())
             {
                 if (!created)
@@ -310,13 +309,13 @@ public class JCSCache<K extends Serializ
                 {
                     if (created)
                     {
-                        listener.onCreated(Arrays.<CacheEntryEvent<? extends K, ? extends V>>asList(
-                                new JCSCacheEntryEvent<K, V>(this, EventType.CREATED, null, key, value)));
+                        listener.onCreated(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this,
+                                EventType.CREATED, null, key, value)));
                     }
                     else
                     {
-                        listener.onUpdated(Arrays.<CacheEntryEvent<? extends K, ? extends V>>asList(
-                                new JCSCacheEntryEvent<K, V>(this, EventType.UPDATED, old, key, value)));
+                        listener.onUpdated(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this,
+                                EventType.UPDATED, old, key, value)));
                     }
                 }
 
@@ -395,8 +394,8 @@ public class JCSCache<K extends Serializ
         }
         for (final JCSListener<K, V> listener : listeners.values())
         {
-            listener.onRemoved(Arrays.<CacheEntryEvent<? extends K, ? extends V>>asList(
-                    new JCSCacheEntryEvent<K, V>(this, EventType.REMOVED, null, key, value)));
+            listener.onRemoved(Arrays.<CacheEntryEvent<? extends K, ? extends V>> asList(new JCSCacheEntryEvent<K, V>(this,
+                    EventType.REMOVED, null, key, value)));
         }
         if (remove && statisticsEnabled)
         {
@@ -434,14 +433,13 @@ public class JCSCache<K extends Serializ
         return v;
     }
 
-    private V doGetControllingExpiry(final K key, final boolean updateAcess,
-                                     final boolean forceDoLoad, final boolean skipLoad,
-                                     final boolean propagateLoadException)
+    private V doGetControllingExpiry(final K key, final boolean updateAcess, final boolean forceDoLoad, final boolean skipLoad,
+            final boolean propagateLoadException)
     {
         final boolean statisticsEnabled = config.isStatisticsEnabled();
         final long getStart = Times.now();
         final JCSElement<V> elt = delegate.get(key);
-        V v = elt != null? elt.getElement() : null;
+        V v = elt != null ? elt.getElement() : null;
         if (v == null && (config.isReadThrough() || forceDoLoad))
         {
             if (!skipLoad)
@@ -615,8 +613,7 @@ public class JCSCache<K extends Serializ
     }
 
     @Override
-    public void loadAll(final Set<? extends K> keys, final boolean replaceExistingValues,
-                        final CompletionListener completionListener)
+    public void loadAll(final Set<? extends K> keys, final boolean replaceExistingValues, final CompletionListener completionListener)
     {
         assertNotClosed();
         assertNotNull(keys, "keys");
@@ -634,8 +631,7 @@ public class JCSCache<K extends Serializ
         });
     }
 
-    private void doLoadAll(final Set<? extends K> keys, final boolean replaceExistingValues,
-                           final CompletionListener completionListener)
+    private void doLoadAll(final Set<? extends K> keys, final boolean replaceExistingValues, final CompletionListener completionListener)
     {
         try
         {
@@ -676,7 +672,8 @@ public class JCSCache<K extends Serializ
         return t;
     }
 
-    private <T> T doInvoke(final TempStateCacheView<K, V> view, final K key, final EntryProcessor<K, V, T> entryProcessor, final Object... arguments)
+    private <T> T doInvoke(final TempStateCacheView<K, V> view, final K key, final EntryProcessor<K, V, T> entryProcessor,
+            final Object... arguments)
     {
         assertNotClosed();
         assertNotNull(entryProcessor, "entryProcessor");
@@ -712,9 +709,8 @@ public class JCSCache<K extends Serializ
     }
 
     @Override
-    public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys,
-                                                         final EntryProcessor<K, V, T> entryProcessor,
-                                                         final Object... arguments)
+    public <T> Map<K, EntryProcessorResult<T>> invokeAll(final Set<? extends K> keys, final EntryProcessor<K, V, T> entryProcessor,
+            final Object... arguments)
     {
         assertNotClosed();
         assertNotNull(entryProcessor, "entryProcessor");
@@ -755,7 +751,8 @@ public class JCSCache<K extends Serializ
     public void registerCacheEntryListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)
     {
         assertNotClosed();
-        if (listeners.containsKey(cacheEntryListenerConfiguration)) {
+        if (listeners.containsKey(cacheEntryListenerConfiguration))
+        {
             throw new IllegalArgumentException(cacheEntryListenerConfiguration + " already registered");
         }
         listeners.put(cacheEntryListenerConfiguration, new JCSListener<K, V>(cacheEntryListenerConfiguration));
@@ -763,7 +760,8 @@ public class JCSCache<K extends Serializ
     }
 
     @Override
-    public void deregisterCacheEntryListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration) {
+    public void deregisterCacheEntryListener(final CacheEntryListenerConfiguration<K, V> cacheEntryListenerConfiguration)
+    {
         assertNotClosed();
         listeners.remove(cacheEntryListenerConfiguration);
         config.removeListener(cacheEntryListenerConfiguration);

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSCachingManager.java Fri May  2 14:24:19 2014
@@ -112,10 +112,16 @@ public class JCSCachingManager implement
         final Class<?> valueType = configuration == null ? Object.class : configuration.getValueType();
         if (!caches.containsKey(cacheName))
         {
-            final Cache<K, V> cache = ClassLoaderAwareHandler.newProxy(
-                    loader,
-                    new JCSCache/* <K, V, C> */(loader, this, new JCSConfiguration(configuration, keyType, valueType),
-                                                instance.getCache(cacheName), instance.getConfigurationProperties()), Cache.class);
+            final Cache<K, V> cache = ClassLoaderAwareHandler.newProxy(loader, new JCSCache/*
+                                                                                            * <
+                                                                                            * K
+                                                                                            * ,
+                                                                                            * V
+                                                                                            * ,
+                                                                                            * C
+                                                                                            * >
+                                                                                            */(loader, this, new JCSConfiguration(
+                    configuration, keyType, valueType), instance.getCache(cacheName), instance.getConfigurationProperties()), Cache.class);
             caches.putIfAbsent(cacheName, cache);
         }
         else
@@ -203,7 +209,7 @@ public class JCSCachingManager implement
         {
             JCSCachingProvider.class.cast(provider).remove(this);
         }
-		instance.shutDown();
+        instance.shutDown();
     }
 
     @Override
@@ -261,7 +267,7 @@ public class JCSCachingManager implement
 
         final Configuration<K, V> config = cache.getConfiguration(Configuration.class);
         if ((keyType != null && !config.getKeyType().isAssignableFrom(keyType))
-            || (valueType != null && !config.getValueType().isAssignableFrom(valueType)))
+                || (valueType != null && !config.getValueType().isAssignableFrom(valueType)))
         {
             throw new IllegalArgumentException("this cache is <" + config.getKeyType().getName() + ", " + config.getValueType().getName()
                     + "> " + " and not <" + keyType.getName() + ", " + valueType.getName() + ">");

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/main/java/org/apache/commons/jcs/jcache/JCSElement.java Fri May  2 14:24:19 2014
@@ -47,10 +47,12 @@ public class JCSElement<V> implements Se
         if (duration == null || duration.isEternal())
         {
             end = -1;
-        } else if (duration.isZero())
+        }
+        else if (duration.isZero())
         {
             end = 0;
-        } else
+        }
+        else
         {
             end = duration.getAdjustedTime(Times.now());
         }

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CacheTest.java Fri May  2 14:24:19 2014
@@ -52,14 +52,14 @@ public class CacheTest
     {
         final CachingProvider cachingProvider = Caching.getCachingProvider();
         final CacheManager cacheManager = cachingProvider.getCacheManager();
-        cacheManager.createCache( "default", null );
-        final Cache<String, String> cache = cacheManager.getCache( "default" );
-        assertFalse( cache.containsKey( "foo" ) );
-        cache.put( "foo", "bar" );
-        assertTrue( cache.containsKey( "foo" ) );
-        assertEquals( "bar", cache.get( "foo" ) );
-        cache.remove( "foo" );
-        assertFalse( cache.containsKey( "foo" ) );
+        cacheManager.createCache("default", null);
+        final Cache<String, String> cache = cacheManager.getCache("default");
+        assertFalse(cache.containsKey("foo"));
+        cache.put("foo", "bar");
+        assertTrue(cache.containsKey("foo"));
+        assertEquals("bar", cache.get("foo"));
+        cache.remove("foo");
+        assertFalse(cache.containsKey("foo"));
         cachingProvider.close();
     }
 
@@ -68,10 +68,10 @@ public class CacheTest
     {
         final CachingProvider cachingProvider = Caching.getCachingProvider();
         final CacheManager cacheManager = cachingProvider.getCacheManager();
-        cacheManager.createCache( "default", null );
-        final Cache<String, String> cache = cacheManager.getCache( "default" );
+        cacheManager.createCache("default", null);
+        final Cache<String, String> cache = cacheManager.getCache("default");
         final Set<String> event = new HashSet<String>();
-        cache.registerCacheEntryListener( new CacheEntryListenerConfiguration<String, String>()
+        cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>()
         {
             @Override
             public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory()
@@ -84,11 +84,10 @@ public class CacheTest
                         return new CacheEntryCreatedListener<String, String>()
                         {
                             @Override
-                            public void onCreated(
-                                Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents )
-                                throws CacheEntryListenerException
+                            public void onCreated(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents)
+                                    throws CacheEntryListenerException
                             {
-                                event.add( cacheEntryEvents.iterator().next().getKey() );
+                                event.add(cacheEntryEvents.iterator().next().getKey());
                             }
                         };
                     }
@@ -112,8 +111,8 @@ public class CacheTest
             {
                 return false;
             }
-        } );
-        cache.registerCacheEntryListener( new CacheEntryListenerConfiguration<String, String>()
+        });
+        cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>()
         {
             @Override
             public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory()
@@ -126,11 +125,10 @@ public class CacheTest
                         return new CacheEntryUpdatedListener<String, String>()
                         {
                             @Override
-                            public void onUpdated(
-                                Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents )
-                                throws CacheEntryListenerException
+                            public void onUpdated(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents)
+                                    throws CacheEntryListenerException
                             {
-                                event.add( cacheEntryEvents.iterator().next().getKey() );
+                                event.add(cacheEntryEvents.iterator().next().getKey());
                             }
                         };
                     }
@@ -154,8 +152,8 @@ public class CacheTest
             {
                 return false;
             }
-        } );
-        cache.registerCacheEntryListener( new CacheEntryListenerConfiguration<String, String>()
+        });
+        cache.registerCacheEntryListener(new CacheEntryListenerConfiguration<String, String>()
         {
             @Override
             public Factory<CacheEntryListener<? super String, ? super String>> getCacheEntryListenerFactory()
@@ -168,11 +166,10 @@ public class CacheTest
                         return new CacheEntryRemovedListener<String, String>()
                         {
                             @Override
-                            public void onRemoved(
-                                Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents )
-                                throws CacheEntryListenerException
+                            public void onRemoved(Iterable<CacheEntryEvent<? extends String, ? extends String>> cacheEntryEvents)
+                                    throws CacheEntryListenerException
                             {
-                                event.add( cacheEntryEvents.iterator().next().getKey() );
+                                event.add(cacheEntryEvents.iterator().next().getKey());
                             }
                         };
                     }
@@ -196,19 +193,19 @@ public class CacheTest
             {
                 return false;
             }
-        } );
+        });
 
-        cache.put( "foo", "bar" );
-        assertEquals( 1, event.size() );
-        assertEquals( "foo", event.iterator().next() );
+        cache.put("foo", "bar");
+        assertEquals(1, event.size());
+        assertEquals("foo", event.iterator().next());
         event.clear();
-        cache.put( "foo", "new" );
-        assertEquals( 1, event.size() );
-        assertEquals( "foo", event.iterator().next() );
+        cache.put("foo", "new");
+        assertEquals(1, event.size());
+        assertEquals("foo", event.iterator().next());
         event.clear();
-        cache.remove( "foo" );
-        assertEquals( 1, event.size() );
-        assertEquals( "foo", event.iterator().next() );
+        cache.remove("foo");
+        assertEquals(1, event.size());
+        assertEquals("foo", event.iterator().next());
 
         cachingProvider.close();
     }
@@ -218,7 +215,7 @@ public class CacheTest
     {
         final CachingProvider cachingProvider = Caching.getCachingProvider();
         final CacheManager cacheManager = cachingProvider.getCacheManager();
-        cacheManager.createCache( "default", new CompleteConfiguration<Object, Object>()
+        cacheManager.createCache("default", new CompleteConfiguration<Object, Object>()
         {
             @Override
             public boolean isReadThrough()
@@ -261,15 +258,13 @@ public class CacheTest
                         return new CacheLoader<Object, Object>()
                         {
                             @Override
-                            public Object load( Object key )
-                                throws CacheLoaderException
+                            public Object load(Object key) throws CacheLoaderException
                             {
                                 return "super";
                             }
 
                             @Override
-                            public Map<Object, Object> loadAll( Iterable<?> keys )
-                                throws CacheLoaderException
+                            public Map<Object, Object> loadAll(Iterable<?> keys) throws CacheLoaderException
                             {
                                 return null;
                             }
@@ -307,9 +302,9 @@ public class CacheTest
             {
                 return false;
             }
-        } );
-        final Cache<String, String> cache = cacheManager.getCache( "default" );
-        assertEquals( "super", cache.get( "lazilyLoaded" ) );
+        });
+        final Cache<String, String> cache = cacheManager.getCache("default");
+        assertEquals("super", cache.get("lazilyLoaded"));
         cachingProvider.close();
     }
 }

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CachingProviderTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CachingProviderTest.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CachingProviderTest.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/CachingProviderTest.java Fri May  2 14:24:19 2014
@@ -31,14 +31,14 @@ public class CachingProviderTest
     @Test
     public void findProvider()
     {
-        assertNotNull( Caching.getCachingProvider() );
+        assertNotNull(Caching.getCachingProvider());
     }
 
     @Test
     public void createCacheMgr()
     {
         final CachingProvider cachingProvider = Caching.getCachingProvider();
-        assertNotNull( cachingProvider.getCacheManager() );
+        assertNotNull(cachingProvider.getCacheManager());
         cachingProvider.close();
     }
 }

Modified: commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/Speed.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/Speed.java?rev=1591929&r1=1591928&r2=1591929&view=diff
==============================================================================
--- commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/Speed.java (original)
+++ commons/proper/jcs/trunk/commons-jcs-jcache/src/test/java/org/apache/commons/jcs/jcache/Speed.java Fri May  2 14:24:19 2014
@@ -18,6 +18,17 @@
  */
 package org.apache.commons.jcs.jcache;
 
+import java.io.IOException;
+import java.util.Random;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import javax.cache.Cache;
+import javax.cache.CacheManager;
+import javax.cache.Caching;
+import javax.cache.configuration.MutableConfiguration;
+import javax.cache.spi.CachingProvider;
+
 import org.apache.commons.jcs.engine.CacheElement;
 import org.apache.commons.jcs.engine.CompositeCacheAttributes;
 import org.apache.commons.jcs.engine.ElementAttributes;
@@ -32,49 +43,45 @@ import org.openjdk.jmh.runner.Runner;
 import org.openjdk.jmh.runner.RunnerException;
 import org.openjdk.jmh.runner.options.OptionsBuilder;
 
-import javax.cache.Cache;
-import javax.cache.CacheManager;
-import javax.cache.Caching;
-import javax.cache.configuration.MutableConfiguration;
-import javax.cache.spi.CachingProvider;
-import java.io.IOException;
-import java.util.Random;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicInteger;
-
 /* not a test, just a helper to run when micro-benchmarking
 
-@BenchmarkMode(Mode.AverageTime)
-@OutputTimeUnit(TimeUnit.NANOSECONDS)
+ @BenchmarkMode(Mode.AverageTime)
+ @OutputTimeUnit(TimeUnit.NANOSECONDS)
  */
-public class Speed {
+public class Speed
+{
     private static final Random RDM = new Random(System.currentTimeMillis());
 
     @State(Scope.Benchmark)
-    public static class MapState {
+    public static class MapState
+    {
         private ConcurrentHashMap<String, Integer> map;
         private final AtomicInteger count = new AtomicInteger(0);
 
         @Setup
-        public void setup() {
+        public void setup()
+        {
             map = new ConcurrentHashMap<String, Integer>();
         }
 
         @TearDown
-        public void end() {
+        public void end()
+        {
             map.clear();
         }
     }
 
     @State(Scope.Benchmark)
-    public static class JCacheState {
+    public static class JCacheState
+    {
         private CachingProvider cachingProvider;
         private CacheManager manager;
         private Cache<Object, Object> jcache;
         private final AtomicInteger count = new AtomicInteger(0);
 
         @Setup
-        public void setup() {
+        public void setup()
+        {
             cachingProvider = Caching.getCachingProvider();
             manager = cachingProvider.getCacheManager();
             manager.createCache("speed-test", new MutableConfiguration<String, Integer>().setStoreByValue(false));
@@ -82,62 +89,76 @@ public class Speed {
         }
 
         @TearDown
-        public void end() {
+        public void end()
+        {
             cachingProvider.close();
         }
     }
 
     @State(Scope.Benchmark)
-    public static class LRUMemoryCacheState {
+    public static class LRUMemoryCacheState
+    {
         private LRUMemoryCache<String, Integer> map;
         private final AtomicInteger count = new AtomicInteger(0);
 
         @Setup
-        public void setup() {
+        public void setup()
+        {
             map = new LRUMemoryCache<String, Integer>();
-            map.initialize(new CompositeCache<String, Integer>("super-cache", new CompositeCacheAttributes(), new ElementAttributes()));
+            map.initialize(new CompositeCache<String, Integer>(new CompositeCacheAttributes(), new ElementAttributes()));
         }
 
         @TearDown
-        public void end() {
-            try {
+        public void end()
+        {
+            try
+            {
                 map.removeAll();
             }
-            catch (final IOException e) {
+            catch (final IOException e)
+            {
                 // no-op
             }
         }
     }
 
     @GenerateMicroBenchmark
-    public void memCachePut(final LRUMemoryCacheState state) {
+    public void memCachePut(final LRUMemoryCacheState state)
+    {
         final int i = state.count.incrementAndGet();
-        try {
+        try
+        {
             state.map.update(new CacheElement<String, Integer>("speed-test", Integer.toString(i), i));
         }
-        catch (final IOException e) {
+        catch (final IOException e)
+        {
             throw new RuntimeException(e);
         }
     }
 
     @GenerateMicroBenchmark
-    public void memCacheGet(final LRUMemoryCacheState state) {
-        try {
+    public void memCacheGet(final LRUMemoryCacheState state)
+    {
+        try
+        {
             state.map.get(RDM.nextInt(1000) + "");
         }
-        catch (final IOException e) {
+        catch (final IOException e)
+        {
             throw new RuntimeException(e);
         }
     }
 
     @GenerateMicroBenchmark
-    public void normalMapPut(final MapState state) {
+    public void normalMapPut(final MapState state)
+    {
         final int i = state.count.incrementAndGet();
         state.map.put(Integer.toString(i), i);
     }
 
     @GenerateMicroBenchmark
-    public void normalMapPutGet(final MapState state) {
+    public void normalMapPutGet(final MapState state)
+    {
         final int i = state.count.incrementAndGet();
         final String key = Integer.toString(i);
         state.map.get(key);
@@ -145,22 +166,26 @@ public class Speed {
     }
 
     @GenerateMicroBenchmark
-    public void normalMapGet(final MapState state) {
+    public void normalMapGet(final MapState state)
+    {
         state.map.get(RDM.nextInt(1000) + "");
     }
 
     @GenerateMicroBenchmark
-    public void jcsJCachePut(final JCacheState state) {
+    public void jcsJCachePut(final JCacheState state)
+    {
         final int i = state.count.incrementAndGet();
         state.jcache.put(Integer.toString(i), i);
     }
 
     @GenerateMicroBenchmark
-    public void jcsJCacheGet(final JCacheState state) {
+    public void jcsJCacheGet(final JCacheState state)
+    {
         state.jcache.get(RDM.nextInt(1000) + "");
     }
 
-    public static void main(final String[] args) throws IOException, RunnerException {
+    public static void main(final String[] args) throws IOException, RunnerException
+    {
         new Runner(new OptionsBuilder().include(".*" + Speed.class.getName() + ".*").warmupIterations(5).measurementIterations(5).forks(2)
                 .build()).run();
     }