Use Java7 diamond operator
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java
index 282988b..8a006a2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/JCS.java
@@ -129,7 +129,7 @@
throws CacheException
{
CompositeCache<K, V> cache = getCacheManager().getCache( region );
- return new CacheAccess<K, V>( cache );
+ return new CacheAccess<>( cache );
}
/**
@@ -144,7 +144,7 @@
throws CacheException
{
CompositeCache<K, V> cache = getCacheManager().getCache( region, icca );
- return new CacheAccess<K, V>( cache );
+ return new CacheAccess<>( cache );
}
/**
@@ -160,7 +160,7 @@
throws CacheException
{
CompositeCache<K, V> cache = getCacheManager().getCache( region, icca, eattr );
- return new CacheAccess<K, V>( cache );
+ return new CacheAccess<>( cache );
}
/**
@@ -174,7 +174,7 @@
throws CacheException
{
CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region );
- return new GroupCacheAccess<K, V>( cache );
+ return new GroupCacheAccess<>( cache );
}
/**
@@ -189,7 +189,7 @@
throws CacheException
{
CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca );
- return new GroupCacheAccess<K, V>( cache );
+ return new GroupCacheAccess<>( cache );
}
/**
@@ -205,6 +205,6 @@
throws CacheException
{
CompositeCache<GroupAttrName<K>, V> cache = getCacheManager().getCache( region, icca, eattr );
- return new GroupCacheAccess<K, V>( cache );
+ return new GroupCacheAccess<>( cache );
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/CacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/CacheAccess.java
index 71095eb..9ca959a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/CacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/CacheAccess.java
@@ -118,7 +118,7 @@
if ( wrappedResults == null )
{
- unwrappedResults = new HashMap<K, V>();
+ unwrappedResults = new HashMap<>();
}
else
{
@@ -260,7 +260,7 @@
// should be wrapped by cache access.
try
{
- CacheElement<K, V> ce = new CacheElement<K, V>( this.getCacheControl().getCacheName(), key,
+ CacheElement<K, V> ce = new CacheElement<>( this.getCacheControl().getCacheName(), key,
val );
ce.setElementAttributes( attr );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/GroupCacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/GroupCacheAccess.java
index 83c846c..88d4a28 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/GroupCacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/GroupCacheAccess.java
@@ -76,7 +76,7 @@
private GroupAttrName<K> getGroupAttrName( String group, K name )
{
GroupId gid = new GroupId( this.getCacheControl().getCacheName(), group );
- return new GroupAttrName<K>( gid, name );
+ return new GroupAttrName<>( gid, name );
}
/**
@@ -134,7 +134,7 @@
{
GroupAttrName<K> key = getGroupAttrName( groupName, name );
CacheElement<GroupAttrName<K>, V> ce =
- new CacheElement<GroupAttrName<K>, V>( this.getCacheControl().getCacheName(), key, value );
+ new CacheElement<>( this.getCacheControl().getCacheName(), key, value );
IElementAttributes attributes = (attr == null) ? this.getCacheControl().getElementAttributes() : attr;
ce.setElementAttributes( attributes );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/PartitionedCacheAccess.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/PartitionedCacheAccess.java
index a12e039..c516a54 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/PartitionedCacheAccess.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/access/PartitionedCacheAccess.java
@@ -281,12 +281,12 @@
int partition = getPartitionNumberForKey( key );
if ( dividedNames[partition] == null )
{
- dividedNames[partition] = new HashSet<K>();
+ dividedNames[partition] = new HashSet<>();
}
dividedNames[partition].add( key );
}
- Map<K, ICacheElement<K, V>> result = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> result = new HashMap<>();
for ( int i = 0; i < partitions.length; i++ )
{
if ( dividedNames[i] != null && !dividedNames[i].isEmpty() )
@@ -320,7 +320,7 @@
return null;
}
- Map<K, V> result = new HashMap<K, V>();
+ Map<K, V> result = new HashMap<>();
for (ICacheAccess<K, V> partition : partitions)
{
result.putAll( partition.getMatching( pattern ) );
@@ -349,7 +349,7 @@
return null;
}
- Map<K, ICacheElement<K, V>> result = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> result = new HashMap<>();
for (ICacheAccess<K, V> partition : partitions)
{
result.putAll( partition.getMatchingCacheElements( pattern ) );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java
index 8e33621..10fddd9 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/admin/JCSAdminBean.java
@@ -102,7 +102,7 @@
keys = cache.getMemoryCache().getKeySet().toArray(new Serializable[0]);
}
- LinkedList<CacheElementInfo> records = new LinkedList<CacheElementInfo>();
+ LinkedList<CacheElementInfo> records = new LinkedList<>();
ICacheElement<Serializable, Serializable> element;
IElementAttributes attributes;
@@ -147,7 +147,7 @@
Arrays.sort( cacheNames );
- LinkedList<CacheRegionInfo> cacheInfo = new LinkedList<CacheRegionInfo>();
+ LinkedList<CacheRegionInfo> cacheInfo = new LinkedList<>();
CacheRegionInfo regionInfo;
CompositeCache<?, ?> cache;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCache.java
index 2371b39..b0ee573 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/AbstractAuxiliaryCache.java
@@ -45,7 +45,7 @@
private IElementSerializer elementSerializer = new StandardSerializer();
/** Key matcher used by the getMatching API */
- private IKeyMatcher<K> keyMatcher = new KeyMatcherPatternImpl<K>();
+ private IKeyMatcher<K> keyMatcher = new KeyMatcherPatternImpl<>();
/**
* Gets multiple items from the cache based on the given set of keys.
@@ -75,7 +75,7 @@
element -> element));
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -99,7 +99,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<K>();
+ return new CacheEvent<>();
}
String diskLocation = getEventLoggingExtraInfo();
String regionName = null;
@@ -125,7 +125,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<T>();
+ return new CacheEvent<>();
}
String diskLocation = getEventLoggingExtraInfo();
return cacheEventLogger.createICacheEvent( getAuxiliaryCacheAttributes().getName(), regionName, eventName,
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java
index a536876..1ceb231 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCache.java
@@ -114,7 +114,7 @@
this.cacheName = attr.getCacheName();
// create queue
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>();
+ CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
this.cacheEventQueue = fact.createCacheEventQueue( new MyCacheListener(), CacheInfo.listenerId, cacheName,
diskCacheAttributes.getEventQueuePoolName(),
diskCacheAttributes.getEventQueueType() );
@@ -159,11 +159,11 @@
{
if ( diskCacheAttributes.getMaxPurgatorySize() >= 0 )
{
- purgatory = new LRUMap<K, PurgatoryElement<K, V>>( diskCacheAttributes.getMaxPurgatorySize() );
+ purgatory = new LRUMap<>( diskCacheAttributes.getMaxPurgatorySize() );
}
else
{
- purgatory = new HashMap<K, PurgatoryElement<K, V>>();
+ purgatory = new HashMap<>();
}
}
}
@@ -198,7 +198,7 @@
try
{
// Wrap the CacheElement in a PurgatoryElement
- PurgatoryElement<K, V> pe = new PurgatoryElement<K, V>( cacheElement );
+ PurgatoryElement<K, V> pe = new PurgatoryElement<>( cacheElement );
// Indicates the the element is eligible to be spooled to disk,
// this will remain true unless the item is pulled back into
@@ -324,7 +324,7 @@
// this avoids locking purgatory, but it uses more memory
synchronized ( purgatory )
{
- keyArray = new HashSet<K>(purgatory.keySet());
+ keyArray = new HashSet<>(purgatory.keySet());
}
Set<K> matchingKeys = getKeyMatcher().getMatchingKeysFromArray( pattern, keyArray );
@@ -512,10 +512,10 @@
IStats stats = new Stats();
stats.setTypeName( "Abstract Disk Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Integer>( "Purgatory Hits", Integer.valueOf(purgHits) ) );
- elems.add(new StatElement<Integer>( "Purgatory Size", Integer.valueOf(purgatory.size()) ) );
+ elems.add(new StatElement<>( "Purgatory Hits", Integer.valueOf(purgHits) ) );
+ elems.add(new StatElement<>( "Purgatory Size", Integer.valueOf(purgatory.size()) ) );
// get the stats from the event queue too
IStats eqStats = this.cacheEventQueue.getStatistics();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
index 8d3e046..aaf3bea 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDisk.java
@@ -63,7 +63,7 @@
private final AtomicInteger numberOfBlocks = new AtomicInteger(0);
/** Empty blocks that can be reused. */
- private final ConcurrentLinkedQueue<Integer> emptyBlocks = new ConcurrentLinkedQueue<Integer>();
+ private final ConcurrentLinkedQueue<Integer> emptyBlocks = new ConcurrentLinkedQueue<>();
/** The serializer. */
private final IElementSerializer elementSerializer;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java
index 06f89ba..7e66e8d 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCache.java
@@ -138,7 +138,7 @@
getElementSerializer() );
}
- keyStore = new BlockDiskKeyStore<K>( this.blockDiskCacheAttributes, this );
+ keyStore = new BlockDiskKeyStore<>( this.blockDiskCacheAttributes, this );
boolean alright = verifyDisk();
@@ -234,7 +234,7 @@
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> keys = new HashSet<K>();
+ HashSet<K> keys = new HashSet<>();
storageLock.readLock().lock();
@@ -264,7 +264,7 @@
storageLock.readLock().lock();
try
{
- keyArray = new HashSet<K>(keyStore.keySet());
+ keyArray = new HashSet<>(keyStore.keySet());
}
finally
{
@@ -695,29 +695,29 @@
IStats stats = new Stats();
stats.setTypeName( "Block Disk Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Boolean>( "Is Alive", Boolean.valueOf(isAlive()) ) );
- elems.add(new StatElement<Integer>( "Key Map Size", Integer.valueOf(this.keyStore.size()) ) );
+ elems.add(new StatElement<>( "Is Alive", Boolean.valueOf(isAlive()) ) );
+ elems.add(new StatElement<>( "Key Map Size", Integer.valueOf(this.keyStore.size()) ) );
if (this.dataFile != null)
{
try
{
- elems.add(new StatElement<Long>( "Data File Length", Long.valueOf(this.dataFile.length()) ) );
+ elems.add(new StatElement<>( "Data File Length", Long.valueOf(this.dataFile.length()) ) );
}
catch ( IOException e )
{
log.error( e );
}
- elems.add(new StatElement<Integer>( "Block Size Bytes",
+ elems.add(new StatElement<>( "Block Size Bytes",
Integer.valueOf(this.dataFile.getBlockSizeBytes()) ) );
- elems.add(new StatElement<Integer>( "Number Of Blocks",
+ elems.add(new StatElement<>( "Number Of Blocks",
Integer.valueOf(this.dataFile.getNumberOfBlocks()) ) );
- elems.add(new StatElement<Long>( "Average Put Size Bytes",
+ elems.add(new StatElement<>( "Average Put Size Bytes",
Long.valueOf(this.dataFile.getAveragePutSizeBytes()) ) );
- elems.add(new StatElement<Integer>( "Empty Blocks",
+ elems.add(new StatElement<>( "Empty Blocks",
Integer.valueOf(this.dataFile.getEmptyBlocks()) ) );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java
index 0b35d2b..c54c573 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheFactory.java
@@ -57,7 +57,7 @@
log.debug( "Creating DiskCache for attributes = " + idca );
}
- BlockDiskCache<K, V> cache = new BlockDiskCache<K, V>( idca, elementSerializer );
+ BlockDiskCache<K, V> cache = new BlockDiskCache<>( idca, elementSerializer );
cache.setCacheEventLogger( cacheEventLogger );
return cache;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskKeyStore.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskKeyStore.java
index 4a9568e..bf4909a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskKeyStore.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskKeyStore.java
@@ -161,7 +161,7 @@
// collection makes a copy
for (Map.Entry<K, int[]> entry : keyHash.entrySet())
{
- BlockDiskElementDescriptor<K> descriptor = new BlockDiskElementDescriptor<K>();
+ BlockDiskElementDescriptor<K> descriptor = new BlockDiskElementDescriptor<>();
descriptor.setKey(entry.getKey());
descriptor.setBlocks(entry.getValue());
// stream these out in the loop.
@@ -228,7 +228,7 @@
{
// If no max size, use a plain map for memory and processing
// efficiency.
- keyHash = new HashMap<K, int[]>();
+ keyHash = new HashMap<>();
// keyHash = Collections.synchronizedMap( new HashMap() );
if (log.isInfoEnabled())
{
@@ -253,7 +253,7 @@
// create a key map to use.
initKeyMap();
- HashMap<K, int[]> keys = new HashMap<K, int[]>();
+ HashMap<K, int[]> keys = new HashMap<>();
synchronized (keyFile)
{
@@ -377,7 +377,7 @@
*/
private boolean verify()
{
- Map<Integer, Set<K>> blockAllocationMap = new TreeMap<Integer, Set<K>>();
+ Map<Integer, Set<K>> blockAllocationMap = new TreeMap<>();
for (Entry<K, int[]> e : keyHash.entrySet())
{
for (int block : e.getValue())
@@ -385,7 +385,7 @@
Set<K> keys = blockAllocationMap.get(block);
if (keys == null)
{
- keys = new HashSet<K>();
+ keys = new HashSet<>();
blockAllocationMap.put(block, keys);
}
else if (!log.isDebugEnabled())
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
index c288784..9f2e3c8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
@@ -464,7 +464,7 @@
keyFile.reset();
- HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<K, IndexedDiskElementDescriptor>();
+ HashMap<K, IndexedDiskElementDescriptor> keys = new HashMap<>();
keys.putAll(keyHash);
if (keys.size() > 0)
@@ -650,12 +650,12 @@
@Override
public Map<K, ICacheElement<K, V>> processGetMatching(String pattern)
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
Set<K> keyArray = null;
storageLock.readLock().lock();
try
{
- keyArray = new HashSet<K>(keyHash.keySet());
+ keyArray = new HashSet<>(keyHash.keySet());
}
finally
{
@@ -725,7 +725,7 @@
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> keys = new HashSet<K>();
+ HashSet<K> keys = new HashSet<>();
storageLock.readLock().lock();
@@ -817,7 +817,7 @@
boolean removed = false;
// remove all keys of the same name hierarchy.
- List<K> itemsToRemove = new LinkedList<K>();
+ List<K> itemsToRemove = new LinkedList<>();
for (K k : keyHash.keySet())
{
@@ -855,7 +855,7 @@
boolean removed = false;
// remove all keys of the same name group.
- List<K> itemsToRemove = new LinkedList<K>();
+ List<K> itemsToRemove = new LinkedList<>();
// remove all keys of the same name hierarchy.
for (K k : keyHash.keySet())
@@ -1512,27 +1512,27 @@
IStats stats = new Stats();
stats.setTypeName("Indexed Disk Cache");
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Boolean>("Is Alive", Boolean.valueOf(isAlive())));
- elems.add(new StatElement<Integer>("Key Map Size", Integer.valueOf(this.keyHash != null ? this.keyHash.size() : -1)));
+ elems.add(new StatElement<>("Is Alive", Boolean.valueOf(isAlive())));
+ elems.add(new StatElement<>("Key Map Size", Integer.valueOf(this.keyHash != null ? this.keyHash.size() : -1)));
try
{
elems
- .add(new StatElement<Long>("Data File Length", Long.valueOf(this.dataFile != null ? this.dataFile.length() : -1L)));
+ .add(new StatElement<>("Data File Length", Long.valueOf(this.dataFile != null ? this.dataFile.length() : -1L)));
}
catch (IOException e)
{
log.error(e);
}
- elems.add(new StatElement<Integer>("Max Key Size", this.maxKeySize));
- elems.add(new StatElement<AtomicInteger>("Hit Count", this.hitCount));
- elems.add(new StatElement<AtomicLong>("Bytes Free", this.bytesFree));
- elems.add(new StatElement<Integer>("Optimize Operation Count", Integer.valueOf(this.removeCount)));
- elems.add(new StatElement<Integer>("Times Optimized", Integer.valueOf(this.timesOptimized)));
- elems.add(new StatElement<Integer>("Recycle Count", Integer.valueOf(this.recycleCnt)));
- elems.add(new StatElement<Integer>("Recycle Bin Size", Integer.valueOf(this.recycle.size())));
- elems.add(new StatElement<Integer>("Startup Size", Integer.valueOf(this.startupSize)));
+ elems.add(new StatElement<>("Max Key Size", this.maxKeySize));
+ elems.add(new StatElement<>("Hit Count", this.hitCount));
+ elems.add(new StatElement<>("Bytes Free", this.bytesFree));
+ elems.add(new StatElement<>("Optimize Operation Count", Integer.valueOf(this.removeCount)));
+ elems.add(new StatElement<>("Times Optimized", Integer.valueOf(this.timesOptimized)));
+ elems.add(new StatElement<>("Recycle Count", Integer.valueOf(this.recycleCnt)));
+ elems.add(new StatElement<>("Recycle Bin Size", Integer.valueOf(this.recycle.size())));
+ elems.add(new StatElement<>("Startup Size", Integer.valueOf(this.startupSize)));
// get the stats from the super too
IStats sStats = super.getStatistics();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
index 03f2f10..e34bd51 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheFactory.java
@@ -57,7 +57,7 @@
log.debug( "Creating DiskCache for attributes = " + idca );
}
- IndexedDiskCache<K, V> cache = new IndexedDiskCache<K, V>( idca, elementSerializer );
+ IndexedDiskCache<K, V> cache = new IndexedDiskCache<>( idca, elementSerializer );
cache.setCacheEventLogger( cacheEventLogger );
return cache;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java
index 94d9cfe..a6ab077 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskDumper.java
@@ -50,7 +50,7 @@
attr.setCacheName( args[0] );
attr.setDiskPath( args[0] );
- IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<Serializable, Serializable>( attr );
+ IndexedDiskCache<Serializable, Serializable> dc = new IndexedDiskCache<>( attr );
dc.dump( true );
System.exit( 0 );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
index 0177f09..30ffaee 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCache.java
@@ -465,7 +465,7 @@
return null;
}
- Map<K, ICacheElement<K, V>> results = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> results = new HashMap<>();
try
{
@@ -830,10 +830,10 @@
List<IStatElement<?>> elems = stats.getStatElements();
- elems.add(new StatElement<AtomicInteger>( "Update Count", updateCount ) );
- elems.add(new StatElement<AtomicInteger>( "Get Count", getCount ) );
- elems.add(new StatElement<AtomicInteger>( "Get Matching Count", getMatchingCount ) );
- elems.add(new StatElement<String>( "DB URL", getJdbcDiskCacheAttributes().getUrl()) );
+ elems.add(new StatElement<>( "Update Count", updateCount ) );
+ elems.add(new StatElement<>( "Get Count", getCount ) );
+ elems.add(new StatElement<>( "Get Matching Count", getMatchingCount ) );
+ elems.add(new StatElement<>( "DB URL", getJdbcDiskCacheAttributes().getUrl()) );
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
index 026a172..0ba22ea 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheFactory.java
@@ -95,7 +95,7 @@
TableState tableState = getTableState( cattr.getTableName() );
DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
- JDBCDiskCache<K, V> cache = new JDBCDiskCache<K, V>( cattr, dsFactory, tableState, compositeCacheManager );
+ JDBCDiskCache<K, V> cache = new JDBCDiskCache<>( cattr, dsFactory, tableState, compositeCacheManager );
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
@@ -112,9 +112,9 @@
public void initialize()
{
super.initialize();
- this.tableStates = new ConcurrentHashMap<String, TableState>();
- this.shrinkerThreadMap = new ConcurrentHashMap<String, ShrinkerThread>();
- this.dsFactories = new ConcurrentHashMap<String, DataSourceFactory>();
+ this.tableStates = new ConcurrentHashMap<>();
+ this.shrinkerThreadMap = new ConcurrentHashMap<>();
+ this.dsFactories = new ConcurrentHashMap<>();
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/ShrinkerThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/ShrinkerThread.java
index adcdb0e..752845b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/ShrinkerThread.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/ShrinkerThread.java
@@ -40,7 +40,7 @@
/** A set of JDBCDiskCache objects to call deleteExpired on. */
private final Set<JDBCDiskCache<?, ?>> shrinkSet =
- Collections.synchronizedSet( new HashSet<JDBCDiskCache<?, ?>>() );
+ Collections.synchronizedSet( new HashSet<>() );
/** Default time period to use. */
private static final long DEFAULT_PAUSE_BETWEEN_REGION_CALLS_MILLIS = 5000;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
index cd32e11..4c8f12b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/dsfactory/JndiDataSourceFactory.java
@@ -138,7 +138,7 @@
log.debug("Time between context lookups: " + ttl);
}
- Hashtable<String, Object> env = new Hashtable<String, Object>();
+ Hashtable<String, Object> env = new Hashtable<>();
ctx = new InitialContext(env);
if (log.isDebugEnabled())
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
index 49899c1..a821a26 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheFactory.java
@@ -79,7 +79,7 @@
public void initialize()
{
super.initialize();
- this.databases = Collections.synchronizedSet( new HashSet<String>() );
+ this.databases = Collections.synchronizedSet( new HashSet<>() );
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
index 147948a..090f766 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheFactory.java
@@ -68,7 +68,7 @@
TableState tableState = getTableState( cattr.getTableName() );
DataSourceFactory dsFactory = getDataSourceFactory(cattr, compositeCacheManager.getConfigurationProperties());
- MySQLDiskCache<K, V> cache = new MySQLDiskCache<K, V>( cattr, dsFactory, tableState, compositeCacheManager );
+ MySQLDiskCache<K, V> cache = new MySQLDiskCache<>( cattr, dsFactory, tableState, compositeCacheManager );
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java
index 77b6cd1..0a7ccea 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCache.java
@@ -319,7 +319,7 @@
{
log.error( "Disabling lateral cache due to error " + msg, ex );
- lateralCacheService = new ZombieCacheServiceNonLocal<K, V>( lateralCacheAttributes.getZombieQueueMaxSize() );
+ lateralCacheService = new ZombieCacheServiceNonLocal<>( lateralCacheAttributes.getZombieQueueMaxSize() );
// may want to flush if region specifies
// Notify the cache monitor about the error, and kick off the recovery
// process.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheMonitor.java
index bbe88ad..c78916b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheMonitor.java
@@ -69,7 +69,7 @@
{
super("JCS-LateralCacheMonitor");
this.factory = factory;
- this.caches = new ConcurrentHashMap<String, LateralCacheNoWait<?,?>>();
+ this.caches = new ConcurrentHashMap<>();
setIdlePeriod(20000L);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWait.java
index ab9e1dc..3a7d9d4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWait.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWait.java
@@ -84,8 +84,8 @@
log.debug( "Constructing LateralCacheNoWait, LateralCache = [" + cache + "]" );
}
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>();
- this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache
+ CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
+ this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<>( cache ), CacheInfo.listenerId, cache
.getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache
.getAuxiliaryCacheAttributes().getEventQueueType() );
@@ -182,7 +182,7 @@
return elements;
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -360,8 +360,8 @@
{
eventQueue.destroy();
}
- CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>();
- this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache
+ CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<>();
+ this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<>( cache ), CacheInfo.listenerId, cache
.getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache
.getAuxiliaryCacheAttributes().getEventQueueType() );
}
@@ -405,16 +405,16 @@
IStats stats = new Stats();
stats.setTypeName( "Lateral Cache No Wait" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
// get the stats from the event queue too
IStats eqStats = this.eventQueue.getStatistics();
elems.addAll(eqStats.getStatElements());
- elems.add(new StatElement<Integer>( "Get Count", Integer.valueOf(this.getCount) ) );
- elems.add(new StatElement<Integer>( "Remove Count", Integer.valueOf(this.removeCount) ) );
- elems.add(new StatElement<Integer>( "Put Count", Integer.valueOf(this.putCount) ) );
- elems.add(new StatElement<AuxiliaryCacheAttributes>( "Attributes", cache.getAuxiliaryCacheAttributes() ) );
+ elems.add(new StatElement<>( "Get Count", Integer.valueOf(this.getCount) ) );
+ elems.add(new StatElement<>( "Remove Count", Integer.valueOf(this.removeCount) ) );
+ elems.add(new StatElement<>( "Put Count", Integer.valueOf(this.putCount) ) );
+ elems.add(new StatElement<>( "Attributes", cache.getAuxiliaryCacheAttributes() ) );
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
index 90e322c..807ec69 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
@@ -246,7 +246,7 @@
return elements;
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -259,7 +259,7 @@
@Override
public Map<K, ICacheElement<K, V>> getMatching(String pattern)
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
for (LateralCacheNoWait<K, V> nw : noWaits)
{
elements.putAll( nw.getMatching( pattern ) );
@@ -275,7 +275,7 @@
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> allKeys = new HashSet<K>();
+ HashSet<K> allKeys = new HashSet<>();
for (LateralCacheNoWait<K, V> nw : noWaits)
{
if ( nw != null )
@@ -451,11 +451,11 @@
IStats stats = new Stats();
stats.setTypeName( "Lateral Cache No Wait Facade" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
if ( noWaits != null )
{
- elems.add(new StatElement<Integer>( "Number of No Waits", Integer.valueOf(noWaits.length) ) );
+ elems.add(new StatElement<>( "Number of No Waits", Integer.valueOf(noWaits.length) ) );
for ( LateralCacheNoWait<K, V> lcnw : noWaits )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
index c517a74..c254a45 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
@@ -89,7 +89,7 @@
ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
{
ITCPLateralCacheAttributes lac = (ITCPLateralCacheAttributes) iaca;
- ArrayList<ICache<K, V>> noWaits = new ArrayList<ICache<K, V>>();
+ ArrayList<ICache<K, V>> noWaits = new ArrayList<>();
// pairs up the tcp servers and set the tcpServer value and
// get the manager and then get the cache
@@ -125,7 +125,7 @@
@SuppressWarnings("unchecked") // No generic arrays in java
LateralCacheNoWait<K, V>[] lcnwArray = noWaits.toArray( new LateralCacheNoWait[0] );
LateralCacheNoWaitFacade<K, V> lcnwf =
- new LateralCacheNoWaitFacade<K, V>(listener, lcnwArray, lac );
+ new LateralCacheNoWaitFacade<>(listener, lcnwArray, lac );
// create udp discovery if available.
createDiscoveryService( lac, lcnwf, cacheMgr, cacheEventLogger, elementSerializer );
@@ -138,7 +138,7 @@
{
ICacheServiceNonLocal<K, V> lateralService = getCSNLInstance(lca);
- LateralCache<K, V> cache = new LateralCache<K, V>( lca, lateralService, this.monitor );
+ LateralCache<K, V> cache = new LateralCache<>( lca, lateralService, this.monitor );
cache.setCacheEventLogger( cacheEventLogger );
cache.setElementSerializer( elementSerializer );
@@ -147,7 +147,7 @@
log.debug( "Created cache for noWait, cache [" + cache + "]" );
}
- LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<K, V>( cache );
+ LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<>( cache );
lateralNoWait.setCacheEventLogger( cacheEventLogger );
lateralNoWait.setElementSerializer( elementSerializer );
@@ -166,8 +166,8 @@
@Override
public void initialize()
{
- this.csnlInstances = new ConcurrentHashMap<String, ICacheServiceNonLocal<?, ?>>();
- this.lTCPDLInstances = new ConcurrentHashMap<String, LateralTCPDiscoveryListener>();
+ this.csnlInstances = new ConcurrentHashMap<>();
+ this.lTCPDLInstances = new ConcurrentHashMap<>();
// Create the monitoring daemon thread
this.monitor = new LateralCacheMonitor(this);
@@ -253,7 +253,7 @@
log.info( "Creating TCP service, lca = " + lca );
}
- return new LateralTCPService<K, V>( lca );
+ return new LateralTCPService<>( lca );
}
catch ( IOException ex )
{
@@ -263,7 +263,7 @@
log.error( "Failure, lateral instance will use zombie service", ex );
ICacheServiceNonLocal<K, V> zombieService =
- new ZombieCacheServiceNonLocal<K, V>( lca.getZombieQueueMaxSize() );
+ new ZombieCacheServiceNonLocal<>( lca.getZombieQueueMaxSize() );
// Notify the cache monitor about the error, and kick off
// the recovery process.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
index 4d6fd73..60170f1 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListener.java
@@ -54,14 +54,14 @@
* use laterals.
*/
private final Map<String, LateralCacheNoWaitFacade<?, ?>> facades =
- Collections.synchronizedMap( new HashMap<String, LateralCacheNoWaitFacade<?, ?>>() );
+ Collections.synchronizedMap( new HashMap<>() );
/**
* List of regions that are configured differently here than on another server. We keep track of
* this to limit the amount of info logging.
*/
private final Set<String> knownDifferentlyConfiguredRegions =
- Collections.synchronizedSet( new HashSet<String>() );
+ Collections.synchronizedSet( new HashSet<>() );
/** The name of the cache factory */
private String factoryName;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
index 12373ae..9506a34 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPListener.java
@@ -70,7 +70,7 @@
/** Map of available instances, keyed by port */
private static final HashMap<String, ILateralCacheListener<?, ?>> instances =
- new HashMap<String, ILateralCacheListener<?, ?>>();
+ new HashMap<>();
/** The socket listener */
private ListenerThread receiver;
@@ -120,7 +120,7 @@
if ( ins == null )
{
- ins = new LateralTCPListener<K, V>( ilca );
+ ins = new LateralTCPListener<>( ilca );
ins.init();
ins.setCacheManager( cacheMgr );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
index 5f346c9..ac90834 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
@@ -125,7 +125,7 @@
// if we shouldn't remove on put, then put
if ( !this.issueRemoveOnPut )
{
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( item );
+ LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( item );
led.requesterId = requesterId;
led.command = LateralCommand.UPDATE;
sender.send( led );
@@ -139,8 +139,8 @@
log.debug( "Issuing a remove for a put" );
}
// set the value to null so we don't send the item
- CacheElement<K, V> ce = new CacheElement<K, V>( item.getCacheName(), item.getKey(), null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( ce );
+ CacheElement<K, V> ce = new CacheElement<>( item.getCacheName(), item.getKey(), null );
+ LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVE;
led.valHashCode = item.getVal().hashCode();
@@ -169,8 +169,8 @@
public void remove( String cacheName, K key, long requesterId )
throws IOException
{
- CacheElement<K, V> ce = new CacheElement<K, V>( cacheName, key, null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( ce );
+ CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
+ LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVE;
sender.send( led );
@@ -230,8 +230,8 @@
// if get is not allowed return
if ( this.allowGet )
{
- CacheElement<K, V> ce = new CacheElement<K, V>( cacheName, key, null );
- LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( ce );
+ CacheElement<K, V> ce = new CacheElement<>( cacheName, key, null );
+ LateralElementDescriptor<K, V> led = new LateralElementDescriptor<>( ce );
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET;
@SuppressWarnings("unchecked") // Need to cast from Object
@@ -283,8 +283,8 @@
// if get is not allowed return
if ( this.allowGet )
{
- CacheElement<String, String> ce = new CacheElement<String, String>( cacheName, pattern, null );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce );
+ CacheElement<String, String> ce = new CacheElement<>( cacheName, pattern, null );
+ LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET_MATCHING;
@@ -334,7 +334,7 @@
public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
throws IOException
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
if ( keys != null && !keys.isEmpty() )
{
@@ -361,8 +361,8 @@
@SuppressWarnings("unchecked") // Need cast from Object
public Set<K> getKeySet(String cacheName) throws IOException
{
- CacheElement<String, String> ce = new CacheElement<String, String>(cacheName, null, null);
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>(ce);
+ CacheElement<String, String> ce = new CacheElement<>(cacheName, null, null);
+ LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>(ce);
// led.requesterId = requesterId; // later
led.command = LateralCommand.GET_KEYSET;
Object response = sender.sendAndReceive(led);
@@ -394,8 +394,8 @@
public void removeAll( String cacheName, long requesterId )
throws IOException
{
- CacheElement<String, String> ce = new CacheElement<String, String>( cacheName, "ALL", null );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce );
+ CacheElement<String, String> ce = new CacheElement<>( cacheName, "ALL", null );
+ LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
led.requesterId = requesterId;
led.command = LateralCommand.REMOVEALL;
sender.send( led );
@@ -427,8 +427,8 @@
continue;
}
- CacheElement<String, String> ce = new CacheElement<String, String>( "test", "test", message );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce );
+ CacheElement<String, String> ce = new CacheElement<>( "test", "test", message );
+ LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
sender.send( led );
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteAuxiliaryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
index 080b850..0a50d0f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteAuxiliaryCache.java
@@ -270,7 +270,7 @@
public Map<K, ICacheElement<K, V>> processGetMatching( String pattern )
throws IOException
{
- Map<K, ICacheElement<K, V>> results = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> results = new HashMap<>();
try
{
Map<K, ICacheElement<K, V>> rawResults = getRemoteCacheService().getMatching( cacheName, pattern, getListenerId() );
@@ -529,25 +529,25 @@
IStats stats = new Stats();
stats.setTypeName( "AbstractRemoteAuxiliaryCache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<String>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
+ elems.add(new StatElement<>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
// if ( this.getRemoteCacheAttributes().getRemoteType() == RemoteType.CLUSTER )
// {
// // something cluster specific
// }
- elems.add(new StatElement<Boolean>( "UsePoolForGet", Boolean.valueOf(usePoolForGet) ) );
+ elems.add(new StatElement<>( "UsePoolForGet", Boolean.valueOf(usePoolForGet) ) );
if ( pool != null )
{
- elems.add(new StatElement<ExecutorService>( "Pool", pool ) );
+ elems.add(new StatElement<>( "Pool", pool ) );
}
if ( getRemoteCacheService() instanceof ZombieCacheServiceNonLocal )
{
- elems.add(new StatElement<Integer>( "Zombie Queue Size",
+ elems.add(new StatElement<>( "Zombie Queue Size",
Integer.valueOf(( (ZombieCacheServiceNonLocal<K, V>) getRemoteCacheService() ).getQueueSize()) ) );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
index da541d5..9ae49ee 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/AbstractRemoteCacheNoWaitFacade.java
@@ -71,7 +71,7 @@
this.remoteCacheAttributes = rca;
setCacheEventLogger( cacheEventLogger );
setElementSerializer( elementSerializer );
- this.noWaits = new ArrayList<RemoteCacheNoWait<K,V>>(noWaits);
+ this.noWaits = new ArrayList<>(noWaits);
for (RemoteCacheNoWait<K,V> nw : this.noWaits)
{
// FIXME: This cast is very brave. Remove this.
@@ -219,7 +219,7 @@
@Override
public Set<K> getKeySet() throws IOException
{
- HashSet<K> allKeys = new HashSet<K>();
+ HashSet<K> allKeys = new HashSet<>();
for (RemoteCacheNoWait<K, V> nw : noWaits)
{
if ( nw != null )
@@ -407,11 +407,11 @@
IStats stats = new Stats();
stats.setTypeName( "Remote Cache No Wait Facade" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
if ( noWaits != null )
{
- elems.add(new StatElement<Integer>( "Number of No Waits", Integer.valueOf(noWaits.size()) ) );
+ elems.add(new StatElement<>( "Number of No Waits", Integer.valueOf(noWaits.size()) ) );
for ( RemoteCacheNoWait<K, V> rcnw : noWaits )
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
index ec0a269..2db1577 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCache.java
@@ -83,10 +83,10 @@
IStats stats = new Stats();
stats.setTypeName( "Remote Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<String>( "Remote Host:Port", getIPAddressForService() ) );
- elems.add(new StatElement<String>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
+ elems.add(new StatElement<>( "Remote Host:Port", getIPAddressForService() ) );
+ elems.add(new StatElement<>( "Remote Type", this.getRemoteCacheAttributes().getRemoteTypeName() ) );
// if ( this.getRemoteCacheAttributes().getRemoteType() == RemoteType.CLUSTER )
// {
@@ -144,7 +144,7 @@
if ( getRemoteCacheService() == null || !( getRemoteCacheService() instanceof ZombieCacheServiceNonLocal ) )
{
// TODO make configurable
- setRemoteCacheService( new ZombieCacheServiceNonLocal<K, V>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) );
+ setRemoteCacheService( new ZombieCacheServiceNonLocal<>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) );
}
// may want to flush if region specifies
// Notify the cache monitor about the error, and kick off the recovery
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
index 3c1ef01..25f18d6 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheFactory.java
@@ -74,13 +74,13 @@
{
RemoteCacheAttributes rca = (RemoteCacheAttributes) iaca;
- ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<RemoteCacheNoWait<K,V>>();
+ ArrayList<RemoteCacheNoWait<K,V>> noWaits = new ArrayList<>();
switch (rca.getRemoteType())
{
case LOCAL:
// a list to be turned into an array of failover server information
- ArrayList<RemoteLocation> failovers = new ArrayList<RemoteLocation>();
+ ArrayList<RemoteLocation> failovers = new ArrayList<>();
// not necessary if a failover list is defined
// REGISTER PRIMARY LISTENER
@@ -152,7 +152,7 @@
}
RemoteCacheNoWaitFacade<K, V> rcnwf =
- new RemoteCacheNoWaitFacade<K, V>(noWaits, rca, cacheEventLogger, elementSerializer, this );
+ new RemoteCacheNoWaitFacade<>(noWaits, rca, cacheEventLogger, elementSerializer, this );
return rcnwf;
}
@@ -233,7 +233,7 @@
{
super.initialize();
- managers = new ConcurrentHashMap<RemoteLocation, RemoteCacheManager>();
+ managers = new ConcurrentHashMap<>();
managerLock = new ReentrantLock();
monitor = new RemoteCacheMonitor();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
index 90a9e79..d3960c4 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheManager.java
@@ -54,7 +54,7 @@
/** Contains instances of RemoteCacheNoWait managed by a RemoteCacheManager instance. */
private final ConcurrentMap<String, RemoteCacheNoWait<?, ?>> caches =
- new ConcurrentHashMap<String, RemoteCacheNoWait<?, ?>>();
+ new ConcurrentHashMap<>();
/** The event logger. */
private final ICacheEventLogger cacheEventLogger;
@@ -151,7 +151,7 @@
// Failed to connect to the remote server.
// Configure this RemoteCacheManager instance to use the "zombie"
// services.
- this.remoteService = new ZombieCacheServiceNonLocal<String, String>();
+ this.remoteService = new ZombieCacheServiceNonLocal<>();
remoteWatch.setCacheWatch( new ZombieCacheWatch() );
throw new IOException( "Problem finding server at [" + registry + "]", ex );
}
@@ -268,7 +268,7 @@
RemoteCacheListener<K, V> listener = null;
try
{
- listener = new RemoteCacheListener<K, V>( cattr, cacheMgr, elementSerializer );
+ listener = new RemoteCacheListener<>( cattr, cacheMgr, elementSerializer );
addRemoteCacheListener( cattr, listener );
}
catch ( IOException ioe )
@@ -283,11 +283,11 @@
}
IRemoteCacheClient<K, V> remoteCacheClient =
- new RemoteCache<K, V>( cattr, (ICacheServiceNonLocal<K, V>) remoteService, listener, monitor );
+ new RemoteCache<>( cattr, (ICacheServiceNonLocal<K, V>) remoteService, listener, monitor );
remoteCacheClient.setCacheEventLogger( cacheEventLogger );
remoteCacheClient.setElementSerializer( elementSerializer );
- remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient );
+ remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient );
remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
remoteCacheNoWait.setElementSerializer( elementSerializer );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java
index 3894f4b..d33ad53 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheMonitor.java
@@ -44,7 +44,7 @@
public RemoteCacheMonitor()
{
super("JCS-RemoteCacheMonitor");
- this.managers = new ConcurrentHashMap<RemoteCacheManager, RemoteCacheManager>();
+ this.managers = new ConcurrentHashMap<>();
setIdlePeriod(30000L);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java
index 122dbaa..1721ded 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWait.java
@@ -113,9 +113,9 @@
*/
private ICacheEventQueue<K, V> createCacheEventQueue( IRemoteCacheClient<K, V> client )
{
- CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<K, V>();
+ CacheEventQueueFactory<K, V> factory = new CacheEventQueueFactory<>();
ICacheEventQueue<K, V> ceq = factory.createCacheEventQueue(
- new CacheAdaptor<K, V>( client ),
+ new CacheAdaptor<>( client ),
client.getListenerId(),
client.getCacheName(),
client.getAuxiliaryCacheAttributes().getEventQueuePoolName(),
@@ -282,7 +282,7 @@
throw ex;
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -498,9 +498,9 @@
IStats stats = new Stats();
stats.setTypeName( "Remote Cache No Wait" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<CacheStatus>( "Status", getStatus() ) );
+ elems.add(new StatElement<>( "Status", getStatus() ) );
// get the stats from the cache queue too
IStats cStats = this.remoteCacheClient.getStatistics();
@@ -513,11 +513,11 @@
IStats eqStats = this.cacheEventQueue.getStatistics();
elems.addAll(eqStats.getStatElements());
- elems.add(new StatElement<Integer>( "Get Count", Integer.valueOf(this.getCount) ) );
- elems.add(new StatElement<Integer>( "GetMatching Count", Integer.valueOf(this.getMatchingCount) ) );
- elems.add(new StatElement<Integer>( "GetMultiple Count", Integer.valueOf(this.getMultipleCount) ) );
- elems.add(new StatElement<Integer>( "Remove Count", Integer.valueOf(this.removeCount) ) );
- elems.add(new StatElement<Integer>( "Put Count", Integer.valueOf(this.putCount) ) );
+ elems.add(new StatElement<>( "Get Count", Integer.valueOf(this.getCount) ) );
+ elems.add(new StatElement<>( "GetMatching Count", Integer.valueOf(this.getMatchingCount) ) );
+ elems.add(new StatElement<>( "GetMultiple Count", Integer.valueOf(this.getMultipleCount) ) );
+ elems.add(new StatElement<>( "Remove Count", Integer.valueOf(this.removeCount) ) );
+ elems.add(new StatElement<>( "Put Count", Integer.valueOf(this.putCount) ) );
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
index 3fd4e46..5b7fa04 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
@@ -83,7 +83,7 @@
if ( rcnw.getStatus() == CacheStatus.ERROR )
{
// start failover, primary recovery process
- RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<K, V>( this, this.cacheFactory );
+ RemoteCacheFailoverRunner<K, V> runner = new RemoteCacheFailoverRunner<>( this, this.cacheFactory );
runner.setDaemon( true );
runner.start();
runner.notifyError();
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java
index 54ead3b..1622b8f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCache.java
@@ -82,7 +82,7 @@
logError( cacheName, "", message );
log.error( message, ex );
- setRemoteCacheService( new ZombieCacheServiceNonLocal<K, V>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) );
+ setRemoteCacheService( new ZombieCacheServiceNonLocal<>( getRemoteCacheAttributes().getZombieQueueMaxSize() ) );
monitor.notifyError( this );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
index 67d243e..d8ad200 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheFactory.java
@@ -70,16 +70,16 @@
// TODO, use the configured value.
rca.setRemoteType( RemoteType.LOCAL );
- RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<K, V>( rca, cacheMgr, elementSerializer );
+ RemoteHttpClientListener<K, V> listener = new RemoteHttpClientListener<>( rca, cacheMgr, elementSerializer );
IRemoteHttpCacheClient<K, V> remoteService = createRemoteHttpCacheClientForAttributes(rca);
IRemoteCacheClient<K, V> remoteCacheClient =
- new RemoteHttpCache<K, V>( rca, remoteService, listener, monitor );
+ new RemoteHttpCache<>( rca, remoteService, listener, monitor );
remoteCacheClient.setCacheEventLogger( cacheEventLogger );
remoteCacheClient.setElementSerializer( elementSerializer );
- RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<K, V>( remoteCacheClient );
+ RemoteCacheNoWait<K, V> remoteCacheNoWait = new RemoteCacheNoWait<>( remoteCacheClient );
remoteCacheNoWait.setCacheEventLogger( cacheEventLogger );
remoteCacheNoWait.setElementSerializer( elementSerializer );
@@ -104,7 +104,7 @@
{
log.info( "Creating the default client for " + cattr.getCacheName());
}
- remoteService = new RemoteHttpCacheClient<K, V>( );
+ remoteService = new RemoteHttpCacheClient<>( );
}
remoteService.initialize( cattr );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
index feb1210..6a5a2a7 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheMonitor.java
@@ -49,7 +49,7 @@
{
super("JCS-RemoteHttpCacheMonitor");
this.factory = factory;
- this.remoteHttpCaches = new ConcurrentHashMap<RemoteHttpCache<?, ?>, RemoteHttpCache<?, ?>>();
+ this.remoteHttpCaches = new ConcurrentHashMap<>();
setIdlePeriod(3000L);
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
index dca2e37..4541986 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/AbstractRemoteCacheService.java
@@ -495,7 +495,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<ICacheElement<K, V>>();
+ return new CacheEvent<>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), item.getCacheName(), eventName, ipAddress,
@@ -515,7 +515,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<T>();
+ return new CacheEvent<>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( getEventLogSourceName(), cacheName, eventName, ipAddress, key );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
index 761efe9..10f8e1d 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServlet.java
@@ -214,7 +214,7 @@
*/
protected RemoteCacheResponse<Object> processRequest( RemoteCacheRequest<Serializable, Serializable> request )
{
- RemoteCacheResponse<Object> response = new RemoteCacheResponse<Object>();
+ RemoteCacheResponse<Object> response = new RemoteCacheResponse<>();
if ( request == null )
{
@@ -239,7 +239,7 @@
remoteCacheService.getMultiple( request.getCacheName(), request.getKeySet(), request.getRequesterId() );
if ( elementMap != null )
{
- Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<Serializable, ICacheElement<Serializable, Serializable>>();
+ Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<>();
map.putAll(elementMap);
response.setPayload(map);
}
@@ -249,7 +249,7 @@
remoteCacheService.getMatching( request.getCacheName(), request.getPattern(), request.getRequesterId() );
if ( elementMapMatching != null )
{
- Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<Serializable, ICacheElement<Serializable, Serializable>>();
+ Map<Serializable, ICacheElement<Serializable, Serializable>> map = new HashMap<>();
map.putAll(elementMapMatching);
response.setPayload(map);
}
@@ -304,7 +304,7 @@
ICacheEventLogger cacheEventLogger = configureCacheEventLogger( props );
RemoteHttpCacheServerAttributes attributes = configureRemoteHttpCacheServerAttributes( props );
- RemoteHttpCacheService<K, V> service = new RemoteHttpCacheService<K, V>( cacheManager, attributes, cacheEventLogger );
+ RemoteHttpCacheService<K, V> service = new RemoteHttpCacheService<>( cacheManager, attributes, cacheEventLogger );
if ( log.isInfoEnabled() )
{
log.info( "Created new RemoteHttpCacheService " + service );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
index b1a241a..829b4e2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServer.java
@@ -86,20 +86,20 @@
/** Maps cache name to CacheListeners object. association of listeners (regions). */
private final transient ConcurrentMap<String, CacheListeners<K, V>> cacheListenersMap =
- new ConcurrentHashMap<String, CacheListeners<K, V>>();
+ new ConcurrentHashMap<>();
/** maps cluster listeners to regions. */
private final transient ConcurrentMap<String, CacheListeners<K, V>> clusterListenersMap =
- new ConcurrentHashMap<String, CacheListeners<K, V>>();
+ new ConcurrentHashMap<>();
/** The central hub */
private transient CompositeCacheManager cacheManager;
/** relates listener id with a type */
- private final ConcurrentMap<Long, RemoteType> idTypeMap = new ConcurrentHashMap<Long, RemoteType>();
+ private final ConcurrentMap<Long, RemoteType> idTypeMap = new ConcurrentHashMap<>();
/** relates listener id with an ip address */
- private final ConcurrentMap<Long, String> idIPMap = new ConcurrentHashMap<Long, String>();
+ private final ConcurrentMap<Long, String> idIPMap = new ConcurrentHashMap<>();
/** Used to get the next listener id. */
private final int[] listenerId = new int[1];
@@ -171,7 +171,7 @@
{
String name = list[i];
CompositeCache<K, V> cache = cacheManager.getCache( name );
- cacheListenersMap.put( name, new CacheListeners<K, V>( cache ) );
+ cacheListenersMap.put( name, new CacheListeners<>( cache ) );
}
}
@@ -1152,7 +1152,7 @@
{
CacheListeners<K, V> cacheListeners = cacheListenersMap.computeIfAbsent(cacheName, key -> {
CompositeCache<K, V> cache = cacheManager.getCache(key);
- return new CacheListeners<K, V>( cache );
+ return new CacheListeners<>( cache );
});
return cacheListeners;
@@ -1169,7 +1169,7 @@
{
CacheListeners<K, V> cacheListeners = clusterListenersMap.computeIfAbsent(cacheName, key -> {
CompositeCache<K, V> cache = cacheManager.getCache( cacheName );
- return new CacheListeners<K, V>( cache );
+ return new CacheListeners<>( cache );
});
return cacheListeners;
@@ -1342,7 +1342,7 @@
}
}
- CacheEventQueueFactory<KK, VV> fact = new CacheEventQueueFactory<KK, VV>();
+ CacheEventQueueFactory<KK, VV> fact = new CacheEventQueueFactory<>();
ICacheEventQueue<KK, VV> q = fact.createCacheEventQueue( listener, id, cacheName, remoteCacheServerAttributes
.getEventQueuePoolName(), remoteCacheServerAttributes.getEventQueueType() );
@@ -1594,7 +1594,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<ICacheElement<K, V>>();
+ return new CacheEvent<>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger
@@ -1614,7 +1614,7 @@
{
if ( cacheEventLogger == null )
{
- return new CacheEvent<T>();
+ return new CacheEvent<>();
}
String ipAddress = getExtraInfoForRequesterId( requesterId );
return cacheEventLogger.createICacheEvent( "RemoteCacheServer", cacheName, eventName, ipAddress, key );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
index 60a0fa0..4668772 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
@@ -139,11 +139,11 @@
// CREATE SERVER
if ( customRMISocketFactory != null )
{
- remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa, props, customRMISocketFactory );
+ remoteCacheServer = new RemoteCacheServer<>( rcsa, props, customRMISocketFactory );
}
else
{
- remoteCacheServer = new RemoteCacheServer<Serializable, Serializable>( rcsa, props );
+ remoteCacheServer = new RemoteCacheServer<>( rcsa, props );
}
remoteCacheServer.setCacheEventLogger( cacheEventLogger );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
index fc90ca9..4c09a95 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactory.java
@@ -45,7 +45,7 @@
*/
private static <K, V> RemoteCacheRequest<K, V> createRequest(String cacheName, RemoteRequestType requestType, long requesterId)
{
- RemoteCacheRequest<K, V> request = new RemoteCacheRequest<K, V>();
+ RemoteCacheRequest<K, V> request = new RemoteCacheRequest<>();
request.setCacheName( cacheName );
request.setRequestType( requestType );
request.setRequesterId( requesterId );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueueFactory.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueueFactory.java
index 24b5dc2..12201ec 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueueFactory.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheEventQueueFactory.java
@@ -75,11 +75,11 @@
ICacheEventQueue<K, V> eventQueue = null;
if ( poolType == null || ICacheEventQueue.QueueType.SINGLE == poolType )
{
- eventQueue = new CacheEventQueue<K, V>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry );
+ eventQueue = new CacheEventQueue<>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry );
}
else if ( ICacheEventQueue.QueueType.POOLED == poolType )
{
- eventQueue = new PooledCacheEventQueue<K, V>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry,
+ eventQueue = new PooledCacheEventQueue<>( listener, listenerId, cacheName, maxFailure, waitBeforeRetry,
threadPoolName );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheListeners.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheListeners.java
index 1c10a58..c4e3ba0 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheListeners.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheListeners.java
@@ -17,7 +17,7 @@
/** Map ICacheListener to ICacheEventQueue */
public final ConcurrentMap<Long, ICacheEventQueue<K, V>> eventQMap =
- new ConcurrentHashMap<Long, ICacheEventQueue<K, V>>();
+ new ConcurrentHashMap<>();
/**
* Constructs with the given cache.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheWatchRepairable.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheWatchRepairable.java
index f3acfab..649edf2 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheWatchRepairable.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/CacheWatchRepairable.java
@@ -47,7 +47,7 @@
/** Map of cache regions. */
private final ConcurrentMap<String, Set<ICacheListener<?, ?>>> cacheMap =
- new ConcurrentHashMap<String, Set<ICacheListener<?, ?>>>();
+ new ConcurrentHashMap<>();
/**
* Replaces the underlying cache watch service and re-attaches all existing listeners to the new
@@ -95,7 +95,7 @@
// Record the added cache listener locally, regardless of whether the
// remote add-listener operation succeeds or fails.
Set<ICacheListener<?, ?>> listenerSet = cacheMap.computeIfAbsent(cacheName, key -> {
- return new CopyOnWriteArraySet<ICacheListener<?, ?>>();
+ return new CopyOnWriteArraySet<>();
});
listenerSet.add( obj );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java
index e0dd6b8..053fefc 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ElementAttributes.java
@@ -365,7 +365,7 @@
// lazy here, no concurrency problems expected
if ( this.eventHandlers == null )
{
- this.eventHandlers = new ArrayList<IElementEventHandler>();
+ this.eventHandlers = new ArrayList<>();
}
this.eventHandlers.add( eventHandler );
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
index e4b1089..a602cfa 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/PooledCacheEventQueue.java
@@ -145,15 +145,15 @@
IStats stats = new Stats();
stats.setTypeName( "Pooled Cache Event Queue" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Boolean>( "Working", Boolean.valueOf(isWorking()) ) );
- elems.add(new StatElement<Boolean>( "Empty", Boolean.valueOf(this.isEmpty()) ) );
+ elems.add(new StatElement<>( "Working", Boolean.valueOf(isWorking()) ) );
+ elems.add(new StatElement<>( "Empty", Boolean.valueOf(this.isEmpty()) ) );
if ( queue != null )
{
- elems.add(new StatElement<Integer>( "Queue Size", Integer.valueOf(queue.size()) ) );
- elems.add(new StatElement<Integer>( "Queue Capacity", Integer.valueOf(queue.remainingCapacity()) ) );
+ elems.add(new StatElement<>( "Queue Size", Integer.valueOf(queue.size()) ) );
+ elems.add(new StatElement<>( "Queue Capacity", Integer.valueOf(queue.remainingCapacity()) ) );
}
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java
index 1c8b34c..313c534 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocal.java
@@ -59,7 +59,7 @@
*/
public ZombieCacheServiceNonLocal()
{
- queue = new ConcurrentLinkedQueue<ZombieEvent>();
+ queue = new ConcurrentLinkedQueue<>();
}
/**
@@ -70,7 +70,7 @@
public ZombieCacheServiceNonLocal( int maxQueueSize )
{
this.maxQueueSize = maxQueueSize;
- queue = new ConcurrentLinkedQueue<ZombieEvent>();
+ queue = new ConcurrentLinkedQueue<>();
}
/**
@@ -103,7 +103,7 @@
{
if ( maxQueueSize > 0 )
{
- PutEvent<K, V> event = new PutEvent<K, V>( item, listenerId );
+ PutEvent<K, V> event = new PutEvent<>( item, listenerId );
addQueue( event );
}
// Zombies have no inner life
@@ -121,7 +121,7 @@
{
if ( maxQueueSize > 0 )
{
- RemoveEvent<K> event = new RemoveEvent<K>( cacheName, key, listenerId );
+ RemoveEvent<K> event = new RemoveEvent<>( cacheName, key, listenerId );
addQueue( event );
}
// Zombies have no inner life
@@ -186,7 +186,7 @@
@Override
public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
{
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
index 8f2efda..3447a73 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCache.java
@@ -122,7 +122,7 @@
private IMemoryCache<K, V> memCache;
/** Key matcher used by the getMatching API */
- private IKeyMatcher<K> keyMatcher = new KeyMatcherPatternImpl<K>();
+ private IKeyMatcher<K> keyMatcher = new KeyMatcherPatternImpl<>();
private ScheduledFuture<?> future;
@@ -181,7 +181,7 @@
if (cacheAttr.isUseMemoryShrinker())
{
future = scheduledExecutor.scheduleAtFixedRate(
- new ShrinkerThread<K, V>(this), 0, cacheAttr.getShrinkerIntervalSeconds(),
+ new ShrinkerThread<>(this), 0, cacheAttr.getShrinkerIntervalSeconds(),
TimeUnit.SECONDS);
}
}
@@ -675,7 +675,7 @@
*/
protected Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys, boolean localOnly)
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
if (log.isDebugEnabled())
{
@@ -763,15 +763,15 @@
private Map<K, ICacheElement<K, V>> getMultipleFromAuxiliaryCaches(Set<K> keys, boolean localOnly)
throws IOException
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
- Set<K> remainingKeys = new HashSet<K>(keys);
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
+ Set<K> remainingKeys = new HashSet<>(keys);
for (AuxiliaryCache<K, V> aux : auxCaches)
{
if (aux != null)
{
Map<K, ICacheElement<K, V>> elementsFromAuxiliary =
- new HashMap<K, ICacheElement<K, V>>();
+ new HashMap<>();
CacheType cacheType = aux.getCacheType();
@@ -877,7 +877,7 @@
log.error("Problem encountered getting elements.", e);
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -916,7 +916,7 @@
private Map<K, ICacheElement<K, V>> getMatchingFromAuxiliaryCaches(String pattern, boolean localOnly)
throws IOException
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
for (int i = auxCaches.length - 1; i >= 0; i--)
{
@@ -925,7 +925,7 @@
if (aux != null)
{
Map<K, ICacheElement<K, V>> elementsFromAuxiliary =
- new HashMap<K, ICacheElement<K, V>>();
+ new HashMap<>();
CacheType cacheType = aux.getCacheType();
@@ -1048,7 +1048,7 @@
*/
private Set<K> pruneKeysFound(Set<K> keys, Map<K, ICacheElement<K, V>> foundElements)
{
- Set<K> remainingKeys = new HashSet<K>(keys);
+ Set<K> remainingKeys = new HashSet<>(keys);
remainingKeys.removeAll(foundElements.keySet());
return remainingKeys;
@@ -1073,7 +1073,7 @@
*/
public Set<K> getKeySet(boolean localOnly)
{
- HashSet<K> allKeys = new HashSet<K>();
+ HashSet<K> allKeys = new HashSet<>();
allKeys.addAll(memCache.getKeySet());
for (AuxiliaryCache<K, V> aux : auxCaches)
@@ -1473,16 +1473,16 @@
stats.setRegionName(this.getCacheName());
// store the composite cache stats first
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Long>("HitCountRam", Long.valueOf(getHitCountRam())));
- elems.add(new StatElement<Long>("HitCountAux", Long.valueOf(getHitCountAux())));
+ elems.add(new StatElement<>("HitCountRam", Long.valueOf(getHitCountRam())));
+ elems.add(new StatElement<>("HitCountAux", Long.valueOf(getHitCountAux())));
stats.setStatElements(elems);
// memory + aux, memory is not considered an auxiliary internally
int total = auxCaches.length + 1;
- ArrayList<IStats> auxStats = new ArrayList<IStats>(total);
+ ArrayList<IStats> auxStats = new ArrayList<>(total);
auxStats.add(getMemoryCache().getStatistics());
@@ -1674,7 +1674,7 @@
log.warn("No element event queue available for cache " + getCacheName());
return;
}
- IElementEvent<ICacheElement<K, V>> event = new ElementEvent<ICacheElement<K, V>>(element, eventType);
+ IElementEvent<ICacheElement<K, V>> event = new ElementEvent<>(element, eventType);
for (IElementEventHandler hand : eventHandlers)
{
try
@@ -1712,7 +1712,7 @@
{
log.warn("Failed to init mem cache, using: LRUMemoryCache", e);
- this.memCache = new LRUMemoryCache<K, V>();
+ this.memCache = new LRUMemoryCache<>();
this.memCache.initialize(this);
}
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java
index 453976c..0a0444c 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheConfigurator.java
@@ -121,7 +121,7 @@
*/
protected void parseRegions( Properties props, CompositeCacheManager ccm )
{
- List<String> regionNames = new ArrayList<String>();
+ List<String> regionNames = new ArrayList<>();
for (String key : props.stringPropertyNames() )
{
@@ -225,7 +225,7 @@
if (auxiliaries != null)
{
// Next, create the auxiliaries for the new cache
- List<AuxiliaryCache<K, V>> auxList = new ArrayList<AuxiliaryCache<K, V>>();
+ List<AuxiliaryCache<K, V>> auxList = new ArrayList<>();
if ( log.isDebugEnabled() )
{
@@ -285,7 +285,7 @@
protected <K, V> CompositeCache<K, V> newCache(
ICompositeCacheAttributes cca, IElementAttributes ea)
{
- return new CompositeCache<K, V>( cca, ea );
+ return new CompositeCache<>( cca, ea );
}
/**
@@ -565,7 +565,7 @@
else
{
// use the default standard serializer
- keyMatcher = new KeyMatcherPatternImpl<K>();
+ keyMatcher = new KeyMatcherPatternImpl<>();
if ( log.isInfoEnabled() )
{
log.info( "Using standard key matcher [" + keyMatcher + "] for auxiliary [" + auxPrefix + "]" );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
index 54ed1d2..4013082 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/control/CompositeCacheManager.java
@@ -83,7 +83,7 @@
/** Caches managed by this cache manager */
private final ConcurrentMap<String, ICache<?, ?>> caches =
- new ConcurrentHashMap<String, ICache<?, ?>>();
+ new ConcurrentHashMap<>();
/** Number of clients accessing this cache manager */
private final AtomicInteger clients = new AtomicInteger(0);
@@ -96,15 +96,15 @@
/** Used to keep track of configured auxiliaries */
private final ConcurrentMap<String, AuxiliaryCacheFactory> auxiliaryFactoryRegistry =
- new ConcurrentHashMap<String, AuxiliaryCacheFactory>( );
+ new ConcurrentHashMap<>( );
/** Used to keep track of attributes for auxiliaries. */
private final ConcurrentMap<String, AuxiliaryCacheAttributes> auxiliaryAttributeRegistry =
- new ConcurrentHashMap<String, AuxiliaryCacheAttributes>( );
+ new ConcurrentHashMap<>( );
/** Used to keep track of configured auxiliaries */
private final ConcurrentMap<String, AuxiliaryCache<?, ?>> auxiliaryCaches =
- new ConcurrentHashMap<String, AuxiliaryCache<?, ?>>( );
+ new ConcurrentHashMap<>( );
/** Properties with which this manager was configured. This is exposed for other managers. */
private Properties configurationProperties;
@@ -122,7 +122,7 @@
private static final boolean DEFAULT_FORCE_RECONFIGURATION = false;
/** Stack for those waiting for notification of a shutdown. */
- private final LinkedBlockingDeque<IShutdownObserver> shutdownObservers = new LinkedBlockingDeque<IShutdownObserver>();
+ private final LinkedBlockingDeque<IShutdownObserver> shutdownObservers = new LinkedBlockingDeque<>();
/** The central background scheduler. */
private ScheduledExecutorService scheduledExecutor;
@@ -839,7 +839,7 @@
*/
public ICacheStats[] getStatistics()
{
- ArrayList<ICacheStats> cacheStats = new ArrayList<ICacheStats>();
+ ArrayList<ICacheStats> cacheStats = new ArrayList<>();
for (ICache<?, ?> c : caches.values())
{
CompositeCache<?, ?> cache = (CompositeCache<?, ?>) c;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java
index e38a9c5..4f67cb0 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/logging/CacheEventLoggerDebugLogger.java
@@ -49,7 +49,7 @@
public <T> ICacheEvent<T> createICacheEvent( String source, String region, String eventName,
String optionalDetails, T key )
{
- ICacheEvent<T> event = new CacheEvent<T>();
+ ICacheEvent<T> event = new CacheEvent<>();
event.setSource( source );
event.setRegion( region );
event.setEventName( eventName );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java
index 5f85104..222f504 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractDoubleLinkedListMemoryCache.java
@@ -61,7 +61,7 @@
public void initialize(CompositeCache<K, V> hub)
{
super.initialize(hub);
- list = new DoubleLinkedList<MemoryElementDescriptor<K, V>>();
+ list = new DoubleLinkedList<>();
log.info("initialized MemoryCache for " + getCacheName());
}
@@ -77,7 +77,7 @@
@Override
public ConcurrentMap<K, MemoryElementDescriptor<K, V>> createMap()
{
- return new ConcurrentHashMap<K, MemoryElementDescriptor<K, V>>();
+ return new ConcurrentHashMap<>();
}
/**
@@ -341,7 +341,7 @@
lock.lock();
try
{
- MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>(ce);
+ MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<>(ce);
list.addFirst(me);
if ( log.isDebugEnabled() )
{
@@ -368,7 +368,7 @@
lock.lock();
try
{
- MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<K, V>(ce);
+ MemoryElementDescriptor<K, V> me = new MemoryElementDescriptor<>(ce);
list.addLast(me);
if ( log.isDebugEnabled() )
{
@@ -517,7 +517,7 @@
List<IStatElement<?>> elems = stats.getStatElements();
- elems.add(new StatElement<Integer>("List Size", Integer.valueOf(list.size())));
+ elems.add(new StatElement<>("List Size", Integer.valueOf(list.size())));
return stats;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java
index 0bc69d4..b984756 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/AbstractMemoryCache.java
@@ -135,7 +135,7 @@
element -> element));
}
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -231,13 +231,13 @@
IStats stats = new Stats();
stats.setTypeName( "Abstract Memory Cache" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
stats.setStatElements(elems);
- elems.add(new StatElement<AtomicLong>("Put Count", putCnt));
- elems.add(new StatElement<AtomicLong>("Hit Count", hitCnt));
- elems.add(new StatElement<AtomicLong>("Miss Count", missCnt));
- elems.add(new StatElement<Integer>( "Map Size", Integer.valueOf(getSize()) ) );
+ elems.add(new StatElement<>("Put Count", putCnt));
+ elems.add(new StatElement<>("Hit Count", hitCnt));
+ elems.add(new StatElement<>("Miss Count", missCnt));
+ elems.add(new StatElement<>( "Map Size", Integer.valueOf(getSize()) ) );
return stats;
}
@@ -457,7 +457,7 @@
@Override
public Set<K> getKeySet()
{
- return new LinkedHashSet<K>(map.keySet());
+ return new LinkedHashSet<>(map.keySet());
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java
index 2f90285..4221b99 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCache.java
@@ -74,7 +74,7 @@
throws IOException
{
putCnt.incrementAndGet();
- map.put( ce.getKey(), new MemoryElementDescriptor<K, V>(ce) );
+ map.put( ce.getKey(), new MemoryElementDescriptor<>(ce) );
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCache.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCache.java
index b5c703b..f471995 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCache.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCache.java
@@ -74,7 +74,7 @@
public synchronized void initialize( CompositeCache<K, V> hub )
{
super.initialize( hub );
- strongReferences = new LinkedBlockingQueue<ICacheElement<K, V>>();
+ strongReferences = new LinkedBlockingQueue<>();
log.info( "initialized Soft Reference Memory Cache for " + getCacheName() );
}
@@ -84,7 +84,7 @@
@Override
public ConcurrentMap<K, MemoryElementDescriptor<K, V>> createMap()
{
- return new ConcurrentHashMap<K, MemoryElementDescriptor<K, V>>();
+ return new ConcurrentHashMap<>();
}
/**
@@ -93,7 +93,7 @@
@Override
public Set<K> getKeySet()
{
- Set<K> keys = new HashSet<K>();
+ Set<K> keys = new HashSet<>();
for (Map.Entry<K, MemoryElementDescriptor<K, V>> e : map.entrySet())
{
SoftReferenceElementDescriptor<K, V> sred = (SoftReferenceElementDescriptor<K, V>) e.getValue();
@@ -137,8 +137,8 @@
List<IStatElement<?>> elems = stats.getStatElements();
int emptyrefs = map.size() - getSize();
- elems.add(new StatElement<Integer>("Empty References", Integer.valueOf(emptyrefs)));
- elems.add(new StatElement<Integer>("Strong References", Integer.valueOf(strongReferences.size())));
+ elems.add(new StatElement<>("Empty References", Integer.valueOf(emptyrefs)));
+ elems.add(new StatElement<>("Strong References", Integer.valueOf(strongReferences.size())));
return stats;
}
@@ -198,7 +198,7 @@
try
{
- map.put(ce.getKey(), new SoftReferenceElementDescriptor<K, V>(ce));
+ map.put(ce.getKey(), new SoftReferenceElementDescriptor<>(ce));
strongReferences.add(ce);
trimStrongReferences();
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/SoftReferenceElementDescriptor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/SoftReferenceElementDescriptor.java
index 32050e7..89edf02 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/SoftReferenceElementDescriptor.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/SoftReferenceElementDescriptor.java
@@ -43,7 +43,7 @@
public SoftReferenceElementDescriptor( ICacheElement<K, V> ce )
{
super( null );
- this.srce = new SoftReference<ICacheElement<K, V>>(ce);
+ this.srce = new SoftReference<>(ce);
}
/**
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/access/JCSWorker.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/access/JCSWorker.java
index 12395ab..58d5a6a 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/access/JCSWorker.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/access/JCSWorker.java
@@ -105,7 +105,7 @@
/**
* Map to hold who's doing work presently.
*/
- private volatile ConcurrentMap<String, JCSWorkerHelper<V>> map = new ConcurrentHashMap<String, JCSWorkerHelper<V>>();
+ private volatile ConcurrentMap<String, JCSWorkerHelper<V>> map = new ConcurrentHashMap<>();
/**
* Region for the JCS cache.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java
index d000f20..fc06fd0 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPCleanupRunner.java
@@ -72,7 +72,7 @@
// html
// TODO this should get a copy. you can't simply remove from this.
// the listeners need to be notified.
- Set<DiscoveredService> toRemove = new HashSet<DiscoveredService>();
+ Set<DiscoveredService> toRemove = new HashSet<>();
// can't remove via the iterator. must remove directly
for (DiscoveredService service : discoveryService.getDiscoveredServices())
{
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryManager.java
index 79300fa..9042923 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryManager.java
@@ -42,7 +42,7 @@
private static UDPDiscoveryManager INSTANCE = new UDPDiscoveryManager();
/** Known services */
- private final Map<String, UDPDiscoveryService> services = new HashMap<String, UDPDiscoveryService>();
+ private final Map<String, UDPDiscoveryService> services = new HashMap<>();
/** private for singleton */
private UDPDiscoveryManager()
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryMessage.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryMessage.java
index efe424c..b71e6e0 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryMessage.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryMessage.java
@@ -63,7 +63,7 @@
private long requesterId;
/** Names of regions */
- private ArrayList<String> cacheNames = new ArrayList<String>();
+ private ArrayList<String> cacheNames = new ArrayList<>();
/**
* @param port The port to set.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
index 8a3ab80..ba56cd9 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderThread.java
@@ -40,7 +40,7 @@
private final UDPDiscoveryAttributes attributes;
/** List of known regions. */
- private ArrayList<String> cacheNames = new ArrayList<String>();
+ private ArrayList<String> cacheNames = new ArrayList<>();
/**
* @param cacheNames The cacheNames to set.
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
index 15b635f..a8a364b 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryService.java
@@ -66,13 +66,13 @@
private boolean shutdown = false;
/** This is a set of services that have been discovered. */
- private Set<DiscoveredService> discoveredServices = new CopyOnWriteArraySet<DiscoveredService>();
+ private Set<DiscoveredService> discoveredServices = new CopyOnWriteArraySet<>();
/** This a list of regions that are configured to use discovery. */
- private final Set<String> cacheNames = new CopyOnWriteArraySet<String>();
+ private final Set<String> cacheNames = new CopyOnWriteArraySet<>();
/** Set of listeners. */
- private final Set<IDiscoveryListener> discoveryListeners = new CopyOnWriteArraySet<IDiscoveryListener>();
+ private final Set<IDiscoveryListener> discoveryListeners = new CopyOnWriteArraySet<>();
/**
* @param attributes
@@ -274,7 +274,7 @@
*/
protected ArrayList<String> getCacheNames()
{
- ArrayList<String> names = new ArrayList<String>();
+ ArrayList<String> names = new ArrayList<>();
names.addAll( cacheNames );
return names;
}
@@ -378,7 +378,7 @@
*/
public Set<IDiscoveryListener> getCopyOfDiscoveryListeners()
{
- Set<IDiscoveryListener> copy = new HashSet<IDiscoveryListener>();
+ Set<IDiscoveryListener> copy = new HashSet<>();
copy.addAll( getDiscoveryListeners() );
return copy;
}
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java
index 3eb7cb8..6b1f374 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtil.java
@@ -89,7 +89,7 @@
throw new IOException( "Could not serialize object. The ElementSerializer is null." );
}
}
- ICacheElementSerialized<K, V> serialized = new CacheElementSerialized<K, V>(
+ ICacheElementSerialized<K, V> serialized = new CacheElementSerialized<>(
element.getCacheName(), element.getKey(), serializedValue, element.getElementAttributes() );
return serialized;
@@ -142,7 +142,7 @@
// we could just use the default.
log.warn( "ElementSerializer is null. Could not serialize object." );
}
- ICacheElement<K, V> deSerialized = new CacheElement<K, V>( serialized.getCacheName(), serialized.getKey(), deSerializedValue );
+ ICacheElement<K, V> deSerialized = new CacheElement<>( serialized.getCacheName(), serialized.getKey(), deSerializedValue );
deSerialized.setElementAttributes( serialized.getElementAttributes() );
return deSerialized;
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java
index c069a6c..becb4bb 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/struct/AbstractLRUMap.java
@@ -62,11 +62,11 @@
*/
public AbstractLRUMap()
{
- list = new DoubleLinkedList<LRUElementDescriptor<K, V>>();
+ list = new DoubleLinkedList<>();
// normal hashtable is faster for
// sequential keys.
- map = new ConcurrentHashMap<K, LRUElementDescriptor<K, V>>();
+ map = new ConcurrentHashMap<>();
}
@@ -278,7 +278,7 @@
putCnt++;
LRUElementDescriptor<K, V> old = null;
- LRUElementDescriptor<K, V> me = new LRUElementDescriptor<K, V>(key, value);
+ LRUElementDescriptor<K, V> me = new LRUElementDescriptor<>(key, value);
lock.lock();
try
@@ -490,13 +490,13 @@
IStats stats = new Stats();
stats.setTypeName( "LRUMap" );
- ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>();
+ ArrayList<IStatElement<?>> elems = new ArrayList<>();
- elems.add(new StatElement<Integer>( "List Size", Integer.valueOf(list.size()) ) );
- elems.add(new StatElement<Integer>( "Map Size", Integer.valueOf(map.size()) ) );
- elems.add(new StatElement<Long>( "Put Count", Long.valueOf(putCnt) ) );
- elems.add(new StatElement<Long>( "Hit Count", Long.valueOf(hitCnt) ) );
- elems.add(new StatElement<Long>( "Miss Count", Long.valueOf(missCnt) ) );
+ elems.add(new StatElement<>( "List Size", Integer.valueOf(list.size()) ) );
+ elems.add(new StatElement<>( "Map Size", Integer.valueOf(map.size()) ) );
+ elems.add(new StatElement<>( "Put Count", Long.valueOf(putCnt) ) );
+ elems.add(new StatElement<>( "Hit Count", Long.valueOf(hitCnt) ) );
+ elems.add(new StatElement<>( "Miss Count", Long.valueOf(missCnt) ) );
stats.setStatElements( elems );
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManager.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManager.java
index 40ab90c..34c5d1f 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManager.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManager.java
@@ -91,8 +91,8 @@
*/
private ThreadPoolManager()
{
- this.pools = new ConcurrentHashMap<String, ExecutorService>();
- this.schedulerPools = new ConcurrentHashMap<String, ScheduledExecutorService>();
+ this.pools = new ConcurrentHashMap<>();
+ this.schedulerPools = new ConcurrentHashMap<>();
configure();
}
@@ -126,7 +126,7 @@
log.debug( "Creating a Bounded Buffer to use for the pool" );
}
- queue = new LinkedBlockingQueue<Runnable>(config.getBoundarySize());
+ queue = new LinkedBlockingQueue<>(config.getBoundarySize());
}
else
{
@@ -134,7 +134,7 @@
{
log.debug( "Creating a non bounded Linked Queue to use for the pool" );
}
- queue = new LinkedBlockingQueue<Runnable>();
+ queue = new LinkedBlockingQueue<>();
}
ThreadPoolExecutor pool = new ThreadPoolExecutor(
@@ -295,7 +295,7 @@
*/
public ArrayList<String> getPoolNames()
{
- return new ArrayList<String>(pools.keySet());
+ return new ArrayList<>(pools.keySet());
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java
index 7a1d7c2..0775fc0 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSConcurrentCacheAccessUnitTest.java
@@ -37,7 +37,7 @@
*/
public class JCSConcurrentCacheAccessUnitTest extends TestCase
{
- private final static int THREADS = 10;
+ private final static int THREADS = 20;
private final static int LOOPS = 10000;
/**
@@ -67,7 +67,7 @@
JCS.setConfigFilename( "/TestJCS-73.ccf" );
cache = JCS.getGroupCacheInstance( "cache" );
errcount = new AtomicInteger(0);
- valueMismatchList = Collections.synchronizedList(new ArrayList<String>());
+ valueMismatchList = Collections.synchronizedList(new ArrayList<>());
}
@Override
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSThrashTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSThrashTest.java
index 6b2ac3d..9fc85c0 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSThrashTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSThrashTest.java
@@ -169,7 +169,7 @@
jcs.put( key, value );
// Create 15 threads that read the keys;
- final List<Executable> executables = new ArrayList<Executable>();
+ final List<Executable> executables = new ArrayList<>();
for ( int i = 0; i < 15; i++ )
{
final JCSThrashTest.Executable executable = new JCSThrashTest.Executable()
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSUnitTest.java
index e945da4..9bf1c31 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSUnitTest.java
@@ -82,7 +82,7 @@
*/
private LinkedList<HashMap<String, String>> buildList()
{
- LinkedList<HashMap<String, String>> list = new LinkedList<HashMap<String,String>>();
+ LinkedList<HashMap<String, String>> list = new LinkedList<>();
for ( int i = 0; i < 100; i++ )
{
@@ -97,7 +97,7 @@
*/
private HashMap<String, String> buildMap()
{
- HashMap<String, String> map = new HashMap<String, String>();
+ HashMap<String, String> map = new HashMap<>();
byte[] keyBytes = new byte[32];
byte[] valBytes = new byte[128];
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSvsHashtablePerformanceTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSvsHashtablePerformanceTest.java
index ee600ab..aab6627 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSvsHashtablePerformanceTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/JCSvsHashtablePerformanceTest.java
@@ -144,7 +144,7 @@
// /////////////////////////////////////////////////////////////
name = "Hashtable";
- Hashtable<String, String> cache2 = new Hashtable<String, String>();
+ Hashtable<String, String> cache2 = new Hashtable<>();
start = System.currentTimeMillis();
for ( int i = 0; i < tries; i++ )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java
index 7e5b30a..2a508c1 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/access/CacheAccessUnitTest.java
@@ -177,7 +177,7 @@
access.put( keyTwo, valueTwo );
access.put( keyThree, valueThree );
- Set<String> input = new HashSet<String>();
+ Set<String> input = new HashSet<>();
input.add( keyOne );
input.add( keyTwo );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java
index eee805e..f17d430 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCache.java
@@ -80,7 +80,7 @@
throws IOException
{
getMatchingCallCount++;
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -93,7 +93,7 @@
@Override
public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
{
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java
index 2ae7c4f..26677e4 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockAuxiliaryCacheFactory.java
@@ -44,7 +44,7 @@
createCache( AuxiliaryCacheAttributes attr, ICompositeCacheManager cacheMgr,
ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer )
{
- MockAuxiliaryCache<K, V> auxCache = new MockAuxiliaryCache<K, V>();
+ MockAuxiliaryCache<K, V> auxCache = new MockAuxiliaryCache<>();
auxCache.setCacheEventLogger( cacheEventLogger );
auxCache.setElementSerializer( elementSerializer );
return auxCache;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java
index 562e33a..e049ca0 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/MockCacheEventLogger.java
@@ -46,7 +46,7 @@
public int errorEventCalls = 0;
/** list of messages */
- public List<String> errorMessages = new ArrayList<String>();
+ public List<String> errorMessages = new ArrayList<>();
/**
* @param source
@@ -93,6 +93,6 @@
String eventName, String optionalDetails, T key )
{
startICacheEventCalls++;
- return new CacheEvent<T>();
+ return new CacheEvent<>();
}
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java
index efc9791..14f6445 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/AbstractDiskCacheUnitTest.java
@@ -56,12 +56,12 @@
IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
diskCacheAttributes.setCacheName( cacheName );
- AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
+ AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<>( diskCacheAttributes );
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
diskCache.update( cacheElement );
@@ -86,12 +86,12 @@
IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
diskCacheAttributes.setCacheName( cacheName );
- AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
+ AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<>( diskCacheAttributes );
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
diskCache.update( cacheElement );
@@ -118,13 +118,13 @@
IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
diskCacheAttributes.setAllowRemoveAll( false );
- AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
+ AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<>( diskCacheAttributes );
String cacheName = "testRemoveAll_notAllowed";
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
diskCache.update( cacheElement );
@@ -149,13 +149,13 @@
IDiskCacheAttributes diskCacheAttributes = new IndexedDiskCacheAttributes();
diskCacheAttributes.setAllowRemoveAll( true );
- AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<String, String>( diskCacheAttributes );
+ AbstractDiskCacheTestInstance<String, String> diskCache = new AbstractDiskCacheTestInstance<>( diskCacheAttributes );
String cacheName = "testRemoveAll_allowed";
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
diskCache.update( cacheElement );
@@ -171,7 +171,7 @@
extends AbstractDiskCache<K, V>
{
/** Internal map */
- protected Map<K, ICacheElement<K, V>> map = new HashMap<K, ICacheElement<K, V>>();
+ protected Map<K, ICacheElement<K, V>> map = new HashMap<>();
/** used by the abstract aux class */
protected IDiskCacheAttributes diskCacheAttributes;
@@ -207,7 +207,7 @@
@Override
public Set<K> getKeySet() throws IOException
{
- return new HashSet<K>(map.keySet());
+ return new HashSet<>(map.keySet());
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElementUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElementUnitTest.java
index 55f41d8..5b937d2 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElementUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/PurgatoryElementUnitTest.java
@@ -37,8 +37,8 @@
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
- PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
+ PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<>( cacheElement );
purgatoryElement.setSpoolable( false );
// DO WORK
@@ -57,8 +57,8 @@
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value );
- PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value );
+ PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<>( cacheElement );
purgatoryElement.setElementAttributes( elementAttributes );
// DO WORK
@@ -76,8 +76,8 @@
String key = "myKey";
String value = "myValue";
IElementAttributes elementAttributes = new ElementAttributes();
- ICacheElement<String, String> cacheElement = new CacheElement<String, String>( cacheName, key, value, elementAttributes );
- PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<String, String>( cacheElement );
+ ICacheElement<String, String> cacheElement = new CacheElement<>( cacheName, key, value, elementAttributes );
+ PurgatoryElement<String, String> purgatoryElement = new PurgatoryElement<>( cacheElement );
// DO WORK
String result = purgatoryElement.toString();
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
index 05969cf..1a4f4dc 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheConcurrentUnitTest.java
@@ -164,7 +164,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
@@ -225,7 +225,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = start; i <= end; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheKeyStoreUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheKeyStoreUnitTest.java
index a6d5f70..8e3da94 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheKeyStoreUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheKeyStoreUnitTest.java
@@ -70,8 +70,8 @@
private void innerTestPutKeys(BlockDiskCacheAttributes attributes)
{
- BlockDiskCache<String, String> blockDiskCache = new BlockDiskCache<String, String>(attributes);
- BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>(attributes, blockDiskCache);
+ BlockDiskCache<String, String> blockDiskCache = new BlockDiskCache<>(attributes);
+ BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<>(attributes, blockDiskCache);
// DO WORK
int numElements = 100;
@@ -125,7 +125,7 @@
private void testSaveLoadKeysInner(BlockDiskCacheAttributes attributes)
{
- BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>(attributes, null);
+ BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<>(attributes, null);
// DO WORK
int numElements = 1000;
@@ -180,7 +180,7 @@
attributes.setDiskLimitType(DiskLimitType.SIZE);
@SuppressWarnings({ "unchecked", "rawtypes" })
- BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<String>(attributes, new BlockDiskCache(attributes));
+ BlockDiskKeyStore<String> keyStore = new BlockDiskKeyStore<>(attributes, new BlockDiskCache(attributes));
keyStore.put("1", new int[1000]);
keyStore.put("2", new int[1000]);
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java
index ffca43e..1cb9656 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheSameRegionConcurrentUnitTest.java
@@ -155,7 +155,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = start; i <= end; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
index 7de0d2a..5254dbc 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskCacheUnitTestAbstract.java
@@ -1,572 +1,572 @@
-package org.apache.commons.jcs.auxiliary.disk.block;
-
-/*
- * 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.File;
-import java.io.IOException;
-import java.io.Serializable;
-import java.util.Map;
-
-import junit.framework.TestCase;
-
-import org.apache.commons.jcs.engine.CacheElement;
-import org.apache.commons.jcs.engine.ElementAttributes;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.IElementAttributes;
-import org.apache.commons.jcs.engine.control.group.GroupAttrName;
-import org.apache.commons.jcs.engine.control.group.GroupId;
-import org.apache.commons.jcs.utils.serialization.StandardSerializer;
-
-/** Unit tests for the Block Disk Cache */
-public abstract class BlockDiskCacheUnitTestAbstract extends TestCase
-{
- public abstract BlockDiskCacheAttributes getCacheAttributes();
-
- public void testPutGetMatching_SmallWait() throws Exception
- {
- // SETUP
- int items = 200;
-
- String cacheName = "testPutGetMatching_SmallWait";
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr);
-
- // DO WORK
- for (int i = 0; i <= items; i++)
- {
- diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i));
- }
- Thread.sleep(500);
-
- Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
-
- // VERIFY
- assertEquals("Wrong number returned", 10, matchingResults.size());
- // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
- // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
- }
-
- /**
- * Test the basic get matching. With no wait this will all come from purgatory.
- * <p>
- *
- * @throws Exception
- */
- public void testPutGetMatching_NoWait() throws Exception
- {
- // SETUP
- int items = 200;
-
- String cacheName = "testPutGetMatching_NoWait";
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr);
-
- // DO WORK
- for (int i = 0; i <= items; i++)
- {
- diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i));
- }
-
- Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
-
- // VERIFY
- assertEquals("Wrong number returned", 10, matchingResults.size());
- // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
- // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
- }
-
- /**
- * Verify that the block disk cache can handle a big string.
- * <p>
- *
- * @throws Exception
- */
- public void testChunk_BigString() throws Exception
- {
- String string = "This is my big string ABCDEFGH";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append("|" + i + ":" + sb.toString()); // big string
- }
- string = sb.toString();
-
- StandardSerializer elementSerializer = new StandardSerializer();
- byte[] data = elementSerializer.serialize(string);
-
- File file = new File("target/test-sandbox/BlockDiskCacheUnitTest/testChunk_BigString.data");
-
- BlockDisk blockDisk = new BlockDisk(file, 200, elementSerializer);
-
- int numBlocksNeeded = blockDisk.calculateTheNumberOfBlocksNeeded(data);
- // System.out.println( numBlocksNeeded );
-
- // get the individual sub arrays.
- byte[][] chunks = blockDisk.getBlockChunks(data, numBlocksNeeded);
-
- byte[] resultData = new byte[0];
-
- for (short i = 0; i < chunks.length; i++)
- {
- byte[] chunk = chunks[i];
- byte[] newTotal = new byte[data.length + chunk.length];
- // copy data into the new array
- System.arraycopy(data, 0, newTotal, 0, data.length);
- // copy the chunk into the new array
- System.arraycopy(chunk, 0, newTotal, data.length, chunk.length);
- // swap the new and old.
- resultData = newTotal;
- }
-
- Serializable result = elementSerializer.deSerialize(resultData, null);
- // System.out.println( result );
- assertEquals("wrong string after retrieval", string, result);
- }
-
- /**
- * Verify that the block disk cache can handle a big string.
- * <p>
- *
- * @throws Exception
- */
- public void testPutGet_BigString() throws Exception
- {
- String string = "This is my big string ABCDEFGH";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(" " + i + sb.toString()); // big string
- }
- string = sb.toString();
-
- String cacheName = "testPutGet_BigString";
-
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(200);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, String>(cacheName, "x", string));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, String> afterElement = diskCache.get("x");
- assertNotNull(afterElement);
- // System.out.println( "afterElement = " + afterElement );
- String after = afterElement.getVal();
-
- assertNotNull(after);
- assertEquals("wrong string after retrieval", string, after);
- }
-
- /**
- * Verify that the block disk cache can handle utf encoded strings.
- * <p>
- *
- * @throws Exception
- */
- public void testUTF8String() throws Exception
- {
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
-
- // System.out.println( "The string contains " + string.length() + " characters" );
-
- String cacheName = "testUTF8String";
-
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(200);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, String>(cacheName, "x", string));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, String> afterElement = diskCache.get("x");
- assertNotNull(afterElement);
- // System.out.println( "afterElement = " + afterElement );
- String after = afterElement.getVal();
-
- assertNotNull(after);
- assertEquals("wrong string after retrieval", string, after);
- }
-
- /**
- * Verify that the block disk cache can handle utf encoded strings.
- * <p>
- *
- * @throws Exception
- */
- public void testUTF8ByteArray() throws Exception
- {
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
- // System.out.println( "The string contains " + string.length() + " characters" );
- String UTF8 = "UTF-8";
- byte[] bytes = string.getBytes(UTF8);
-
- String cacheName = "testUTF8ByteArray";
-
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(200);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, byte[]> diskCache = new BlockDiskCache<String, byte[]>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, byte[]>(cacheName, "x", bytes));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, byte[]> afterElement = diskCache.get("x");
- assertNotNull(afterElement);
- // System.out.println( "afterElement = " + afterElement );
- byte[] after = afterElement.getVal();
-
- assertNotNull(after);
- assertEquals("wrong bytes after retrieval", bytes.length, after.length);
- // assertEquals( "wrong bytes after retrieval", bytes, after );
- // assertEquals( "wrong bytes after retrieval", string, new String( after, UTF8 ) );
-
- }
-
- /**
- * Verify that the block disk cache can handle utf encoded strings.
- * <p>
- *
- * @throws Exception
- */
- public void testUTF8StringAndBytes() throws Exception
- {
- X before = new X();
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
- // System.out.println( "The string contains " + string.length() + " characters" );
- String UTF8 = "UTF-8";
- before.string = string;
- before.bytes = string.getBytes(UTF8);
-
- String cacheName = "testUTF8StringAndBytes";
-
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(500);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, X> diskCache = new BlockDiskCache<String, X>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, X>(cacheName, "x", before));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, X> afterElement = diskCache.get("x");
- // System.out.println( "afterElement = " + afterElement );
- X after = (afterElement.getVal());
-
- assertNotNull(after);
- assertEquals("wrong string after retrieval", string, after.string);
- assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8));
-
- }
-
- public void testLoadFromDisk() throws Exception
- {
- for (int i = 0; i < 20; i++)
- { // usually after 2 time it fails
- oneLoadFromDisk();
- }
- }
-
- public void testAppendToDisk() throws Exception
- {
- String cacheName = "testAppendToDisk";
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(500);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, X> diskCache = new BlockDiskCache<String, X>(cattr);
- diskCache.removeAll();
- X value1 = new X();
- value1.string = "1234567890";
- X value2 = new X();
- value2.string = "0987654321";
- diskCache.update(new CacheElement<String, X>(cacheName, "1", value1));
- diskCache.dispose();
- diskCache = new BlockDiskCache<String, X>(cattr);
- diskCache.update(new CacheElement<String, X>(cacheName, "2", value2));
- diskCache.dispose();
- diskCache = new BlockDiskCache<String, X>(cattr);
- assertTrue(diskCache.verifyDisk());
- assertEquals(2, diskCache.getKeySet().size());
- assertEquals(value1.string, diskCache.get("1").getVal().string);
- assertEquals(value2.string, diskCache.get("2").getVal().string);
- }
-
- public void oneLoadFromDisk() throws Exception
- {
- // initialize object to be stored
- X before = new X();
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
- String UTF8 = "UTF-8";
- before.string = string;
- before.bytes = string.getBytes(UTF8);
-
- // initialize cache
- String cacheName = "testLoadFromDisk";
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setBlockSizeBytes(500);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, X> diskCache = new BlockDiskCache<String, X>(cattr);
-
- // DO WORK
- for (int i = 0; i < 50; i++)
- {
- diskCache.update(new CacheElement<String, X>(cacheName, "x" + i, before));
- }
- diskCache.dispose();
-
- // VERIFY
- diskCache = new BlockDiskCache<String, X>(cattr);
-
- for (int i = 0; i < 50; i++)
- {
- ICacheElement<String, X> afterElement = diskCache.get("x" + i);
- assertNotNull("Missing element from cache. Cache size: " + diskCache.getSize() + " element: x" + i, afterElement);
- X after = (afterElement.getVal());
-
- assertNotNull(after);
- assertEquals("wrong string after retrieval", string, after.string);
- assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8));
- }
-
- diskCache.dispose();
- }
-
- /**
- * Add some items to the disk cache and then remove them one by one.
- *
- * @throws IOException
- */
- public void testRemoveItems() throws IOException
- {
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemoveItems");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> disk = new BlockDiskCache<String, String>(cattr);
-
- disk.processRemoveAll();
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- ICacheElement<String, String> element = new CacheElement<String, String>("testRemoveItems", "key:" + i, "data:" + i);
- element.setElementAttributes(eAttr);
- disk.processUpdate(element);
- }
-
- // remove each
- for (int i = 0; i < cnt; i++)
- {
- disk.remove("key:" + i);
- ICacheElement<String, String> element = disk.processGet("key:" + i);
- assertNull("Should not have received an element.", element);
- }
- }
-
- /**
- * Add some items to the disk cache and then remove them one by one.
- * <p>
- *
- * @throws IOException
- */
- public void testRemove_PartialKey() throws IOException
- {
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemove_PartialKey");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<String, String> disk = new BlockDiskCache<String, String>(cattr);
-
- disk.processRemoveAll();
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- ICacheElement<String, String> element = new CacheElement<String, String>("testRemove_PartialKey", i + ":key", "data:"
- + i);
- element.setElementAttributes(eAttr);
- disk.processUpdate(element);
- }
-
- // verify each
- for (int i = 0; i < cnt; i++)
- {
- ICacheElement<String, String> element = disk.processGet(i + ":key");
- assertNotNull("Shoulds have received an element.", element);
- }
-
- // remove each
- for (int i = 0; i < cnt; i++)
- {
- disk.remove(i + ":");
- ICacheElement<String, String> element = disk.processGet(i + ":key");
- assertNull("Should not have received an element.", element);
- }
- }
-
-
- /**
- * Verify that group members are removed if we call remove with a group.
- *
- * @throws IOException
- */
- public void testRemove_Group() throws IOException
- {
- // SETUP
- BlockDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemove_Group");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- BlockDiskCache<GroupAttrName<String>, String> disk = new BlockDiskCache<GroupAttrName<String>, String>(cattr);
-
- disk.processRemoveAll();
-
- String cacheName = "testRemove_Group_Region";
- String groupName = "testRemove_Group";
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- CacheElement<GroupAttrName<String>, String> element = new CacheElement<GroupAttrName<String>, String>(cacheName,
- groupAttrName, "data:" + i);
-
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- element.setElementAttributes(eAttr);
-
- disk.processUpdate(element);
- }
-
- // verify each
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
- assertNotNull("Should have received an element.", element);
- }
-
- // DO WORK
- // remove the group
- disk.remove(getGroupAttrName(cacheName, groupName, null));
-
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
-
- // VERIFY
- assertNull("Should not have received an element.", element);
- }
-
- }
-
- /**
- * Internal method used for group functionality.
- * <p>
- *
- * @param cacheName
- * @param group
- * @param name
- * @return GroupAttrName
- */
- private GroupAttrName<String> getGroupAttrName(String cacheName, String group, String name)
- {
- GroupId gid = new GroupId(cacheName, group);
- return new GroupAttrName<String>(gid, name);
- }
-
- /** Holder for a string and byte array. */
- static class X implements Serializable
- {
- /** ignore */
- private static final long serialVersionUID = 1L;
-
- /** Test string */
- String string;
-
- /*** test byte array. */
- byte[] bytes;
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.block;
+
+/*
+ * 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.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.ElementAttributes;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.IElementAttributes;
+import org.apache.commons.jcs.engine.control.group.GroupAttrName;
+import org.apache.commons.jcs.engine.control.group.GroupId;
+import org.apache.commons.jcs.utils.serialization.StandardSerializer;
+
+/** Unit tests for the Block Disk Cache */
+public abstract class BlockDiskCacheUnitTestAbstract extends TestCase
+{
+ public abstract BlockDiskCacheAttributes getCacheAttributes();
+
+ public void testPutGetMatching_SmallWait() throws Exception
+ {
+ // SETUP
+ int items = 200;
+
+ String cacheName = "testPutGetMatching_SmallWait";
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i <= items; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, i + ":key", cacheName + " data " + i));
+ }
+ Thread.sleep(500);
+
+ Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
+
+ // VERIFY
+ assertEquals("Wrong number returned", 10, matchingResults.size());
+ // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+ // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+ }
+
+ /**
+ * Test the basic get matching. With no wait this will all come from purgatory.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testPutGetMatching_NoWait() throws Exception
+ {
+ // SETUP
+ int items = 200;
+
+ String cacheName = "testPutGetMatching_NoWait";
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i <= items; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, i + ":key", cacheName + " data " + i));
+ }
+
+ Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
+
+ // VERIFY
+ assertEquals("Wrong number returned", 10, matchingResults.size());
+ // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+ // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+ }
+
+ /**
+ * Verify that the block disk cache can handle a big string.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testChunk_BigString() throws Exception
+ {
+ String string = "This is my big string ABCDEFGH";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append("|" + i + ":" + sb.toString()); // big string
+ }
+ string = sb.toString();
+
+ StandardSerializer elementSerializer = new StandardSerializer();
+ byte[] data = elementSerializer.serialize(string);
+
+ File file = new File("target/test-sandbox/BlockDiskCacheUnitTest/testChunk_BigString.data");
+
+ BlockDisk blockDisk = new BlockDisk(file, 200, elementSerializer);
+
+ int numBlocksNeeded = blockDisk.calculateTheNumberOfBlocksNeeded(data);
+ // System.out.println( numBlocksNeeded );
+
+ // get the individual sub arrays.
+ byte[][] chunks = blockDisk.getBlockChunks(data, numBlocksNeeded);
+
+ byte[] resultData = new byte[0];
+
+ for (short i = 0; i < chunks.length; i++)
+ {
+ byte[] chunk = chunks[i];
+ byte[] newTotal = new byte[data.length + chunk.length];
+ // copy data into the new array
+ System.arraycopy(data, 0, newTotal, 0, data.length);
+ // copy the chunk into the new array
+ System.arraycopy(chunk, 0, newTotal, data.length, chunk.length);
+ // swap the new and old.
+ resultData = newTotal;
+ }
+
+ Serializable result = elementSerializer.deSerialize(resultData, null);
+ // System.out.println( result );
+ assertEquals("wrong string after retrieval", string, result);
+ }
+
+ /**
+ * Verify that the block disk cache can handle a big string.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testPutGet_BigString() throws Exception
+ {
+ String string = "This is my big string ABCDEFGH";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(" " + i + sb.toString()); // big string
+ }
+ string = sb.toString();
+
+ String cacheName = "testPutGet_BigString";
+
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(200);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", string));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, String> afterElement = diskCache.get("x");
+ assertNotNull(afterElement);
+ // System.out.println( "afterElement = " + afterElement );
+ String after = afterElement.getVal();
+
+ assertNotNull(after);
+ assertEquals("wrong string after retrieval", string, after);
+ }
+
+ /**
+ * Verify that the block disk cache can handle utf encoded strings.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUTF8String() throws Exception
+ {
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+
+ // System.out.println( "The string contains " + string.length() + " characters" );
+
+ String cacheName = "testUTF8String";
+
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(200);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", string));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, String> afterElement = diskCache.get("x");
+ assertNotNull(afterElement);
+ // System.out.println( "afterElement = " + afterElement );
+ String after = afterElement.getVal();
+
+ assertNotNull(after);
+ assertEquals("wrong string after retrieval", string, after);
+ }
+
+ /**
+ * Verify that the block disk cache can handle utf encoded strings.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUTF8ByteArray() throws Exception
+ {
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+ // System.out.println( "The string contains " + string.length() + " characters" );
+ String UTF8 = "UTF-8";
+ byte[] bytes = string.getBytes(UTF8);
+
+ String cacheName = "testUTF8ByteArray";
+
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(200);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, byte[]> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", bytes));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, byte[]> afterElement = diskCache.get("x");
+ assertNotNull(afterElement);
+ // System.out.println( "afterElement = " + afterElement );
+ byte[] after = afterElement.getVal();
+
+ assertNotNull(after);
+ assertEquals("wrong bytes after retrieval", bytes.length, after.length);
+ // assertEquals( "wrong bytes after retrieval", bytes, after );
+ // assertEquals( "wrong bytes after retrieval", string, new String( after, UTF8 ) );
+
+ }
+
+ /**
+ * Verify that the block disk cache can handle utf encoded strings.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUTF8StringAndBytes() throws Exception
+ {
+ X before = new X();
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+ // System.out.println( "The string contains " + string.length() + " characters" );
+ String UTF8 = "UTF-8";
+ before.string = string;
+ before.bytes = string.getBytes(UTF8);
+
+ String cacheName = "testUTF8StringAndBytes";
+
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(500);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, X> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", before));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, X> afterElement = diskCache.get("x");
+ // System.out.println( "afterElement = " + afterElement );
+ X after = (afterElement.getVal());
+
+ assertNotNull(after);
+ assertEquals("wrong string after retrieval", string, after.string);
+ assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8));
+
+ }
+
+ public void testLoadFromDisk() throws Exception
+ {
+ for (int i = 0; i < 20; i++)
+ { // usually after 2 time it fails
+ oneLoadFromDisk();
+ }
+ }
+
+ public void testAppendToDisk() throws Exception
+ {
+ String cacheName = "testAppendToDisk";
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(500);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, X> diskCache = new BlockDiskCache<>(cattr);
+ diskCache.removeAll();
+ X value1 = new X();
+ value1.string = "1234567890";
+ X value2 = new X();
+ value2.string = "0987654321";
+ diskCache.update(new CacheElement<>(cacheName, "1", value1));
+ diskCache.dispose();
+ diskCache = new BlockDiskCache<>(cattr);
+ diskCache.update(new CacheElement<>(cacheName, "2", value2));
+ diskCache.dispose();
+ diskCache = new BlockDiskCache<>(cattr);
+ assertTrue(diskCache.verifyDisk());
+ assertEquals(2, diskCache.getKeySet().size());
+ assertEquals(value1.string, diskCache.get("1").getVal().string);
+ assertEquals(value2.string, diskCache.get("2").getVal().string);
+ }
+
+ public void oneLoadFromDisk() throws Exception
+ {
+ // initialize object to be stored
+ X before = new X();
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+ String UTF8 = "UTF-8";
+ before.string = string;
+ before.bytes = string.getBytes(UTF8);
+
+ // initialize cache
+ String cacheName = "testLoadFromDisk";
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setBlockSizeBytes(500);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, X> diskCache = new BlockDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i < 50; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, "x" + i, before));
+ }
+ diskCache.dispose();
+
+ // VERIFY
+ diskCache = new BlockDiskCache<>(cattr);
+
+ for (int i = 0; i < 50; i++)
+ {
+ ICacheElement<String, X> afterElement = diskCache.get("x" + i);
+ assertNotNull("Missing element from cache. Cache size: " + diskCache.getSize() + " element: x" + i, afterElement);
+ X after = (afterElement.getVal());
+
+ assertNotNull(after);
+ assertEquals("wrong string after retrieval", string, after.string);
+ assertEquals("wrong bytes after retrieval", string, new String(after.bytes, UTF8));
+ }
+
+ diskCache.dispose();
+ }
+
+ /**
+ * Add some items to the disk cache and then remove them one by one.
+ *
+ * @throws IOException
+ */
+ public void testRemoveItems() throws IOException
+ {
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemoveItems");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> disk = new BlockDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ ICacheElement<String, String> element = new CacheElement<>("testRemoveItems", "key:" + i, "data:" + i);
+ element.setElementAttributes(eAttr);
+ disk.processUpdate(element);
+ }
+
+ // remove each
+ for (int i = 0; i < cnt; i++)
+ {
+ disk.remove("key:" + i);
+ ICacheElement<String, String> element = disk.processGet("key:" + i);
+ assertNull("Should not have received an element.", element);
+ }
+ }
+
+ /**
+ * Add some items to the disk cache and then remove them one by one.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testRemove_PartialKey() throws IOException
+ {
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemove_PartialKey");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<String, String> disk = new BlockDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ ICacheElement<String, String> element = new CacheElement<>("testRemove_PartialKey", i + ":key", "data:"
+ + i);
+ element.setElementAttributes(eAttr);
+ disk.processUpdate(element);
+ }
+
+ // verify each
+ for (int i = 0; i < cnt; i++)
+ {
+ ICacheElement<String, String> element = disk.processGet(i + ":key");
+ assertNotNull("Shoulds have received an element.", element);
+ }
+
+ // remove each
+ for (int i = 0; i < cnt; i++)
+ {
+ disk.remove(i + ":");
+ ICacheElement<String, String> element = disk.processGet(i + ":key");
+ assertNull("Should not have received an element.", element);
+ }
+ }
+
+
+ /**
+ * Verify that group members are removed if we call remove with a group.
+ *
+ * @throws IOException
+ */
+ public void testRemove_Group() throws IOException
+ {
+ // SETUP
+ BlockDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemove_Group");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ BlockDiskCache<GroupAttrName<String>, String> disk = new BlockDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ String cacheName = "testRemove_Group_Region";
+ String groupName = "testRemove_Group";
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ CacheElement<GroupAttrName<String>, String> element = new CacheElement<>(cacheName,
+ groupAttrName, "data:" + i);
+
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ element.setElementAttributes(eAttr);
+
+ disk.processUpdate(element);
+ }
+
+ // verify each
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
+ assertNotNull("Should have received an element.", element);
+ }
+
+ // DO WORK
+ // remove the group
+ disk.remove(getGroupAttrName(cacheName, groupName, null));
+
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
+
+ // VERIFY
+ assertNull("Should not have received an element.", element);
+ }
+
+ }
+
+ /**
+ * Internal method used for group functionality.
+ * <p>
+ *
+ * @param cacheName
+ * @param group
+ * @param name
+ * @return GroupAttrName
+ */
+ private GroupAttrName<String> getGroupAttrName(String cacheName, String group, String name)
+ {
+ GroupId gid = new GroupId(cacheName, group);
+ return new GroupAttrName<>(gid, name);
+ }
+
+ /** Holder for a string and byte array. */
+ static class X implements Serializable
+ {
+ /** ignore */
+ private static final long serialVersionUID = 1L;
+
+ /** Test string */
+ String string;
+
+ /*** test byte array. */
+ byte[] bytes;
+ }
+}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java
index 3cab3eb..336b101 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/block/BlockDiskElementDescriptorUnitTest.java
@@ -53,7 +53,7 @@
// DO WORK
for ( int i = 0; i < numElements; i++ )
{
- BlockDiskElementDescriptor<Integer> descriptor = new BlockDiskElementDescriptor<Integer>();
+ BlockDiskElementDescriptor<Integer> descriptor = new BlockDiskElementDescriptor<>();
descriptor.setKey( Integer.valueOf( i ) );
descriptor.setBlocks( new int[] { 1, 2 } );
elements[i] = descriptor;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/DiskTestObjectUtil.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/DiskTestObjectUtil.java
index 3021d1d..eca8864 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/DiskTestObjectUtil.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/DiskTestObjectUtil.java
@@ -109,7 +109,7 @@
int size = bytes * 1024;
DiskTestObject tile = new DiskTestObject( Integer.valueOf( i ), new byte[size] );
- ICacheElement<Integer, DiskTestObject> element = new CacheElement<Integer, DiskTestObject>( cacheName, tile.id, tile );
+ ICacheElement<Integer, DiskTestObject> element = new CacheElement<>( cacheName, tile.id, tile );
elements[i] = element;
}
return elements;
@@ -134,7 +134,7 @@
int size = ( bytes + 4 ) * 1024;
DiskTestObject tile = new DiskTestObject( Integer.valueOf( i ), new byte[size] );
- ICacheElement<Integer, DiskTestObject> element = new CacheElement<Integer, DiskTestObject>( cacheName, tile.id, tile );
+ ICacheElement<Integer, DiskTestObject> element = new CacheElement<>( cacheName, tile.id, tile );
elements[i] = element;
}
return elements;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheCountUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheCountUnitTest.java
index db9ae10..ef8eea3 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheCountUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheCountUnitTest.java
@@ -1,109 +1,109 @@
-package org.apache.commons.jcs.auxiliary.disk.indexed;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.commons.jcs.auxiliary.disk.behavior.IDiskCacheAttributes.DiskLimitType;
-import org.apache.commons.jcs.engine.CacheElement;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-
-public class IndexDiskCacheCountUnitTest extends IndexDiskCacheUnitTestAbstract {
-
- @Override
- public IndexedDiskCacheAttributes getCacheAttributes() {
- IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes();
- ret.setDiskLimitType(DiskLimitType.COUNT);
- return ret;
- }
- public void testRecycleBin()
- throws IOException
- {
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName( "testRemoveItems" );
- cattr.setOptimizeAtRemoveCount( 7 );
- cattr.setMaxKeySize( 5 );
- cattr.setMaxPurgatorySize( 0 );
- cattr.setDiskPath( "target/test-sandbox/BreakIndexTest" );
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr );
-
- String[] test = { "a", "bb", "ccc", "dddd", "eeeee", "ffffff", "ggggggg", "hhhhhhhhh", "iiiiiiiiii" };
- String[] expect = { null, "bb", "ccc", null, null, "ffffff", null, "hhhhhhhhh", "iiiiiiiiii" };
-
- //System.out.println( "------------------------- testRecycleBin " );
-
- for ( int i = 0; i < 6; i++ )
- {
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRecycleBin", "key:" + test[i], test[i] );
- //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
- disk.processUpdate( element );
- }
-
- for ( int i = 3; i < 5; i++ )
- {
- //System.out.println( "About to remove " + "key:" + test[i] + " i = " + i );
- disk.remove( "key:" + test[i] );
- }
-
- // there was a bug where 7 would try to be put in the empty slot left by 4's removal, but it
- // will not fit.
- for ( int i = 7; i < 9; i++ )
- {
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRecycleBin", "key:" + test[i], test[i] );
- //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
- disk.processUpdate( element );
- }
-
- try
- {
- for ( int i = 0; i < 9; i++ )
- {
- ICacheElement<String, String> element = disk.get( "key:" + test[i] );
- if ( element != null )
- {
- //System.out.println( "element = " + element.getVal() );
- }
- else
- {
- //System.out.println( "null --" + "key:" + test[i] );
- }
-
- String expectedValue = expect[i];
- if ( expectedValue == null )
- {
- assertNull( "Expected a null element", element );
- }
- else
- {
- assertNotNull( "The element for key [" + "key:" + test[i] + "] should not be null. i = " + i,
- element );
- assertEquals( "Elements contents do not match expected", element.getVal(), expectedValue );
- }
- }
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- fail( "Should not get an exception: " + e.toString() );
- }
-
- disk.removeAll();
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.indexed;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.commons.jcs.auxiliary.disk.behavior.IDiskCacheAttributes.DiskLimitType;
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+
+public class IndexDiskCacheCountUnitTest extends IndexDiskCacheUnitTestAbstract {
+
+ @Override
+ public IndexedDiskCacheAttributes getCacheAttributes() {
+ IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes();
+ ret.setDiskLimitType(DiskLimitType.COUNT);
+ return ret;
+ }
+ public void testRecycleBin()
+ throws IOException
+ {
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName( "testRemoveItems" );
+ cattr.setOptimizeAtRemoveCount( 7 );
+ cattr.setMaxKeySize( 5 );
+ cattr.setMaxPurgatorySize( 0 );
+ cattr.setDiskPath( "target/test-sandbox/BreakIndexTest" );
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>( cattr );
+
+ String[] test = { "a", "bb", "ccc", "dddd", "eeeee", "ffffff", "ggggggg", "hhhhhhhhh", "iiiiiiiiii" };
+ String[] expect = { null, "bb", "ccc", null, null, "ffffff", null, "hhhhhhhhh", "iiiiiiiiii" };
+
+ //System.out.println( "------------------------- testRecycleBin " );
+
+ for ( int i = 0; i < 6; i++ )
+ {
+ ICacheElement<String, String> element = new CacheElement<>( "testRecycleBin", "key:" + test[i], test[i] );
+ //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
+ disk.processUpdate( element );
+ }
+
+ for ( int i = 3; i < 5; i++ )
+ {
+ //System.out.println( "About to remove " + "key:" + test[i] + " i = " + i );
+ disk.remove( "key:" + test[i] );
+ }
+
+ // there was a bug where 7 would try to be put in the empty slot left by 4's removal, but it
+ // will not fit.
+ for ( int i = 7; i < 9; i++ )
+ {
+ ICacheElement<String, String> element = new CacheElement<>( "testRecycleBin", "key:" + test[i], test[i] );
+ //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
+ disk.processUpdate( element );
+ }
+
+ try
+ {
+ for ( int i = 0; i < 9; i++ )
+ {
+ ICacheElement<String, String> element = disk.get( "key:" + test[i] );
+ if ( element != null )
+ {
+ //System.out.println( "element = " + element.getVal() );
+ }
+ else
+ {
+ //System.out.println( "null --" + "key:" + test[i] );
+ }
+
+ String expectedValue = expect[i];
+ if ( expectedValue == null )
+ {
+ assertNull( "Expected a null element", element );
+ }
+ else
+ {
+ assertNotNull( "The element for key [" + "key:" + test[i] + "] should not be null. i = " + i,
+ element );
+ assertEquals( "Elements contents do not match expected", element.getVal(), expectedValue );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "Should not get an exception: " + e.toString() );
+ }
+
+ disk.removeAll();
+ }
+}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
index 66975c6..1a3456b 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheSizeUnitTest.java
@@ -1,110 +1,110 @@
-package org.apache.commons.jcs.auxiliary.disk.indexed;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-
-import org.apache.commons.jcs.auxiliary.disk.DiskTestObject;
-import org.apache.commons.jcs.auxiliary.disk.behavior.IDiskCacheAttributes.DiskLimitType;
-import org.apache.commons.jcs.engine.CacheElement;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-
-public class IndexDiskCacheSizeUnitTest extends IndexDiskCacheUnitTestAbstract {
-
- @Override
- public IndexedDiskCacheAttributes getCacheAttributes() {
- IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes();
- ret.setDiskLimitType(DiskLimitType.SIZE);
- return ret;
- }
- public void testRecycleBin()
- throws IOException
- {
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName( "testRemoveItems" );
- cattr.setOptimizeAtRemoveCount( 7 );
- cattr.setMaxKeySize( 8); // 1kb DiskTestObject takes 1420 bytes, so 5*1420 = 7100, so to keep 5 ojbects, we need max key size of 8
- cattr.setMaxPurgatorySize( 0 );
- cattr.setDiskPath( "target/test-sandbox/BreakIndexTest" );
- IndexedDiskCache<String, DiskTestObject> disk = new IndexedDiskCache<String, DiskTestObject>( cattr );
-
- String[] test = { "a", "bb", "ccc", "dddd", "eeeee", "ffffff", "ggggggg", "hhhhhhhhh", "iiiiiiiiii" };
- String[] expect = { null, "bb", "ccc", null, null, "ffffff", null, "hhhhhhhhh", "iiiiiiiiii" };
- DiskTestObject value = DiskTestObjectUtil.createCacheElementsWithTestObjects( 1, 1, cattr .getCacheName())[0].getVal();
- //System.out.println( "------------------------- testRecycleBin " );
-
- for ( int i = 0; i < 6; i++ )
- {
- ICacheElement<String, DiskTestObject> element = new CacheElement<String, DiskTestObject>( "testRecycleBin", "key:" + test[i], value);
- //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
- disk.processUpdate( element );
- }
-
- for ( int i = 3; i < 5; i++ )
- {
- //System.out.println( "About to remove " + "key:" + test[i] + " i = " + i );
- disk.remove( "key:" + test[i] );
- }
-
- // there was a bug where 7 would try to be put in the empty slot left by 4's removal, but it
- // will not fit.
- for ( int i = 7; i < 9; i++ )
- {
- ICacheElement<String, DiskTestObject> element = new CacheElement<String, DiskTestObject>( "testRecycleBin", "key:" + test[i], value);
- //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
- disk.processUpdate( element );
- }
-
- try
- {
- for ( int i = 0; i < 9; i++ )
- {
- ICacheElement<String, DiskTestObject> element = disk.get( "key:" + test[i] );
- if ( element != null )
- {
- //System.out.println( "element = " + element.getVal() );
- }
- else
- {
- //System.out.println( "null --" + "key:" + test[i] );
- }
-
- String expectedValue = expect[i];
- if ( expectedValue == null )
- {
- assertNull( "Expected a null element", element );
- }
- else
- {
- assertNotNull( "The element for key [" + "key:" + test[i] + "] should not be null. i = " + i,
- element );
- assertEquals( "Elements contents do not match expected", element.getVal(), value );
- }
- }
- }
- catch ( Exception e )
- {
- e.printStackTrace();
- fail( "Should not get an exception: " + e.toString() );
- }
-
- disk.removeAll();
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.indexed;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+
+import org.apache.commons.jcs.auxiliary.disk.DiskTestObject;
+import org.apache.commons.jcs.auxiliary.disk.behavior.IDiskCacheAttributes.DiskLimitType;
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+
+public class IndexDiskCacheSizeUnitTest extends IndexDiskCacheUnitTestAbstract {
+
+ @Override
+ public IndexedDiskCacheAttributes getCacheAttributes() {
+ IndexedDiskCacheAttributes ret = new IndexedDiskCacheAttributes();
+ ret.setDiskLimitType(DiskLimitType.SIZE);
+ return ret;
+ }
+ public void testRecycleBin()
+ throws IOException
+ {
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName( "testRemoveItems" );
+ cattr.setOptimizeAtRemoveCount( 7 );
+ cattr.setMaxKeySize( 8); // 1kb DiskTestObject takes 1420 bytes, so 5*1420 = 7100, so to keep 5 ojbects, we need max key size of 8
+ cattr.setMaxPurgatorySize( 0 );
+ cattr.setDiskPath( "target/test-sandbox/BreakIndexTest" );
+ IndexedDiskCache<String, DiskTestObject> disk = new IndexedDiskCache<>( cattr );
+
+ String[] test = { "a", "bb", "ccc", "dddd", "eeeee", "ffffff", "ggggggg", "hhhhhhhhh", "iiiiiiiiii" };
+ String[] expect = { null, "bb", "ccc", null, null, "ffffff", null, "hhhhhhhhh", "iiiiiiiiii" };
+ DiskTestObject value = DiskTestObjectUtil.createCacheElementsWithTestObjects( 1, 1, cattr .getCacheName())[0].getVal();
+ //System.out.println( "------------------------- testRecycleBin " );
+
+ for ( int i = 0; i < 6; i++ )
+ {
+ ICacheElement<String, DiskTestObject> element = new CacheElement<>( "testRecycleBin", "key:" + test[i], value);
+ //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
+ disk.processUpdate( element );
+ }
+
+ for ( int i = 3; i < 5; i++ )
+ {
+ //System.out.println( "About to remove " + "key:" + test[i] + " i = " + i );
+ disk.remove( "key:" + test[i] );
+ }
+
+ // there was a bug where 7 would try to be put in the empty slot left by 4's removal, but it
+ // will not fit.
+ for ( int i = 7; i < 9; i++ )
+ {
+ ICacheElement<String, DiskTestObject> element = new CacheElement<>( "testRecycleBin", "key:" + test[i], value);
+ //System.out.println( "About to add " + "key:" + test[i] + " i = " + i );
+ disk.processUpdate( element );
+ }
+
+ try
+ {
+ for ( int i = 0; i < 9; i++ )
+ {
+ ICacheElement<String, DiskTestObject> element = disk.get( "key:" + test[i] );
+ if ( element != null )
+ {
+ //System.out.println( "element = " + element.getVal() );
+ }
+ else
+ {
+ //System.out.println( "null --" + "key:" + test[i] );
+ }
+
+ String expectedValue = expect[i];
+ if ( expectedValue == null )
+ {
+ assertNull( "Expected a null element", element );
+ }
+ else
+ {
+ assertNotNull( "The element for key [" + "key:" + test[i] + "] should not be null. i = " + i,
+ element );
+ assertEquals( "Elements contents do not match expected", element.getVal(), value );
+ }
+ }
+ }
+ catch ( Exception e )
+ {
+ e.printStackTrace();
+ fail( "Should not get an exception: " + e.toString() );
+ }
+
+ disk.removeAll();
+ }
+}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
index f6fc6df..da4f5b3 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexDiskCacheUnitTestAbstract.java
@@ -1,989 +1,989 @@
-package org.apache.commons.jcs.auxiliary.disk.indexed;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.io.IOException;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.commons.jcs.auxiliary.MockCacheEventLogger;
-import org.apache.commons.jcs.auxiliary.disk.DiskTestObject;
-import org.apache.commons.jcs.engine.CacheElement;
-import org.apache.commons.jcs.engine.ElementAttributes;
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.IElementAttributes;
-import org.apache.commons.jcs.engine.control.group.GroupAttrName;
-import org.apache.commons.jcs.engine.control.group.GroupId;
-import org.apache.commons.jcs.utils.timing.SleepUtil;
-
-import junit.framework.TestCase;
-
-/**
- * Tests for common functionality.
- * <p>
- *
- * @author Aaron Smuts
- */
-public abstract class IndexDiskCacheUnitTestAbstract extends TestCase
-{
- public abstract IndexedDiskCacheAttributes getCacheAttributes();
-
- /**
- * Simply verify that we can put items in the disk cache and retrieve them.
- *
- * @throws IOException
- */
- public void testSimplePutAndGet() throws IOException
- {
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testSimplePutAndGet");
- cattr.setMaxKeySize(1000);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr);
-
- disk.processRemoveAll();
-
- int cnt = 999;
- for (int i = 0; i < cnt; i++)
- {
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- ICacheElement<String, String> element = new CacheElement<String, String>("testSimplePutAndGet", "key:" + i, "data:" + i);
- element.setElementAttributes(eAttr);
- disk.processUpdate(element);
- }
-
- for (int i = 0; i < cnt; i++)
- {
- ICacheElement<String, String> element = disk.processGet("key:" + i);
- assertNotNull("Should have received an element.", element);
- assertEquals("Element is wrong.", "data:" + i, element.getVal());
- }
-
- // Test that getMultiple returns all the expected values
- Set<String> keys = new HashSet<String>();
- for (int i = 0; i < cnt; i++)
- {
- keys.add("key:" + i);
- }
-
- Map<String, ICacheElement<String, String>> elements = disk.getMultiple(keys);
- for (int i = 0; i < cnt; i++)
- {
- ICacheElement<String, String> element = elements.get("key:" + i);
- assertNotNull("element " + i + ":key is missing", element);
- assertEquals("value key:" + i, "data:" + i, element.getVal());
- }
- // System.out.println( disk.getStats() );
- }
-
- /**
- * Add some items to the disk cache and then remove them one by one.
- *
- * @throws IOException
- */
- public void testRemoveItems() throws IOException
- {
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemoveItems");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr);
-
- disk.processRemoveAll();
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- ICacheElement<String, String> element = new CacheElement<String, String>("testRemoveItems", "key:" + i, "data:" + i);
- element.setElementAttributes(eAttr);
- disk.processUpdate(element);
- }
-
- // remove each
- for (int i = 0; i < cnt; i++)
- {
- disk.remove("key:" + i);
- ICacheElement<String, String> element = disk.processGet("key:" + i);
- assertNull("Should not have received an element.", element);
- }
- }
-
- /**
- * Verify that we don't override the largest item.
- * <p>
- *
- * @throws IOException
- */
-
- /**
- * Verify that the overlap check returns true when there are no overlaps.
- */
- public void testCheckForDedOverlaps_noOverlap()
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testCheckForDedOverlaps_noOverlap");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr);
-
- int numDescriptors = 5;
- int pos = 0;
- IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors];
- for (int i = 0; i < numDescriptors; i++)
- {
- IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2);
- pos = pos + (i * 2) + IndexedDisk.HEADER_SIZE_BYTES;
- sortedDescriptors[i] = descriptor;
- }
-
- // DO WORK
- boolean result = disk.checkForDedOverlaps(sortedDescriptors);
-
- // VERIFY
- assertTrue("There should be no overlap. it should be ok", result);
- }
-
- /**
- * Verify that the overlap check returns false when there are overlaps.
- */
- public void testCheckForDedOverlaps_overlaps()
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testCheckForDedOverlaps_overlaps");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr);
-
- int numDescriptors = 5;
- int pos = 0;
- IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors];
- for (int i = 0; i < numDescriptors; i++)
- {
- IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2);
- // don't add the header + IndexedDisk.RECORD_HEADER;
- pos = pos + (i * 2);
- sortedDescriptors[i] = descriptor;
- }
-
- // DO WORK
- boolean result = disk.checkForDedOverlaps(sortedDescriptors);
-
- // VERIFY
- assertFalse("There should be overlaps. it should be not ok", result);
- }
-
- /**
- * Verify that the file size is as expected.
- * <p>
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void testFileSize() throws IOException, InterruptedException
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testFileSize");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<Integer, DiskTestObject>(cattr);
-
- int numberToInsert = 20;
- int bytes = 24;
- ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
- bytes, cattr.getCacheName());
-
- for (int i = 0; i < elements.length; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- Thread.yield();
- Thread.sleep(100);
- Thread.yield();
-
- long expectedSize = DiskTestObjectUtil.totalSize(elements, numberToInsert);
- long resultSize = disk.getDataFileSize();
-
- // System.out.println( "testFileSize stats " + disk.getStats() );
-
- assertEquals("Wrong file size", expectedSize, resultSize);
- }
-
- /**
- * Verify that items are added to the recycle bin on removal.
- * <p>
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void testRecyleBinSize() throws IOException, InterruptedException
- {
- // SETUP
- int numberToInsert = 20;
-
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRecyleBinSize");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- cattr.setOptimizeAtRemoveCount(numberToInsert);
- cattr.setMaxKeySize(numberToInsert * 2);
- cattr.setMaxPurgatorySize(numberToInsert);
- IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<Integer, DiskTestObject>(cattr);
-
- int bytes = 1;
- ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
- bytes, cattr.getCacheName());
-
- for (int i = 0; i < elements.length; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- Thread.yield();
- Thread.sleep(100);
- Thread.yield();
-
- // remove half
- int numberToRemove = elements.length / 2;
- for (int i = 0; i < numberToRemove; i++)
- {
- disk.processRemove(elements[i].getKey());
- }
-
- // verify that the recycle bin has the correct amount.
- assertEquals("The recycle bin should have the number removed.", numberToRemove, disk.getRecyleBinSize());
- }
-
- /**
- * Verify that items of the same size use recycle bin spots. Setup the recycle bin by removing
- * some items. Add some of the same size. Verify that the recycle count is the number added.
- * <p>
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void testRecyleBinUsage() throws IOException, InterruptedException
- {
- // SETUP
- int numberToInsert = 20;
-
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRecyleBinUsage");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- cattr.setOptimizeAtRemoveCount(numberToInsert);
- cattr.setMaxKeySize(numberToInsert * 2);
- cattr.setMaxPurgatorySize(numberToInsert);
- IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<Integer, DiskTestObject>(cattr);
-
- // we will reuse these
- int bytes = 1;
- ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
- bytes, cattr.getCacheName());
-
- // Add some to the disk
- for (int i = 0; i < elements.length; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- Thread.yield();
- Thread.sleep(100);
- Thread.yield();
-
- // remove half of those added
- int numberToRemove = elements.length / 2;
- for (int i = 0; i < numberToRemove; i++)
- {
- disk.processRemove(elements[i].getKey());
- }
-
- // verify that the recycle bin has the correct amount.
- assertEquals("The recycle bin should have the number removed.", numberToRemove, disk.getRecyleBinSize());
-
- // add half as many as we removed. These should all use spots in the recycle bin.
- int numberToAdd = numberToRemove / 2;
- for (int i = 0; i < numberToAdd; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- // verify that we used the correct number of spots
- assertEquals("The recycle bin should have the number removed." + disk.getStats(), numberToAdd, disk.getRecyleCount());
- }
-
- /**
- * Verify that the data size is as expected after a remove and after a put that should use the
- * spots.
- * <p>
- *
- * @throws IOException
- * @throws InterruptedException
- */
- public void testBytesFreeSize() throws IOException, InterruptedException
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testBytesFreeSize");
- cattr.setDiskPath("target/test-sandbox/UnitTest");
- IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<Integer, DiskTestObject>(cattr);
-
- int numberToInsert = 20;
- int bytes = 24;
- ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
- bytes, cattr.getCacheName());
-
- for (int i = 0; i < elements.length; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- Thread.yield();
- Thread.sleep(100);
- Thread.yield();
-
- // remove half of those added
- int numberToRemove = elements.length / 2;
- for (int i = 0; i < numberToRemove; i++)
- {
- disk.processRemove(elements[i].getKey());
- }
-
- long expectedSize = DiskTestObjectUtil.totalSize(elements, numberToRemove);
- long resultSize = disk.getBytesFree();
-
- // System.out.println( "testBytesFreeSize stats " + disk.getStats() );
-
- assertEquals("Wrong bytes free size" + disk.getStats(), expectedSize, resultSize);
-
- // add half as many as we removed. These should all use spots in the recycle bin.
- int numberToAdd = numberToRemove / 2;
- for (int i = 0; i < numberToAdd; i++)
- {
- disk.processUpdate(elements[i]);
- }
-
- long expectedSize2 = DiskTestObjectUtil.totalSize(elements, numberToAdd);
- long resultSize2 = disk.getBytesFree();
- assertEquals("Wrong bytes free size" + disk.getStats(), expectedSize2, resultSize2);
- }
-
- /**
- * Add some items to the disk cache and then remove them one by one.
- * <p>
- *
- * @throws IOException
- */
- public void testRemove_PartialKey() throws IOException
- {
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemove_PartialKey");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>(cattr);
-
- disk.processRemoveAll();
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- ICacheElement<String, String> element = new CacheElement<String, String>("testRemove_PartialKey", i + ":key", "data:"
- + i);
- element.setElementAttributes(eAttr);
- disk.processUpdate(element);
- }
-
- // verif each
- for (int i = 0; i < cnt; i++)
- {
- ICacheElement<String, String> element = disk.processGet(i + ":key");
- assertNotNull("Shoulds have received an element.", element);
- }
-
- // remove each
- for (int i = 0; i < cnt; i++)
- {
- disk.remove(i + ":");
- ICacheElement<String, String> element = disk.processGet(i + ":key");
- assertNull("Should not have received an element.", element);
- }
- // https://issues.apache.org/jira/browse/JCS-67
- assertEquals("Recylenbin should not have more elements than we removed. Check for JCS-67", cnt, disk.getRecyleBinSize());
- }
-
- /**
- * Verify that group members are removed if we call remove with a group.
- *
- * @throws IOException
- */
- public void testRemove_Group() throws IOException
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemove_Group");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<GroupAttrName<String>, String> disk = new IndexedDiskCache<GroupAttrName<String>, String>(cattr);
-
- disk.processRemoveAll();
-
- String cacheName = "testRemove_Group_Region";
- String groupName = "testRemove_Group";
-
- int cnt = 25;
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- CacheElement<GroupAttrName<String>, String> element = new CacheElement<GroupAttrName<String>, String>(cacheName,
- groupAttrName, "data:" + i);
-
- IElementAttributes eAttr = new ElementAttributes();
- eAttr.setIsSpool(true);
- element.setElementAttributes(eAttr);
-
- disk.processUpdate(element);
- }
-
- // verify each
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
- assertNotNull("Should have received an element.", element);
- }
-
- // DO WORK
- // remove the group
- disk.remove(getGroupAttrName(cacheName, groupName, null));
-
- for (int i = 0; i < cnt; i++)
- {
- GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
- ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
-
- // VERIFY
- assertNull("Should not have received an element.", element);
- }
-
- }
-
- /**
- * Internal method used for group functionality.
- * <p>
- *
- * @param cacheName
- * @param group
- * @param name
- * @return GroupAttrName
- */
- private GroupAttrName<String> getGroupAttrName(String cacheName, String group, String name)
- {
- GroupId gid = new GroupId(cacheName, group);
- return new GroupAttrName<String>(gid, name);
- }
-
- /**
- * Verify event log calls.
- * <p>
- *
- * @throws Exception
- */
- public void testUpdate_EventLogging_simple() throws Exception
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testUpdate_EventLogging_simple");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
- diskCache.processRemoveAll();
-
- MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
- diskCache.setCacheEventLogger(cacheEventLogger);
-
- ICacheElement<String, String> item = new CacheElement<String, String>("region", "key", "value");
-
- // DO WORK
- diskCache.update(item);
-
- SleepUtil.sleepAtLeast(200);
-
- // VERIFY
- assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
- assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
- }
-
- /**
- * Verify event log calls.
- * <p>
- *
- * @throws Exception
- */
- public void testGet_EventLogging_simple() throws Exception
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testGet_EventLogging_simple");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
- diskCache.processRemoveAll();
-
- MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
- diskCache.setCacheEventLogger(cacheEventLogger);
-
- // DO WORK
- diskCache.get("key");
-
- // VERIFY
- assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
- assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
- }
-
- /**
- * Verify event log calls.
- * <p>
- *
- * @throws Exception
- */
- public void testGetMultiple_EventLogging_simple() throws Exception
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testGetMultiple_EventLogging_simple");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
- diskCache.processRemoveAll();
-
- MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
- diskCache.setCacheEventLogger(cacheEventLogger);
-
- Set<String> keys = new HashSet<String>();
- keys.add("junk");
-
- // DO WORK
- diskCache.getMultiple(keys);
-
- // VERIFY
- // 1 for get multiple and 1 for get.
- assertEquals("Start should have been called.", 2, cacheEventLogger.startICacheEventCalls);
- assertEquals("End should have been called.", 2, cacheEventLogger.endICacheEventCalls);
- }
-
- /**
- * Verify event log calls.
- * <p>
- *
- * @throws Exception
- */
- public void testRemove_EventLogging_simple() throws Exception
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemoveAll_EventLogging_simple");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
- diskCache.processRemoveAll();
-
- MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
- diskCache.setCacheEventLogger(cacheEventLogger);
-
- // DO WORK
- diskCache.remove("key");
-
- // VERIFY
- assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
- assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
- }
-
- /**
- * Verify event log calls.
- * <p>
- *
- * @throws Exception
- */
- public void testRemoveAll_EventLogging_simple() throws Exception
- {
- // SETUP
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName("testRemoveAll_EventLogging_simple");
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
- diskCache.processRemoveAll();
-
- MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
- diskCache.setCacheEventLogger(cacheEventLogger);
-
- // DO WORK
- diskCache.remove("key");
-
- // VERIFY
- assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
- assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
- }
-
- /**
- * Test the basic get matching.
- * <p>
- *
- * @throws Exception
- */
- public void testPutGetMatching_SmallWait() throws Exception
- {
- // SETUP
- int items = 200;
-
- String cacheName = "testPutGetMatching_SmallWait";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- // DO WORK
- for (int i = 0; i <= items; i++)
- {
- diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i));
- }
- Thread.sleep(500);
-
- Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
-
- // VERIFY
- assertEquals("Wrong number returned", 10, matchingResults.size());
- // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
- // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
- }
-
- /**
- * Test the basic get matching. With no wait this will all come from purgatory.
- * <p>
- *
- * @throws Exception
- */
- public void testPutGetMatching_NoWait() throws Exception
- {
- // SETUP
- int items = 200;
-
- String cacheName = "testPutGetMatching_NoWait";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- // DO WORK
- for (int i = 0; i <= items; i++)
- {
- diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i));
- }
-
- Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
-
- // VERIFY
- assertEquals("Wrong number returned", 10, matchingResults.size());
- // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
- // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
- }
-
- /**
- * Verify that the block disk cache can handle utf encoded strings.
- * <p>
- *
- * @throws Exception
- */
- public void testUTF8String() throws Exception
- {
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
-
- // System.out.println( "The string contains " + string.length() + " characters" );
-
- String cacheName = "testUTF8String";
-
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, String>(cacheName, "x", string));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, String> afterElement = diskCache.get("x");
- assertNotNull(afterElement);
- // System.out.println( "afterElement = " + afterElement );
- String after = afterElement.getVal();
-
- assertNotNull(after);
- assertEquals("wrong string after retrieval", string, after);
- }
-
- /**
- * Verify that the block disk cache can handle utf encoded strings.
- * <p>
- *
- * @throws Exception
- */
- public void testUTF8ByteArray() throws Exception
- {
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
- // System.out.println( "The string contains " + string.length() + " characters" );
- String UTF8 = "UTF-8";
- byte[] bytes = string.getBytes(UTF8);
-
- String cacheName = "testUTF8ByteArray";
-
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, byte[]> diskCache = new IndexedDiskCache<String, byte[]>(cattr);
-
- // DO WORK
- diskCache.update(new CacheElement<String, byte[]>(cacheName, "x", bytes));
-
- // VERIFY
- assertNotNull(diskCache.get("x"));
- Thread.sleep(1000);
- ICacheElement<String, byte[]> afterElement = diskCache.get("x");
- assertNotNull(afterElement);
- // System.out.println( "afterElement = " + afterElement );
- byte[] after = afterElement.getVal();
-
- assertNotNull(after);
- assertEquals("wrong bytes after retrieval", string, new String(after, UTF8));
- }
-
- /**
- * Verify the item makes it to disk.
- * <p>
- *
- * @throws IOException
- */
- public void testProcessUpdate_Simple() throws IOException
- {
- // SETUP
- String cacheName = "testProcessUpdate_Simple";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- String key = "myKey";
- String value = "myValue";
- ICacheElement<String, String> ce = new CacheElement<String, String>(cacheName, key, value);
-
- // DO WORK
- diskCache.processUpdate(ce);
- ICacheElement<String, String> result = diskCache.processGet(key);
-
- // VERIFY
- assertNotNull("Should have a result", result);
- long fileSize = diskCache.getDataFileSize();
- assertTrue("File should be greater than 0", fileSize > 0);
- }
-
- /**
- * Verify the item makes it to disk.
- * <p>
- *
- * @throws IOException
- */
- public void testProcessUpdate_SameKeySameSize() throws IOException
- {
- // SETUP
- String cacheName = "testProcessUpdate_SameKeySameSize";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- String key = "myKey";
- String value = "myValue";
- ICacheElement<String, String> ce1 = new CacheElement<String, String>(cacheName, key, value);
-
- // DO WORK
- diskCache.processUpdate(ce1);
- long fileSize1 = diskCache.getDataFileSize();
-
- // DO WORK
- ICacheElement<String, String> ce2 = new CacheElement<String, String>(cacheName, key, value);
- diskCache.processUpdate(ce2);
- ICacheElement<String, String> result = diskCache.processGet(key);
-
- // VERIFY
- assertNotNull("Should have a result", result);
- long fileSize2 = diskCache.getDataFileSize();
- assertEquals("File should be the same", fileSize1, fileSize2);
- int binSize = diskCache.getRecyleBinSize();
- assertEquals("Should be nothing in the bin.", 0, binSize);
- }
-
- /**
- * Verify the item makes it to disk.
- * <p>
- *
- * @throws IOException
- */
- public void testProcessUpdate_SameKeySmallerSize() throws IOException
- {
- // SETUP
- String cacheName = "testProcessUpdate_SameKeySmallerSize";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- String key = "myKey";
- String value = "myValue";
- String value2 = "myValu";
- ICacheElement<String, String> ce1 = new CacheElement<String, String>(cacheName, key, value);
-
- // DO WORK
- diskCache.processUpdate(ce1);
- long fileSize1 = diskCache.getDataFileSize();
-
- // DO WORK
- ICacheElement<String, String> ce2 = new CacheElement<String, String>(cacheName, key, value2);
- diskCache.processUpdate(ce2);
- ICacheElement<String, String> result = diskCache.processGet(key);
-
- // VERIFY
- assertNotNull("Should have a result", result);
- long fileSize2 = diskCache.getDataFileSize();
- assertEquals("File should be the same", fileSize1, fileSize2);
- int binSize = diskCache.getRecyleBinSize();
- assertEquals("Should be nothing in the bin.", 0, binSize);
- }
-
- /**
- * Verify that the old slot gets in the recycle bin.
- * <p>
- *
- * @throws IOException
- */
- public void testProcessUpdate_SameKeyBiggerSize() throws IOException
- {
- // SETUP
- String cacheName = "testProcessUpdate_SameKeyBiggerSize";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- String key = "myKey";
- String value = "myValue";
- String value2 = "myValue2";
- ICacheElement<String, String> ce1 = new CacheElement<String, String>(cacheName, key, value);
-
- // DO WORK
- diskCache.processUpdate(ce1);
- long fileSize1 = diskCache.getDataFileSize();
-
- // DO WORK
- ICacheElement<String, String> ce2 = new CacheElement<String, String>(cacheName, key, value2);
- diskCache.processUpdate(ce2);
- ICacheElement<String, String> result = diskCache.processGet(key);
-
- // VERIFY
- assertNotNull("Should have a result", result);
- long fileSize2 = diskCache.getDataFileSize();
- assertTrue("File should be greater.", fileSize1 < fileSize2);
- int binSize = diskCache.getRecyleBinSize();
- assertEquals("Should be one in the bin.", 1, binSize);
- }
-
- public void testLoadFromDisk() throws Exception
- {
- for (int i = 0; i < 15; i++)
- { // usually after 2 time it fails
- oneLoadFromDisk();
- }
- }
-
- public void oneLoadFromDisk() throws Exception
- {
- // initialize object to be stored
- String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
- StringBuilder sb = new StringBuilder();
- sb.append(string);
- for (int i = 0; i < 4; i++)
- {
- sb.append(sb.toString()); // big string
- }
- string = sb.toString();
-
- // initialize cache
- String cacheName = "testLoadFromDisk";
- IndexedDiskCacheAttributes cattr = getCacheAttributes();
- cattr.setCacheName(cacheName);
- cattr.setMaxKeySize(100);
- cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
- IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<String, String>(cattr);
-
- // DO WORK
- for (int i = 0; i < 50; i++)
- {
- diskCache.update(new CacheElement<String, String>(cacheName, "x" + i, string));
- }
- // Thread.sleep(1000);
- // VERIFY
- diskCache.dispose();
- // Thread.sleep(1000);
-
- diskCache = new IndexedDiskCache<String, String>(cattr);
-
- for (int i = 0; i < 50; i++)
- {
- ICacheElement<String, String> afterElement = diskCache.get("x" + i);
- assertNotNull("Missing element from cache. Cache size: " + diskCache.getSize() + " element: x" + i, afterElement);
- assertEquals("wrong string after retrieval", string, afterElement.getVal());
- }
- }
-}
+package org.apache.commons.jcs.auxiliary.disk.indexed;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.apache.commons.jcs.auxiliary.MockCacheEventLogger;
+import org.apache.commons.jcs.auxiliary.disk.DiskTestObject;
+import org.apache.commons.jcs.engine.CacheElement;
+import org.apache.commons.jcs.engine.ElementAttributes;
+import org.apache.commons.jcs.engine.behavior.ICacheElement;
+import org.apache.commons.jcs.engine.behavior.IElementAttributes;
+import org.apache.commons.jcs.engine.control.group.GroupAttrName;
+import org.apache.commons.jcs.engine.control.group.GroupId;
+import org.apache.commons.jcs.utils.timing.SleepUtil;
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for common functionality.
+ * <p>
+ *
+ * @author Aaron Smuts
+ */
+public abstract class IndexDiskCacheUnitTestAbstract extends TestCase
+{
+ public abstract IndexedDiskCacheAttributes getCacheAttributes();
+
+ /**
+ * Simply verify that we can put items in the disk cache and retrieve them.
+ *
+ * @throws IOException
+ */
+ public void testSimplePutAndGet() throws IOException
+ {
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testSimplePutAndGet");
+ cattr.setMaxKeySize(1000);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ int cnt = 999;
+ for (int i = 0; i < cnt; i++)
+ {
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ ICacheElement<String, String> element = new CacheElement<>("testSimplePutAndGet", "key:" + i, "data:" + i);
+ element.setElementAttributes(eAttr);
+ disk.processUpdate(element);
+ }
+
+ for (int i = 0; i < cnt; i++)
+ {
+ ICacheElement<String, String> element = disk.processGet("key:" + i);
+ assertNotNull("Should have received an element.", element);
+ assertEquals("Element is wrong.", "data:" + i, element.getVal());
+ }
+
+ // Test that getMultiple returns all the expected values
+ Set<String> keys = new HashSet<>();
+ for (int i = 0; i < cnt; i++)
+ {
+ keys.add("key:" + i);
+ }
+
+ Map<String, ICacheElement<String, String>> elements = disk.getMultiple(keys);
+ for (int i = 0; i < cnt; i++)
+ {
+ ICacheElement<String, String> element = elements.get("key:" + i);
+ assertNotNull("element " + i + ":key is missing", element);
+ assertEquals("value key:" + i, "data:" + i, element.getVal());
+ }
+ // System.out.println( disk.getStats() );
+ }
+
+ /**
+ * Add some items to the disk cache and then remove them one by one.
+ *
+ * @throws IOException
+ */
+ public void testRemoveItems() throws IOException
+ {
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemoveItems");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ ICacheElement<String, String> element = new CacheElement<>("testRemoveItems", "key:" + i, "data:" + i);
+ element.setElementAttributes(eAttr);
+ disk.processUpdate(element);
+ }
+
+ // remove each
+ for (int i = 0; i < cnt; i++)
+ {
+ disk.remove("key:" + i);
+ ICacheElement<String, String> element = disk.processGet("key:" + i);
+ assertNull("Should not have received an element.", element);
+ }
+ }
+
+ /**
+ * Verify that we don't override the largest item.
+ * <p>
+ *
+ * @throws IOException
+ */
+
+ /**
+ * Verify that the overlap check returns true when there are no overlaps.
+ */
+ public void testCheckForDedOverlaps_noOverlap()
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testCheckForDedOverlaps_noOverlap");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>(cattr);
+
+ int numDescriptors = 5;
+ int pos = 0;
+ IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors];
+ for (int i = 0; i < numDescriptors; i++)
+ {
+ IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2);
+ pos = pos + (i * 2) + IndexedDisk.HEADER_SIZE_BYTES;
+ sortedDescriptors[i] = descriptor;
+ }
+
+ // DO WORK
+ boolean result = disk.checkForDedOverlaps(sortedDescriptors);
+
+ // VERIFY
+ assertTrue("There should be no overlap. it should be ok", result);
+ }
+
+ /**
+ * Verify that the overlap check returns false when there are overlaps.
+ */
+ public void testCheckForDedOverlaps_overlaps()
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testCheckForDedOverlaps_overlaps");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>(cattr);
+
+ int numDescriptors = 5;
+ int pos = 0;
+ IndexedDiskElementDescriptor[] sortedDescriptors = new IndexedDiskElementDescriptor[numDescriptors];
+ for (int i = 0; i < numDescriptors; i++)
+ {
+ IndexedDiskElementDescriptor descriptor = new IndexedDiskElementDescriptor(pos, i * 2);
+ // don't add the header + IndexedDisk.RECORD_HEADER;
+ pos = pos + (i * 2);
+ sortedDescriptors[i] = descriptor;
+ }
+
+ // DO WORK
+ boolean result = disk.checkForDedOverlaps(sortedDescriptors);
+
+ // VERIFY
+ assertFalse("There should be overlaps. it should be not ok", result);
+ }
+
+ /**
+ * Verify that the file size is as expected.
+ * <p>
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void testFileSize() throws IOException, InterruptedException
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testFileSize");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
+
+ int numberToInsert = 20;
+ int bytes = 24;
+ ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
+ bytes, cattr.getCacheName());
+
+ for (int i = 0; i < elements.length; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ Thread.yield();
+ Thread.sleep(100);
+ Thread.yield();
+
+ long expectedSize = DiskTestObjectUtil.totalSize(elements, numberToInsert);
+ long resultSize = disk.getDataFileSize();
+
+ // System.out.println( "testFileSize stats " + disk.getStats() );
+
+ assertEquals("Wrong file size", expectedSize, resultSize);
+ }
+
+ /**
+ * Verify that items are added to the recycle bin on removal.
+ * <p>
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void testRecyleBinSize() throws IOException, InterruptedException
+ {
+ // SETUP
+ int numberToInsert = 20;
+
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRecyleBinSize");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ cattr.setOptimizeAtRemoveCount(numberToInsert);
+ cattr.setMaxKeySize(numberToInsert * 2);
+ cattr.setMaxPurgatorySize(numberToInsert);
+ IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
+
+ int bytes = 1;
+ ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
+ bytes, cattr.getCacheName());
+
+ for (int i = 0; i < elements.length; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ Thread.yield();
+ Thread.sleep(100);
+ Thread.yield();
+
+ // remove half
+ int numberToRemove = elements.length / 2;
+ for (int i = 0; i < numberToRemove; i++)
+ {
+ disk.processRemove(elements[i].getKey());
+ }
+
+ // verify that the recycle bin has the correct amount.
+ assertEquals("The recycle bin should have the number removed.", numberToRemove, disk.getRecyleBinSize());
+ }
+
+ /**
+ * Verify that items of the same size use recycle bin spots. Setup the recycle bin by removing
+ * some items. Add some of the same size. Verify that the recycle count is the number added.
+ * <p>
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void testRecyleBinUsage() throws IOException, InterruptedException
+ {
+ // SETUP
+ int numberToInsert = 20;
+
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRecyleBinUsage");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ cattr.setOptimizeAtRemoveCount(numberToInsert);
+ cattr.setMaxKeySize(numberToInsert * 2);
+ cattr.setMaxPurgatorySize(numberToInsert);
+ IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
+
+ // we will reuse these
+ int bytes = 1;
+ ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
+ bytes, cattr.getCacheName());
+
+ // Add some to the disk
+ for (int i = 0; i < elements.length; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ Thread.yield();
+ Thread.sleep(100);
+ Thread.yield();
+
+ // remove half of those added
+ int numberToRemove = elements.length / 2;
+ for (int i = 0; i < numberToRemove; i++)
+ {
+ disk.processRemove(elements[i].getKey());
+ }
+
+ // verify that the recycle bin has the correct amount.
+ assertEquals("The recycle bin should have the number removed.", numberToRemove, disk.getRecyleBinSize());
+
+ // add half as many as we removed. These should all use spots in the recycle bin.
+ int numberToAdd = numberToRemove / 2;
+ for (int i = 0; i < numberToAdd; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ // verify that we used the correct number of spots
+ assertEquals("The recycle bin should have the number removed." + disk.getStats(), numberToAdd, disk.getRecyleCount());
+ }
+
+ /**
+ * Verify that the data size is as expected after a remove and after a put that should use the
+ * spots.
+ * <p>
+ *
+ * @throws IOException
+ * @throws InterruptedException
+ */
+ public void testBytesFreeSize() throws IOException, InterruptedException
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testBytesFreeSize");
+ cattr.setDiskPath("target/test-sandbox/UnitTest");
+ IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>(cattr);
+
+ int numberToInsert = 20;
+ int bytes = 24;
+ ICacheElement<Integer, DiskTestObject>[] elements = DiskTestObjectUtil.createCacheElementsWithTestObjects(numberToInsert,
+ bytes, cattr.getCacheName());
+
+ for (int i = 0; i < elements.length; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ Thread.yield();
+ Thread.sleep(100);
+ Thread.yield();
+
+ // remove half of those added
+ int numberToRemove = elements.length / 2;
+ for (int i = 0; i < numberToRemove; i++)
+ {
+ disk.processRemove(elements[i].getKey());
+ }
+
+ long expectedSize = DiskTestObjectUtil.totalSize(elements, numberToRemove);
+ long resultSize = disk.getBytesFree();
+
+ // System.out.println( "testBytesFreeSize stats " + disk.getStats() );
+
+ assertEquals("Wrong bytes free size" + disk.getStats(), expectedSize, resultSize);
+
+ // add half as many as we removed. These should all use spots in the recycle bin.
+ int numberToAdd = numberToRemove / 2;
+ for (int i = 0; i < numberToAdd; i++)
+ {
+ disk.processUpdate(elements[i]);
+ }
+
+ long expectedSize2 = DiskTestObjectUtil.totalSize(elements, numberToAdd);
+ long resultSize2 = disk.getBytesFree();
+ assertEquals("Wrong bytes free size" + disk.getStats(), expectedSize2, resultSize2);
+ }
+
+ /**
+ * Add some items to the disk cache and then remove them one by one.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testRemove_PartialKey() throws IOException
+ {
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemove_PartialKey");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ ICacheElement<String, String> element = new CacheElement<>("testRemove_PartialKey", i + ":key", "data:"
+ + i);
+ element.setElementAttributes(eAttr);
+ disk.processUpdate(element);
+ }
+
+ // verif each
+ for (int i = 0; i < cnt; i++)
+ {
+ ICacheElement<String, String> element = disk.processGet(i + ":key");
+ assertNotNull("Shoulds have received an element.", element);
+ }
+
+ // remove each
+ for (int i = 0; i < cnt; i++)
+ {
+ disk.remove(i + ":");
+ ICacheElement<String, String> element = disk.processGet(i + ":key");
+ assertNull("Should not have received an element.", element);
+ }
+ // https://issues.apache.org/jira/browse/JCS-67
+ assertEquals("Recylenbin should not have more elements than we removed. Check for JCS-67", cnt, disk.getRecyleBinSize());
+ }
+
+ /**
+ * Verify that group members are removed if we call remove with a group.
+ *
+ * @throws IOException
+ */
+ public void testRemove_Group() throws IOException
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemove_Group");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<GroupAttrName<String>, String> disk = new IndexedDiskCache<>(cattr);
+
+ disk.processRemoveAll();
+
+ String cacheName = "testRemove_Group_Region";
+ String groupName = "testRemove_Group";
+
+ int cnt = 25;
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ CacheElement<GroupAttrName<String>, String> element = new CacheElement<>(cacheName,
+ groupAttrName, "data:" + i);
+
+ IElementAttributes eAttr = new ElementAttributes();
+ eAttr.setIsSpool(true);
+ element.setElementAttributes(eAttr);
+
+ disk.processUpdate(element);
+ }
+
+ // verify each
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
+ assertNotNull("Should have received an element.", element);
+ }
+
+ // DO WORK
+ // remove the group
+ disk.remove(getGroupAttrName(cacheName, groupName, null));
+
+ for (int i = 0; i < cnt; i++)
+ {
+ GroupAttrName<String> groupAttrName = getGroupAttrName(cacheName, groupName, i + ":key");
+ ICacheElement<GroupAttrName<String>, String> element = disk.processGet(groupAttrName);
+
+ // VERIFY
+ assertNull("Should not have received an element.", element);
+ }
+
+ }
+
+ /**
+ * Internal method used for group functionality.
+ * <p>
+ *
+ * @param cacheName
+ * @param group
+ * @param name
+ * @return GroupAttrName
+ */
+ private GroupAttrName<String> getGroupAttrName(String cacheName, String group, String name)
+ {
+ GroupId gid = new GroupId(cacheName, group);
+ return new GroupAttrName<>(gid, name);
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUpdate_EventLogging_simple() throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testUpdate_EventLogging_simple");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+ diskCache.processRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger(cacheEventLogger);
+
+ ICacheElement<String, String> item = new CacheElement<>("region", "key", "value");
+
+ // DO WORK
+ diskCache.update(item);
+
+ SleepUtil.sleepAtLeast(200);
+
+ // VERIFY
+ assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
+ assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testGet_EventLogging_simple() throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testGet_EventLogging_simple");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+ diskCache.processRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger(cacheEventLogger);
+
+ // DO WORK
+ diskCache.get("key");
+
+ // VERIFY
+ assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
+ assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testGetMultiple_EventLogging_simple() throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testGetMultiple_EventLogging_simple");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+ diskCache.processRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger(cacheEventLogger);
+
+ Set<String> keys = new HashSet<>();
+ keys.add("junk");
+
+ // DO WORK
+ diskCache.getMultiple(keys);
+
+ // VERIFY
+ // 1 for get multiple and 1 for get.
+ assertEquals("Start should have been called.", 2, cacheEventLogger.startICacheEventCalls);
+ assertEquals("End should have been called.", 2, cacheEventLogger.endICacheEventCalls);
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testRemove_EventLogging_simple() throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemoveAll_EventLogging_simple");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+ diskCache.processRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger(cacheEventLogger);
+
+ // DO WORK
+ diskCache.remove("key");
+
+ // VERIFY
+ assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
+ assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
+ }
+
+ /**
+ * Verify event log calls.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testRemoveAll_EventLogging_simple() throws Exception
+ {
+ // SETUP
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName("testRemoveAll_EventLogging_simple");
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTestCEL");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+ diskCache.processRemoveAll();
+
+ MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
+ diskCache.setCacheEventLogger(cacheEventLogger);
+
+ // DO WORK
+ diskCache.remove("key");
+
+ // VERIFY
+ assertEquals("Start should have been called.", 1, cacheEventLogger.startICacheEventCalls);
+ assertEquals("End should have been called.", 1, cacheEventLogger.endICacheEventCalls);
+ }
+
+ /**
+ * Test the basic get matching.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testPutGetMatching_SmallWait() throws Exception
+ {
+ // SETUP
+ int items = 200;
+
+ String cacheName = "testPutGetMatching_SmallWait";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i <= items; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, i + ":key", cacheName + " data " + i));
+ }
+ Thread.sleep(500);
+
+ Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
+
+ // VERIFY
+ assertEquals("Wrong number returned", 10, matchingResults.size());
+ // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+ // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+ }
+
+ /**
+ * Test the basic get matching. With no wait this will all come from purgatory.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testPutGetMatching_NoWait() throws Exception
+ {
+ // SETUP
+ int items = 200;
+
+ String cacheName = "testPutGetMatching_NoWait";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i <= items; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, i + ":key", cacheName + " data " + i));
+ }
+
+ Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+");
+
+ // VERIFY
+ assertEquals("Wrong number returned", 10, matchingResults.size());
+ // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() );
+ // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() );
+ }
+
+ /**
+ * Verify that the block disk cache can handle utf encoded strings.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUTF8String() throws Exception
+ {
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+
+ // System.out.println( "The string contains " + string.length() + " characters" );
+
+ String cacheName = "testUTF8String";
+
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", string));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, String> afterElement = diskCache.get("x");
+ assertNotNull(afterElement);
+ // System.out.println( "afterElement = " + afterElement );
+ String after = afterElement.getVal();
+
+ assertNotNull(after);
+ assertEquals("wrong string after retrieval", string, after);
+ }
+
+ /**
+ * Verify that the block disk cache can handle utf encoded strings.
+ * <p>
+ *
+ * @throws Exception
+ */
+ public void testUTF8ByteArray() throws Exception
+ {
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+ // System.out.println( "The string contains " + string.length() + " characters" );
+ String UTF8 = "UTF-8";
+ byte[] bytes = string.getBytes(UTF8);
+
+ String cacheName = "testUTF8ByteArray";
+
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, byte[]> diskCache = new IndexedDiskCache<>(cattr);
+
+ // DO WORK
+ diskCache.update(new CacheElement<>(cacheName, "x", bytes));
+
+ // VERIFY
+ assertNotNull(diskCache.get("x"));
+ Thread.sleep(1000);
+ ICacheElement<String, byte[]> afterElement = diskCache.get("x");
+ assertNotNull(afterElement);
+ // System.out.println( "afterElement = " + afterElement );
+ byte[] after = afterElement.getVal();
+
+ assertNotNull(after);
+ assertEquals("wrong bytes after retrieval", string, new String(after, UTF8));
+ }
+
+ /**
+ * Verify the item makes it to disk.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testProcessUpdate_Simple() throws IOException
+ {
+ // SETUP
+ String cacheName = "testProcessUpdate_Simple";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ String key = "myKey";
+ String value = "myValue";
+ ICacheElement<String, String> ce = new CacheElement<>(cacheName, key, value);
+
+ // DO WORK
+ diskCache.processUpdate(ce);
+ ICacheElement<String, String> result = diskCache.processGet(key);
+
+ // VERIFY
+ assertNotNull("Should have a result", result);
+ long fileSize = diskCache.getDataFileSize();
+ assertTrue("File should be greater than 0", fileSize > 0);
+ }
+
+ /**
+ * Verify the item makes it to disk.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testProcessUpdate_SameKeySameSize() throws IOException
+ {
+ // SETUP
+ String cacheName = "testProcessUpdate_SameKeySameSize";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ String key = "myKey";
+ String value = "myValue";
+ ICacheElement<String, String> ce1 = new CacheElement<>(cacheName, key, value);
+
+ // DO WORK
+ diskCache.processUpdate(ce1);
+ long fileSize1 = diskCache.getDataFileSize();
+
+ // DO WORK
+ ICacheElement<String, String> ce2 = new CacheElement<>(cacheName, key, value);
+ diskCache.processUpdate(ce2);
+ ICacheElement<String, String> result = diskCache.processGet(key);
+
+ // VERIFY
+ assertNotNull("Should have a result", result);
+ long fileSize2 = diskCache.getDataFileSize();
+ assertEquals("File should be the same", fileSize1, fileSize2);
+ int binSize = diskCache.getRecyleBinSize();
+ assertEquals("Should be nothing in the bin.", 0, binSize);
+ }
+
+ /**
+ * Verify the item makes it to disk.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testProcessUpdate_SameKeySmallerSize() throws IOException
+ {
+ // SETUP
+ String cacheName = "testProcessUpdate_SameKeySmallerSize";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ String key = "myKey";
+ String value = "myValue";
+ String value2 = "myValu";
+ ICacheElement<String, String> ce1 = new CacheElement<>(cacheName, key, value);
+
+ // DO WORK
+ diskCache.processUpdate(ce1);
+ long fileSize1 = diskCache.getDataFileSize();
+
+ // DO WORK
+ ICacheElement<String, String> ce2 = new CacheElement<>(cacheName, key, value2);
+ diskCache.processUpdate(ce2);
+ ICacheElement<String, String> result = diskCache.processGet(key);
+
+ // VERIFY
+ assertNotNull("Should have a result", result);
+ long fileSize2 = diskCache.getDataFileSize();
+ assertEquals("File should be the same", fileSize1, fileSize2);
+ int binSize = diskCache.getRecyleBinSize();
+ assertEquals("Should be nothing in the bin.", 0, binSize);
+ }
+
+ /**
+ * Verify that the old slot gets in the recycle bin.
+ * <p>
+ *
+ * @throws IOException
+ */
+ public void testProcessUpdate_SameKeyBiggerSize() throws IOException
+ {
+ // SETUP
+ String cacheName = "testProcessUpdate_SameKeyBiggerSize";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/IndexDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ String key = "myKey";
+ String value = "myValue";
+ String value2 = "myValue2";
+ ICacheElement<String, String> ce1 = new CacheElement<>(cacheName, key, value);
+
+ // DO WORK
+ diskCache.processUpdate(ce1);
+ long fileSize1 = diskCache.getDataFileSize();
+
+ // DO WORK
+ ICacheElement<String, String> ce2 = new CacheElement<>(cacheName, key, value2);
+ diskCache.processUpdate(ce2);
+ ICacheElement<String, String> result = diskCache.processGet(key);
+
+ // VERIFY
+ assertNotNull("Should have a result", result);
+ long fileSize2 = diskCache.getDataFileSize();
+ assertTrue("File should be greater.", fileSize1 < fileSize2);
+ int binSize = diskCache.getRecyleBinSize();
+ assertEquals("Should be one in the bin.", 1, binSize);
+ }
+
+ public void testLoadFromDisk() throws Exception
+ {
+ for (int i = 0; i < 15; i++)
+ { // usually after 2 time it fails
+ oneLoadFromDisk();
+ }
+ }
+
+ public void oneLoadFromDisk() throws Exception
+ {
+ // initialize object to be stored
+ String string = "IÒtÎrn‚tiÙn‡lizÊti¯n";
+ StringBuilder sb = new StringBuilder();
+ sb.append(string);
+ for (int i = 0; i < 4; i++)
+ {
+ sb.append(sb.toString()); // big string
+ }
+ string = sb.toString();
+
+ // initialize cache
+ String cacheName = "testLoadFromDisk";
+ IndexedDiskCacheAttributes cattr = getCacheAttributes();
+ cattr.setCacheName(cacheName);
+ cattr.setMaxKeySize(100);
+ cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest");
+ IndexedDiskCache<String, String> diskCache = new IndexedDiskCache<>(cattr);
+
+ // DO WORK
+ for (int i = 0; i < 50; i++)
+ {
+ diskCache.update(new CacheElement<>(cacheName, "x" + i, string));
+ }
+ // Thread.sleep(1000);
+ // VERIFY
+ diskCache.dispose();
+ // Thread.sleep(1000);
+
+ diskCache = new IndexedDiskCache<>(cattr);
+
+ for (int i = 0; i < 50; i++)
+ {
+ ICacheElement<String, String> afterElement = diskCache.get("x" + i);
+ assertNotNull("Missing element from cache. Cache size: " + diskCache.getSize() + " element: x" + i, afterElement);
+ assertEquals("wrong string after retrieval", string, afterElement.getVal());
+ }
+ }
+}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
index 35c2b18..0661254 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheConcurrentUnitTest.java
@@ -157,7 +157,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
@@ -218,7 +218,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = start; i <= end; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
index 644213e..239b575 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheKeyStoreUnitTest.java
@@ -49,7 +49,7 @@
cattr.setCacheName( "testStoreKeys" );
cattr.setMaxKeySize( 100 );
cattr.setDiskPath( "target/test-sandbox/KeyStoreUnitTest" );
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr );
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>( cattr );
disk.processRemoveAll();
@@ -58,7 +58,7 @@
{
IElementAttributes eAttr = new ElementAttributes();
eAttr.setIsSpool( true );
- ICacheElement<String, String> element = new CacheElement<String, String>( cattr.getCacheName(), "key:" + i, "data:" + i );
+ ICacheElement<String, String> element = new CacheElement<>( cattr.getCacheName(), "key:" + i, "data:" + i );
element.setElementAttributes( eAttr );
disk.processUpdate( element );
}
@@ -103,7 +103,7 @@
cattr.setCacheName( "testOptimize" );
cattr.setMaxKeySize( 100 );
cattr.setDiskPath( "target/test-sandbox/KeyStoreUnitTest" );
- IndexedDiskCache<String, String> disk = new IndexedDiskCache<String, String>( cattr );
+ IndexedDiskCache<String, String> disk = new IndexedDiskCache<>( cattr );
disk.processRemoveAll();
@@ -112,7 +112,7 @@
{
IElementAttributes eAttr = new ElementAttributes();
eAttr.setIsSpool( true );
- ICacheElement<String, String> element = new CacheElement<String, String>( cattr.getCacheName(), "key:" + i, "data:" + i );
+ ICacheElement<String, String> element = new CacheElement<>( cattr.getCacheName(), "key:" + i, "data:" + i );
element.setElementAttributes( eAttr );
disk.processUpdate( element );
}
@@ -121,7 +121,7 @@
IElementAttributes eAttr = new ElementAttributes();
eAttr.setIsSpool( true );
- ICacheElement<String, String> elementSetup = new CacheElement<String, String>( cattr.getCacheName(), "key:" + "A", "data:" + "A" );
+ ICacheElement<String, String> elementSetup = new CacheElement<>( cattr.getCacheName(), "key:" + "A", "data:" + "A" );
elementSetup.setElementAttributes( eAttr );
disk.processUpdate( elementSetup );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheNoMemoryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheNoMemoryUnitTest.java
index 82ad2cc..bbce378 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheNoMemoryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheNoMemoryUnitTest.java
@@ -146,7 +146,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
index 8317505..a76740d 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheOptimizationUnitTest.java
@@ -49,7 +49,7 @@
cattr.setMaxKeySize( removeCount * 2 );
cattr.setOptimizeAtRemoveCount( removeCount );
cattr.setDiskPath( "target/test-sandbox/testOptimization" );
- IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<Integer, DiskTestObject>( cattr );
+ IndexedDiskCache<Integer, DiskTestObject> disk = new IndexedDiskCache<>( cattr );
disk.removeAll();
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java
index b9f4771..244410c 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/IndexedDiskCacheSameRegionConcurrentUnitTest.java
@@ -182,7 +182,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = start; i <= end; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/LRUMapSizeVsCount.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/LRUMapSizeVsCount.java
index 7599f01..587e462 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/LRUMapSizeVsCount.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/indexed/LRUMapSizeVsCount.java
@@ -114,7 +114,7 @@
cattr.setName("junit");
cattr.setCacheName("junit");
cattr.setDiskPath(".");
- IndexedDiskCache<String, String> idc = new IndexedDiskCache<String, String>(cattr);
+ IndexedDiskCache<String, String> idc = new IndexedDiskCache<>(cattr);
Map<String, IndexedDiskElementDescriptor> cacheCount = idc.new LRUMapCountLimited( tries );
Map<String, IndexedDiskElementDescriptor> cacheSize = idc.new LRUMapSizeLimited( tries/1024/2 );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
index 821bd3b..9385e87 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDataSourceFactoryUnitTest.java
@@ -154,7 +154,7 @@
{
context = new InitialContext(true)
{
- Map<String, Object> bindings = new HashMap<String, Object>();
+ Map<String, Object> bindings = new HashMap<>();
@Override
public void bind(String name, Object obj) throws NamingException
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheSharedPoolUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheSharedPoolUnitTest.java
index 79f8311..b33ae4d 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheSharedPoolUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheSharedPoolUnitTest.java
@@ -112,7 +112,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java
index 2b53ac8..bd79ab9 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/JDBCDiskCacheUnitTest.java
@@ -116,7 +116,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java
index 33d8957..91a0811 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheConcurrentUnitTest.java
@@ -144,7 +144,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java
index d5bca8a..d6c0294 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/hsql/HSQLDiskCacheUnitTest.java
@@ -81,7 +81,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i <= items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java
index 97130f2..7030397 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheHsqlBackedUnitTest.java
@@ -118,7 +118,7 @@
}
// Test that getElements returns all the expected values
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java
index cd4a217..596252c 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/disk/jdbc/mysql/MySQLDiskCacheUnitTest.java
@@ -60,7 +60,7 @@
TableState tableState = new TableState( tableName );
tableState.setState( TableState.OPTIMIZATION_RUNNING );
- MySQLDiskCache<String, String> cache = new MySQLDiskCache<String, String>( attributes, dsFactory, tableState,
+ MySQLDiskCache<String, String> cache = new MySQLDiskCache<>( attributes, dsFactory, tableState,
CompositeCacheManager.getUnconfiguredInstance() );
// DO WORK
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacadeUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacadeUnitTest.java
index cc90583..c36bd4f 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacadeUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/LateralCacheNoWaitFacadeUnitTest.java
@@ -39,10 +39,10 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( "testCache1" );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
facade.addNoWait( noWait );
@@ -69,11 +69,11 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( "testCache1" );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
- LateralCacheNoWait<String, String> noWait2 = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
+ LateralCacheNoWait<String, String> noWait2 = new LateralCacheNoWait<>( cache );
// DO WORK
facade.addNoWait( noWait );
@@ -104,10 +104,10 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( "testCache1" );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
facade.addNoWait( noWait );
@@ -129,10 +129,10 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( "testCache1" );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
facade.removeNoWait( noWait );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java
index 1f1ae8b..ac2b159 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPConcurrentRandomTestUtil.java
@@ -85,7 +85,7 @@
// this service will put and remove using the lateral to
// the cache instance above
// the cache thinks it is different since the listenerid is different
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
try
@@ -98,7 +98,7 @@
String key = "key" + kn;
if ( n == 1 )
{
- ICacheElement<String, String> element = new CacheElement<String, String>( region, key, region + ":data" + i
+ ICacheElement<String, String> element = new CacheElement<>( region, key, region + ":data" + i
+ " junk asdfffffffadfasdfasf " + kn + ":" + n );
service.update( element );
if ( show )
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java
index 238ddec..63b74a9 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPDiscoveryListenerUnitTest.java
@@ -80,7 +80,7 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
// DO WORK
listener.addNoWaitFacade( cacheName, facade );
@@ -102,11 +102,11 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
listener.addNoWaitFacade( cacheName, facade );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
boolean result = listener.addNoWait( noWait );
@@ -125,8 +125,8 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
boolean result = listener.addNoWait( noWait );
@@ -145,8 +145,8 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
boolean result = listener.removeNoWait( noWait );
@@ -168,11 +168,11 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
listener.addNoWaitFacade( cacheName, facade );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
// DO WORK
boolean result = listener.removeNoWait( noWait );
@@ -194,11 +194,11 @@
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
listener.addNoWaitFacade( cacheName, facade );
- LateralCache<String, String> cache = new LateralCache<String, String>( cattr );
- LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache );
+ LateralCache<String, String> cache = new LateralCache<>( cattr );
+ LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<>( cache );
listener.addNoWait( noWait );
// DO WORK
@@ -216,7 +216,7 @@
// SETUP
String cacheName = "testAddDiscoveredService_FacadeInList_NoWaitNot";
- ArrayList<String> cacheNames = new ArrayList<String>();
+ ArrayList<String> cacheNames = new ArrayList<>();
cacheNames.add( cacheName );
DiscoveredService service = new DiscoveredService();
@@ -238,7 +238,7 @@
LateralCacheNoWait<String, String>[] noWaits = new LateralCacheNoWait[0];
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
listener.addNoWaitFacade( cacheName, facade );
// DO WORK
@@ -256,7 +256,7 @@
// SETUP
String cacheName = "testRemoveDiscoveredService_FacadeInList_NoWaitIs";
- ArrayList<String> cacheNames = new ArrayList<String>();
+ ArrayList<String> cacheNames = new ArrayList<>();
cacheNames.add( cacheName );
DiscoveredService service = new DiscoveredService();
@@ -278,7 +278,7 @@
LateralCacheNoWait<String, String>[] noWaits = new LateralCacheNoWait[0];
ILateralCacheAttributes cattr = new LateralCacheAttributes();
cattr.setCacheName( cacheName );
- LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<String, String>( null, noWaits, cattr );
+ LateralCacheNoWaitFacade<String, String> facade = new LateralCacheNoWaitFacade<>( null, noWaits, cattr );
listener.addNoWaitFacade( cacheName, facade );
listener.addDiscoveredService( service );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
index 90203f2..2084161 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPFilterRemoveHashCodeUnitTest.java
@@ -99,7 +99,7 @@
// this service will put and remove using the lateral to
// the cache instance above
// the cache thinks it is different since the listenerid is different
- LateralTCPService<String, Serializable> service = new LateralTCPService<String, Serializable>( lattr2 );
+ LateralTCPService<String, Serializable> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
String keyToBeRemovedOnPut = "test1";
@@ -122,12 +122,12 @@
// dataToPassHashCodeCompare.hashCode() );
cache.put( keyToBeRemovedOnPut, "this should get removed." );
- ICacheElement<String, Serializable> element1 = new CacheElement<String, Serializable>( region, keyToBeRemovedOnPut, region
+ ICacheElement<String, Serializable> element1 = new CacheElement<>( region, keyToBeRemovedOnPut, region
+ ":data-this shouldn't get there" );
service.update( element1 );
cache.put( keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
- ICacheElement<String, Serializable> element2 = new CacheElement<String, Serializable>( region, keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
+ ICacheElement<String, Serializable> element2 = new CacheElement<>( region, keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
service.update( element2 );
/*
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java
index 6a11be0..d2cd13e 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/LateralTCPIssueRemoveOnPutUnitTest.java
@@ -96,12 +96,12 @@
// Using the lateral, this service will put to and remove from
// the cache instance above.
// The cache thinks it is different since the listenerid is different
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
String keyToBeRemovedOnPut = "test1_notremoved";
- ICacheElement<String, String> element1 = new CacheElement<String, String>( region, keyToBeRemovedOnPut, region
+ ICacheElement<String, String> element1 = new CacheElement<>( region, keyToBeRemovedOnPut, region
+ ":data-this shouldn't get removed, it should get to the cache." );
service.update( element1 );
@@ -143,13 +143,13 @@
// Using the lateral, this service will put to and remove from
// the cache instance above.
// The cache thinks it is different since the listenerid is different
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
String keyToBeRemovedOnPut = "test1";
cache.put( keyToBeRemovedOnPut, "this should get removed." );
- ICacheElement<String, String> element1 = new CacheElement<String, String>( region, keyToBeRemovedOnPut, region
+ ICacheElement<String, String> element1 = new CacheElement<>( region, keyToBeRemovedOnPut, region
+ ":data-this shouldn't get there" );
service.update( element1 );
@@ -162,7 +162,7 @@
int kn = ran.nextInt( range );
String key = "key" + kn;
- ICacheElement<String, String> element = new CacheElement<String, String>( region, key, region + ":data" + i
+ ICacheElement<String, String> element = new CacheElement<>( region, key, region + ":data" + i
+ " junk asdfffffffadfasdfasf " + kn + ":" + n );
service.update( element );
if ( show )
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
index eeaa8ee..4f34f80 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/lateral/socket/tcp/TestTCPLateralUnitTest.java
@@ -86,8 +86,8 @@
for ( int i = 0; i < numMes; i++ )
{
String message = "adsfasasfasfasdasf";
- CacheElement<String, String> ce = new CacheElement<String, String>( "test", "test", message );
- LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce );
+ CacheElement<String, String> ce = new CacheElement<>( "test", "test", message );
+ LateralElementDescriptor<String, String> led = new LateralElementDescriptor<>( ce );
led.command = LateralCommand.UPDATE;
led.requesterId = 1;
lur.send( led );
@@ -119,14 +119,14 @@
lattr2.setTransmissionTypeName( "TCP" );
lattr2.setTcpServer( "localhost:1101" );
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
// DO WORK
int cnt = 100;
for ( int i = 0; i < cnt; i++ )
{
- ICacheElement<String, String> element = new CacheElement<String, String>( "test", "key" + i, "value1" );
+ ICacheElement<String, String> element = new CacheElement<>( "test", "key" + i, "value1" );
service.update( element );
}
@@ -162,16 +162,16 @@
lattr2.setTcpListenerPort( 1104 );
lattr2.setTcpServer( "localhost:1103" );
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( "test", "key", "value1" );
+ ICacheElement<String, String> element = new CacheElement<>( "test", "key", "value1" );
service.update( element );
SleepUtil.sleepAtLeast( 300 );
- ICacheElement<String, String> element2 = new CacheElement<String, String>( "test", "key", "value2" );
+ ICacheElement<String, String> element2 = new CacheElement<>( "test", "key", "value2" );
service.update( element2 );
SleepUtil.sleepAtLeast( 1000 );
@@ -206,17 +206,17 @@
lattr2.setTransmissionTypeName( "TCP" );
lattr2.setTcpServer( "localhost:1105" );
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
// DO WORK
String key = "key";
- ICacheElement<String, String> element = new CacheElement<String, String>( "test", key, "value1" );
+ ICacheElement<String, String> element = new CacheElement<>( "test", key, "value1" );
service.update( element );
SleepUtil.sleepAtLeast( 300 );
- ICacheElement<String, String> element2 = new CacheElement<String, String>( "test", key, "value2" );
+ ICacheElement<String, String> element2 = new CacheElement<>( "test", key, "value2" );
service.update( element2 );
SleepUtil.sleepAtLeast( 1000 );
@@ -248,7 +248,7 @@
LateralTCPListener.getInstance( lattr, cacheMgr );
// add the item to the listeners cache
- ICacheElement<String, String> element = new CacheElement<String, String>( "test", "key", "value1" );
+ ICacheElement<String, String> element = new CacheElement<>( "test", "key", "value1" );
cache.update( element );
// setup a service to talk to the listener started above.
@@ -256,7 +256,7 @@
lattr2.setTcpListenerPort( 1108 );
lattr2.setTcpServer( "localhost:1107" );
- LateralTCPService<String, String> service = new LateralTCPService<String, String>( lattr2 );
+ LateralTCPService<String, String> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
SleepUtil.sleepAtLeast( 300 );
@@ -290,9 +290,9 @@
LateralTCPListener.getInstance( lattr, cacheMgr );
// add the item to the listeners cache
- GroupAttrName<String> groupKey = new GroupAttrName<String>(new GroupId("test", "group"), "key");
+ GroupAttrName<String> groupKey = new GroupAttrName<>(new GroupId("test", "group"), "key");
ICacheElement<GroupAttrName<String>, String> element =
- new CacheElement<GroupAttrName<String>, String>( "test", groupKey, "value1" );
+ new CacheElement<>( "test", groupKey, "value1" );
cache.update( element );
// setup a service to talk to the listener started above.
@@ -301,7 +301,7 @@
lattr2.setTcpServer( "localhost:1150" );
LateralTCPService<GroupAttrName<String>, String> service =
- new LateralTCPService<GroupAttrName<String>, String>( lattr2 );
+ new LateralTCPService<>( lattr2 );
service.setListenerId( 123459 );
SleepUtil.sleepAtLeast( 500 );
@@ -343,7 +343,7 @@
for ( int i = 0; i < numToInsertPrefix1; i++ )
{
// add the item to the listeners cache
- ICacheElement<String, Integer> element = new CacheElement<String, Integer>( "test", keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
+ ICacheElement<String, Integer> element = new CacheElement<>( "test", keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
cache.update( element );
}
@@ -352,7 +352,7 @@
lattr2.setTcpListenerPort( 1108 );
lattr2.setTcpServer( "localhost:1108" );
- LateralTCPService<String, Integer> service = new LateralTCPService<String, Integer>( lattr2 );
+ LateralTCPService<String, Integer> service = new LateralTCPService<>( lattr2 );
service.setListenerId( 123456 );
SleepUtil.sleepAtLeast( 300 );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheClient.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheClient.java
index b20e979..83c6b44 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheClient.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheClient.java
@@ -50,20 +50,20 @@
private static final Log log = LogFactory.getLog( MockRemoteCacheClient.class );
/** List of ICacheElement<K, V> objects passed into update. */
- public List<ICacheElement<K, V>> updateList = new LinkedList<ICacheElement<K,V>>();
+ public List<ICacheElement<K, V>> updateList = new LinkedList<>();
/** List of key objects passed into remove. */
- public List<K> removeList = new LinkedList<K>();
+ public List<K> removeList = new LinkedList<>();
/** status to return. */
public CacheStatus status = CacheStatus.ALIVE;
/** Can setup values to return from get. values must be ICacheElement<K, V> */
- public Map<K, ICacheElement<K, V>> getSetupMap = new HashMap<K, ICacheElement<K,V>>();
+ public Map<K, ICacheElement<K, V>> getSetupMap = new HashMap<>();
/** Can setup values to return from get. values must be Map<K, ICacheElement<K, V>> */
public Map<Set<K>, Map<K, ICacheElement<K, V>>> getMultipleSetupMap =
- new HashMap<Set<K>, Map<K,ICacheElement<K,V>>>();
+ new HashMap<>();
/** The last service passed to fixCache */
public ICacheServiceNonLocal<K, V> fixed;
@@ -245,7 +245,7 @@
public Map<K, ICacheElement<K, V>> getMatching(String pattern)
throws IOException
{
- return new HashMap<K, ICacheElement<K,V>>();
+ return new HashMap<>();
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheListener.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheListener.java
index 65caa0b..4295ec6 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheListener.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheListener.java
@@ -45,10 +45,10 @@
public int putCount;
/** List of ICacheElements passed to handlePut. */
- public List<ICacheElement<K, V>> putItems = new LinkedList<ICacheElement<K,V>>();
+ public List<ICacheElement<K, V>> putItems = new LinkedList<>();
/** List of Serializable objects passed to handleRemove. */
- public List<K> removedKeys = new LinkedList<K>();
+ public List<K> removedKeys = new LinkedList<>();
/** Number of times handleRemote was called. */
public int removeCount;
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheService.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheService.java
index 1f1b1c5..b004220 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheService.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/MockRemoteCacheService.java
@@ -49,10 +49,10 @@
public ICacheElement<K, V> lastUpdate;
/** List of updates. */
- public List<ICacheElement<K, V>> updateRequestList = new ArrayList<ICacheElement<K,V>>();
+ public List<ICacheElement<K, V>> updateRequestList = new ArrayList<>();
/** List of request ids. */
- public List<Long> updateRequestIdList = new ArrayList<Long>();
+ public List<Long> updateRequestIdList = new ArrayList<>();
/** The key that was last passed to remove. */
public K lastRemoveKey;
@@ -80,7 +80,7 @@
@Override
public Set<K> getKeySet( String cacheName )
{
- return new HashSet<K>();
+ return new HashSet<>();
}
/**
@@ -195,7 +195,7 @@
public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
{
lastGetMultipleKeys = keys;
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -236,6 +236,6 @@
throws IOException
{
lastGetMatchingPattern = pattern;
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheClientTester.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheClientTester.java
index cdb2686..cc62371 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheClientTester.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheClientTester.java
@@ -158,11 +158,11 @@
p( "subscribing to the server" );
watch.addCacheListener( "testCache", this );
- ICacheElement<String, String> cb = new CacheElement<String, String>( "testCache", "testKey", "testVal" );
+ ICacheElement<String, String> cb = new CacheElement<>( "testCache", "testKey", "testVal" );
for ( int i = 0; i < count; i++ )
{
- cb = new CacheElement<String, String>( "testCache", "" + i, "" + i );
+ cb = new CacheElement<>( "testCache", "" + i, "" + i );
if ( delete )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
index db1569b..7cc7e7c 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheListenerUnitTest.java
@@ -55,7 +55,7 @@
IRemoteCacheAttributes irca = new RemoteCacheAttributes();
irca.setRemoveUponRemotePut( false );
ICompositeCacheManager cacheMgr = new MockCompositeCacheManager();
- RemoteCacheListener<String, String> listener = new RemoteCacheListener<String, String>( irca, cacheMgr, new StandardSerializer() );
+ RemoteCacheListener<String, String> listener = new RemoteCacheListener<>( irca, cacheMgr, new StandardSerializer() );
String cacheName = "testName";
String key = "key";
@@ -66,7 +66,7 @@
IElementSerializer elementSerializer = new StandardSerializer();
ICacheElementSerialized<String, String> element =
- new CacheElementSerialized<String, String>( cacheName, key, elementSerializer
+ new CacheElementSerialized<>( cacheName, key, elementSerializer
.serialize( value ), attr );
// DO WORK
@@ -98,7 +98,7 @@
IRemoteCacheAttributes irca = new RemoteCacheAttributes();
irca.setRemoveUponRemotePut( true );
ICompositeCacheManager cacheMgr = new MockCompositeCacheManager();
- RemoteCacheListener<String, String> listener = new RemoteCacheListener<String, String>( irca, cacheMgr, new StandardSerializer() );
+ RemoteCacheListener<String, String> listener = new RemoteCacheListener<>( irca, cacheMgr, new StandardSerializer() );
String cacheName = "testName";
String key = "key";
@@ -109,7 +109,7 @@
IElementSerializer elementSerializer = new StandardSerializer();
ICacheElementSerialized<String, String> element =
- new CacheElementSerialized<String, String>( cacheName, key, elementSerializer
+ new CacheElementSerialized<>( cacheName, key, elementSerializer
.serialize( value ), attr );
// DO WORK
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java
index afbeef2..8af3017 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitFacadeUnitTest.java
@@ -1,56 +1,56 @@
-package org.apache.commons.jcs.auxiliary.remote;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-/**
- * Tests for RemoteCacheNoWaitFacade.
- */
-public class RemoteCacheNoWaitFacadeUnitTest
- extends TestCase
-{
- /**
- * Verify that we can add an item.
- */
- public void testAddNoWait_InList()
- {
- // SETUP
- List<RemoteCacheNoWait<String, String>> noWaits = new ArrayList<RemoteCacheNoWait<String,String>>();
- IRemoteCacheAttributes cattr = new RemoteCacheAttributes();
- cattr.setCacheName( "testCache1" );
-
- RemoteCache<String, String> client = new RemoteCache<String, String>(cattr, null, null, null);
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
- noWaits.add( noWait );
-
- RemoteCacheNoWaitFacade<String, String> facade = new RemoteCacheNoWaitFacade<String, String>(noWaits, cattr, null, null, null );
-
- // VERIFY
- assertEquals( "Should have one entry.", 1, facade.noWaits.size() );
- assertTrue( "Should be in the list.", facade.noWaits.contains( noWait ) );
- assertSame( "Should have same facade.", facade, ((RemoteCache<String, String>)facade.noWaits.get(0).getRemoteCache()).getFacade() );
- }
-}
+package org.apache.commons.jcs.auxiliary.remote;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import junit.framework.TestCase;
+
+/**
+ * Tests for RemoteCacheNoWaitFacade.
+ */
+public class RemoteCacheNoWaitFacadeUnitTest
+ extends TestCase
+{
+ /**
+ * Verify that we can add an item.
+ */
+ public void testAddNoWait_InList()
+ {
+ // SETUP
+ List<RemoteCacheNoWait<String, String>> noWaits = new ArrayList<>();
+ IRemoteCacheAttributes cattr = new RemoteCacheAttributes();
+ cattr.setCacheName( "testCache1" );
+
+ RemoteCache<String, String> client = new RemoteCache<>(cattr, null, null, null);
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
+ noWaits.add( noWait );
+
+ RemoteCacheNoWaitFacade<String, String> facade = new RemoteCacheNoWaitFacade<>(noWaits, cattr, null, null, null );
+
+ // VERIFY
+ assertEquals( "Should have one entry.", 1, facade.noWaits.size() );
+ assertTrue( "Should be in the list.", facade.noWaits.contains( noWait ) );
+ assertSame( "Should have same facade.", facade, ((RemoteCache<String, String>)facade.noWaits.get(0).getRemoteCache()).getFacade() );
+ }
+}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
index dbca37e..93a7236 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheNoWaitUnitTest.java
@@ -48,10 +48,10 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
- ICacheElement<String, String> element = new CacheElement<String, String>( "testUpdate", "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( "testUpdate", "key", "value" );
// DO WORK
noWait.update( element );
@@ -72,10 +72,10 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
- ICacheElement<String, String> input = new CacheElement<String, String>( "testUpdate", "key", "value" );
+ ICacheElement<String, String> input = new CacheElement<>( "testUpdate", "key", "value" );
client.getSetupMap.put( "key", input );
// DO WORK
@@ -94,14 +94,14 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( "testUpdate", "key", "value" );
- Map<String, ICacheElement<String, String>> inputMap = new HashMap<String, ICacheElement<String,String>>();
+ ICacheElement<String, String> inputElement = new CacheElement<>( "testUpdate", "key", "value" );
+ Map<String, ICacheElement<String, String>> inputMap = new HashMap<>();
inputMap.put( "key", inputElement );
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
keys.add( "key" );
client.getMultipleSetupMap.put( keys, inputMap );
@@ -122,8 +122,8 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
String input = "MyKey";
@@ -146,9 +146,9 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
client.status = CacheStatus.ALIVE;
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
// DO WORK
String result = noWait.getStats();
@@ -166,9 +166,9 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
client.status = CacheStatus.ERROR;
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
// DO WORK
CacheStatus result = noWait.getStatus();
@@ -187,13 +187,13 @@
throws Exception
{
// SETUP
- MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<String, String>();
+ MockRemoteCacheClient<String, String> client = new MockRemoteCacheClient<>();
client.status = CacheStatus.ALIVE;
- RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<String, String>( client );
+ RemoteCacheNoWait<String, String> noWait = new RemoteCacheNoWait<>( client );
- MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>();
+ MockRemoteCacheService<String, String> service = new MockRemoteCacheService<>();
- ICacheElement<String, String> element = new CacheElement<String, String>( "testUpdate", "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( "testUpdate", "key", "value" );
// DO WORK
noWait.update( element );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheUnitTest.java
index e46105c..55090d4 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/RemoteCacheUnitTest.java
@@ -51,8 +51,8 @@
{
super.setUp();
cattr = new RemoteCacheAttributes();
- service = new MockRemoteCacheService<String, String>();
- listener = new MockRemoteCacheListener<String, String>();
+ service = new MockRemoteCacheService<>();
+ listener = new MockRemoteCacheListener<>();
monitor = new RemoteCacheMonitor();
}
@@ -69,12 +69,12 @@
long listenerId = 123;
listener.setListenerId( listenerId );
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
remoteCache.update( element );
// VERIFY
@@ -96,15 +96,15 @@
throws Exception
{
// SETUP
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
// set the zombie
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, zombie, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, zombie, listener, monitor );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
remoteCache.update( element );
// set the new service, this should call propagate
remoteCache.fixCache( service );
@@ -126,12 +126,12 @@
public void testUpdate_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
- ICacheElement<String, String> item = new CacheElement<String, String>( "region", "key", "value" );
+ ICacheElement<String, String> item = new CacheElement<>( "region", "key", "value" );
// DO WORK
remoteCache.update( item );
@@ -149,7 +149,7 @@
public void testGet_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
@@ -170,13 +170,13 @@
public void testGetMultiple_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
// DO WORK
- remoteCache.getMultiple( new HashSet<String>() );
+ remoteCache.getMultiple( new HashSet<>() );
// VERIFY
assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
@@ -191,7 +191,7 @@
public void testRemove_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
@@ -212,7 +212,7 @@
public void testRemoveAll_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
@@ -236,7 +236,7 @@
// SETUP
String pattern = "adsfasdfasd.?";
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
@@ -258,7 +258,7 @@
public void testDispose_simple()
throws Exception
{
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, listener, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, listener, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
@@ -280,7 +280,7 @@
throws Exception
{
// SETUP
- RemoteCache<String, String> remoteCache = new RemoteCache<String, String>( cattr, service, null, monitor );
+ RemoteCache<String, String> remoteCache = new RemoteCache<>( cattr, service, null, monitor );
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
remoteCache.setCacheEventLogger( cacheEventLogger );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
index 694194d..fdc0c3b 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/TestRemoteCache.java
@@ -120,7 +120,7 @@
for ( int i = 0; i < numMes; i++ )
{
String message = "adsfasasfasfasdasf";
- CacheElement<String, String> ce = new CacheElement<String, String>( "key" + 1, "data" + i, message );
+ CacheElement<String, String> ce = new CacheElement<>( "key" + 1, "data" + i, message );
cache.update( ce );
// System.out.println( "put " + ce );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/ZombieRemoteCacheServiceUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/ZombieRemoteCacheServiceUnitTest.java
index c66e909..84ecc3a 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/ZombieRemoteCacheServiceUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/ZombieRemoteCacheServiceUnitTest.java
@@ -39,14 +39,14 @@
throws Exception
{
// SETUP
- MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>();
+ MockRemoteCacheService<String, String> service = new MockRemoteCacheService<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
zombie.update( element, 123l );
zombie.propagateEvents( service );
@@ -63,14 +63,14 @@
throws Exception
{
// SETUP
- MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>();
+ MockRemoteCacheService<String, String> service = new MockRemoteCacheService<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 0 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 0 );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
zombie.update( element, 123l );
zombie.propagateEvents( service );
@@ -87,9 +87,9 @@
throws Exception
{
// SETUP
- MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>();
+ MockRemoteCacheService<String, String> service = new MockRemoteCacheService<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testRemoveThenWalk";
String key = "myKey";
@@ -111,9 +111,9 @@
throws Exception
{
// SETUP
- MockRemoteCacheService<String, String> service = new MockRemoteCacheService<String, String>();
+ MockRemoteCacheService<String, String> service = new MockRemoteCacheService<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testRemoveThenWalk";
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheClientUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheClientUnitTest.java
index be8e3e2..7d31c70 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheClientUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/client/RemoteHttpCacheClientUnitTest.java
@@ -45,7 +45,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -74,7 +74,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -82,9 +82,9 @@
String cacheName = "test";
String key = "key";
- ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, key, "value" );
+ ICacheElement<String, String> expected = new CacheElement<>( cacheName, key, "value" );
RemoteCacheResponse<ICacheElement<String, String>> remoteHttpCacheResponse =
- new RemoteCacheResponse<ICacheElement<String,String>>();
+ new RemoteCacheResponse<>();
remoteHttpCacheResponse.setPayload( expected );
mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse;
@@ -108,7 +108,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -116,11 +116,11 @@
String cacheName = "test";
String pattern = "key";
- ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" );
- Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>();
+ ICacheElement<String, String> expected = new CacheElement<>( cacheName, "key", "value" );
+ Map<String, ICacheElement<String, String>> expectedMap = new HashMap<>();
expectedMap.put( "key", expected );
RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse =
- new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>();
+ new RemoteCacheResponse<>();
remoteHttpCacheResponse.setPayload( expectedMap );
mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse;
@@ -144,7 +144,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -152,11 +152,11 @@
String cacheName = "test";
Set<String> keys = Collections.emptySet();
- ICacheElement<String, String> expected = new CacheElement<String, String>( cacheName, "key", "value" );
- Map<String, ICacheElement<String, String>> expectedMap = new HashMap<String, ICacheElement<String,String>>();
+ ICacheElement<String, String> expected = new CacheElement<>( cacheName, "key", "value" );
+ Map<String, ICacheElement<String, String>> expectedMap = new HashMap<>();
expectedMap.put( "key", expected );
RemoteCacheResponse<Map<String, ICacheElement<String, String>>> remoteHttpCacheResponse =
- new RemoteCacheResponse<Map<String,ICacheElement<String,String>>>();
+ new RemoteCacheResponse<>();
remoteHttpCacheResponse.setPayload( expectedMap );
mockDispatcher.setupRemoteCacheResponse = remoteHttpCacheResponse;
@@ -180,7 +180,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -206,7 +206,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
@@ -231,14 +231,14 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
String cacheName = "test";
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
// DO WORK
client.update( element );
@@ -258,7 +258,7 @@
{
// SETUP
RemoteHttpCacheAttributes attributes = new RemoteHttpCacheAttributes();
- RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<String, String>( attributes );
+ RemoteHttpCacheClient<String, String> client = new RemoteHttpCacheClient<>( attributes );
MockRemoteCacheDispatcher mockDispatcher = new MockRemoteCacheDispatcher();
client.setRemoteDispatcher( mockDispatcher );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServiceUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServiceUnitTest.java
index 049438d..6b35897 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServiceUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServiceUnitTest.java
@@ -44,12 +44,12 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
String cacheName = "test";
String key = "key";
long requesterId = 2;
- CacheElement<String, String> element = new CacheElement<String, String>( cacheName, key, null );
+ CacheElement<String, String> element = new CacheElement<>( cacheName, key, null );
// DO WORK
server.update( element, requesterId );
@@ -73,7 +73,7 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
// DO WORK
server.get( "region", "key" );
@@ -97,7 +97,7 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
// DO WORK
server.getMatching( "region", "pattern", 0 );
@@ -121,10 +121,10 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
// DO WORK
- server.getMultiple( "region", new HashSet<String>() );
+ server.getMultiple( "region", new HashSet<>() );
// VERIFY
assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
@@ -145,7 +145,7 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
// DO WORK
server.remove( "region", "key" );
@@ -169,7 +169,7 @@
RemoteHttpCacheServerAttributes rcsa = new RemoteHttpCacheServerAttributes();
RemoteHttpCacheService<String, String> server =
- new RemoteHttpCacheService<String, String>( manager, rcsa, cacheEventLogger );
+ new RemoteHttpCacheService<>( manager, rcsa, cacheEventLogger );
// DO WORK
server.removeAll( "region" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServletUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServletUnitTest.java
index 1e45af5..93cb7c9 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServletUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/http/server/RemoteHttpCacheServletUnitTest.java
@@ -48,7 +48,7 @@
servlet = new RemoteHttpCacheServlet();
servlet.init(null);
- remoteHttpCacheService = new MockRemoteCacheService<Serializable, Serializable>();
+ remoteHttpCacheService = new MockRemoteCacheService<>();
servlet.setRemoteCacheService( remoteHttpCacheService );
}
@@ -133,7 +133,7 @@
String cacheName = "test";
String key = "key";
long requesterId = 2;
- CacheElement<Serializable, Serializable> element = new CacheElement<Serializable, Serializable>( cacheName, key, null );
+ CacheElement<Serializable, Serializable> element = new CacheElement<>( cacheName, key, null );
RemoteCacheRequest<Serializable, Serializable> request = RemoteCacheRequestFactory.createUpdateRequest( element, requesterId );
// DO WORK
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
index fe6b86a..21ea4dd 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/BasicRemoteCacheClientServerUnitTest.java
@@ -152,7 +152,7 @@
// DO WORK
int numPutsPrior = server.getPutCount();
- ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value");
+ ICacheElement<String, String> element = new CacheElement<>(cache.getCacheName(), "key", "value");
cache.update(element);
SleepUtil.sleepAtLeast(200);
@@ -201,7 +201,7 @@
// DO WORK
int numPutsPrior = server.getPutCount();
- ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value");
+ ICacheElement<String, String> element = new CacheElement<>(cache.getCacheName(), "key", "value");
cache.update(element);
SleepUtil.sleepAtLeast(50);
@@ -253,12 +253,12 @@
RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer());
AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
- MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<>();
server.addCacheListener(cache.getCacheName(), listener);
// DO WORK
int numPutsPrior = server.getPutCount();
- ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value");
+ ICacheElement<String, String> element = new CacheElement<>(cache.getCacheName(), "key", "value");
cache.update(element);
SleepUtil.sleepAtLeast(50);
@@ -302,7 +302,7 @@
RemoteCacheManager remoteCacheManager = factory.getManager(attributes, compositeCacheManager, new MockCacheEventLogger(), new MockElementSerializer());
AuxiliaryCache<String, String> cache = remoteCacheManager.getCache(attributes);
- MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> listener = new MockRemoteCacheListener<>();
server.addCacheListener(cache.getCacheName(), listener);
// DO WORK
@@ -310,7 +310,7 @@
int numToPut = 100;
for (int i = 0; i < numToPut; i++)
{
- ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key" + 1, "value" + i);
+ ICacheElement<String, String> element = new CacheElement<>(cache.getCacheName(), "key" + 1, "value" + i);
cache.update(element);
}
SleepUtil.sleepAtLeast(500);
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
index cf09219..d002f80 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/server/RemoteCacheServerUnitTest.java
@@ -57,7 +57,7 @@
IRemoteCacheServerAttributes rcsa = new RemoteCacheServerAttributes();
rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
- this.server = new RemoteCacheServer<String, String>( rcsa, config );
+ this.server = new RemoteCacheServer<>( rcsa, config );
}
@Override
@@ -77,10 +77,10 @@
public void testAddListenerToCache_LOCALtype()
throws Exception
{
- MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<>();
mockListener1.remoteType = RemoteType.LOCAL;
mockListener1.localAddress = expectedIp1;
- MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<>();
mockListener1.remoteType = RemoteType.LOCAL;
mockListener2.localAddress = expectedIp2;
@@ -106,10 +106,10 @@
public void testAddListenerToCache_CLUSTERtype()
throws Exception
{
- MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<>();
mockListener1.remoteType = RemoteType.CLUSTER;
mockListener1.localAddress = expectedIp1;
- MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<>();
mockListener1.remoteType = RemoteType.CLUSTER;
mockListener2.localAddress = expectedIp2;
@@ -136,9 +136,9 @@
// public void testAddListener_ToAll()
// throws Exception
// {
-// MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<String, String>();
+// MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<>();
// mockListener1.localAddress = expectedIp1;
-// MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<String, String>();
+// MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<>();
// mockListener2.localAddress = expectedIp2;
//
// // DO WORK
@@ -163,8 +163,8 @@
public void testAddListener_ToAllThenRemove()
throws Exception
{
- MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<String, String>();
- MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<>();
+ MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<>();
String cacheName = "testAddListenerToAllThenRemove";
@@ -192,9 +192,9 @@
public void testAddListener_ToAllThenRemove_clusterType()
throws Exception
{
- MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener1 = new MockRemoteCacheListener<>();
mockListener1.remoteType = RemoteType.CLUSTER;
- MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener2 = new MockRemoteCacheListener<>();
mockListener2.remoteType = RemoteType.CLUSTER;
String cacheName = "testAddListenerToAllThenRemove";
@@ -227,19 +227,19 @@
rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
- MockRemoteCacheListener<String, Long> mockListener = new MockRemoteCacheListener<String, Long>();
- RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa, config );
+ MockRemoteCacheListener<String, Long> mockListener = new MockRemoteCacheListener<>();
+ RemoteCacheServer<String, Long> server = new RemoteCacheServer<>( rcsa, config );
String cacheName = "testSimpleRegisterListenerAndPut";
server.addCacheListener( cacheName, mockListener );
// DO WORK
- List<ICacheElement<String, Long>> inputItems = new LinkedList<ICacheElement<String, Long>>();
+ List<ICacheElement<String, Long>> inputItems = new LinkedList<>();
int numToPut = 10;
for ( int i = 0; i < numToPut; i++ )
{
- ICacheElement<String, Long> element = new CacheElement<String, Long>( cacheName, String.valueOf( i ), Long.valueOf( i ) );
+ ICacheElement<String, Long> element = new CacheElement<>( cacheName, String.valueOf( i ), Long.valueOf( i ) );
inputItems.add( element );
server.update( element, 9999 );
}
@@ -273,14 +273,14 @@
rcsa.setLocalClusterConsistency( true );
rcsa.setConfigFileName( "/TestRemoteCacheServer.ccf" );
Properties config = RemoteUtils.loadProps(rcsa.getConfigFileName());
- RemoteCacheServer<String, Long> server = new RemoteCacheServer<String, Long>( rcsa, config );
+ RemoteCacheServer<String, Long> server = new RemoteCacheServer<>( rcsa, config );
// this is to get the listener id for inserts.
- MockRemoteCacheListener<String, Long> clusterListener = new MockRemoteCacheListener<String, Long>();
+ MockRemoteCacheListener<String, Long> clusterListener = new MockRemoteCacheListener<>();
clusterListener.remoteType = RemoteType.CLUSTER;
// this should get the updates
- MockRemoteCacheListener<String, Long> localListener = new MockRemoteCacheListener<String, Long>();
+ MockRemoteCacheListener<String, Long> localListener = new MockRemoteCacheListener<>();
localListener.remoteType = RemoteType.LOCAL;
String cacheName = "testSimpleRegisterListenerAndPut_FromClusterWithLCC";
@@ -288,12 +288,12 @@
server.addCacheListener( cacheName, localListener );
// DO WORK
- List<ICacheElement<String, Long>> inputItems = new LinkedList<ICacheElement<String,Long>>();
+ List<ICacheElement<String, Long>> inputItems = new LinkedList<>();
int numToPut = 10;
for ( int i = 0; i < numToPut; i++ )
{
- ICacheElement<String, Long> element = new CacheElement<String, Long>( cacheName, String.valueOf( i ), Long.valueOf( i ) );
+ ICacheElement<String, Long> element = new CacheElement<>( cacheName, String.valueOf( i ), Long.valueOf( i ) );
inputItems.add( element );
// update using the cluster listener id
server.update( element, clusterListener.getListenerId() );
@@ -321,7 +321,7 @@
public void testSimpleRegisterListenerAndRemove()
throws Exception
{
- MockRemoteCacheListener<String, String> mockListener = new MockRemoteCacheListener<String, String>();
+ MockRemoteCacheListener<String, String> mockListener = new MockRemoteCacheListener<>();
String cacheName = "testSimpleRegisterListenerAndPut";
server.addCacheListener( cacheName, mockListener );
@@ -358,7 +358,7 @@
MockCacheEventLogger cacheEventLogger = new MockCacheEventLogger();
server.setCacheEventLogger( cacheEventLogger );
- ICacheElement<String, String> item = new CacheElement<String, String>( "region", "key", "value" );
+ ICacheElement<String, String> item = new CacheElement<>( "region", "key", "value" );
// DO WORK
server.update( item );
@@ -418,7 +418,7 @@
server.setCacheEventLogger( cacheEventLogger );
// DO WORK
- server.getMultiple( "region", new HashSet<String>() );
+ server.getMultiple( "region", new HashSet<>() );
// VERIFY
assertEquals( "Start should have been called.", 1, cacheEventLogger.startICacheEventCalls );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactoryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactoryUnitTest.java
index b12824f..e43688c 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactoryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/auxiliary/remote/util/RemoteCacheRequestFactoryUnitTest.java
@@ -130,7 +130,7 @@
long requesterId = 2;
CacheElement<Serializable, Serializable> element =
- new CacheElement<Serializable, Serializable>( cacheName, key, null );
+ new CacheElement<>( cacheName, key, null );
// DO WORK
RemoteCacheRequest<Serializable, Serializable> result =
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/CacheEventQueueFactoryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/CacheEventQueueFactoryUnitTest.java
index 60b72f3..b5d3637 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/CacheEventQueueFactoryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/CacheEventQueueFactoryUnitTest.java
@@ -35,10 +35,10 @@
{
// SETUP
QueueType eventQueueType = QueueType.SINGLE;
- ICacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
+ ICacheListener<String, String> listener = new MockRemoteCacheListener<>();
long listenerId = 1;
- CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<String, String>();
+ CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<>();
// DO WORK
ICacheEventQueue<String, String> result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType );
@@ -53,10 +53,10 @@
{
// SETUP
QueueType eventQueueType = QueueType.POOLED;
- ICacheListener<String, String> listener = new MockRemoteCacheListener<String, String>();
+ ICacheListener<String, String> listener = new MockRemoteCacheListener<>();
long listenerId = 1;
- CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<String, String>();
+ CacheEventQueueFactory<String, String> factory = new CacheEventQueueFactory<>();
// DO WORK
ICacheEventQueue<String, String> result = factory.createCacheEventQueue( listener, listenerId, "cacheName", "threadPoolName", eventQueueType );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/EventQueueConcurrentLoadTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/EventQueueConcurrentLoadTest.java
index 799ebf4..a38267e 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/EventQueueConcurrentLoadTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/EventQueueConcurrentLoadTest.java
@@ -148,8 +148,8 @@
@Override
public void setUp()
{
- listen = new CacheListenerImpl<String, String>();
- queue = new CacheEventQueue<String, String>( listen, 1L, "testCache1", maxFailure, waitBeforeRetry );
+ listen = new CacheListenerImpl<>();
+ queue = new CacheEventQueue<>( listen, 1L, "testCache1", maxFailure, waitBeforeRetry );
queue.setWaitToDieMillis( idleTime );
}
@@ -165,7 +165,7 @@
{
for ( int i = 0; i <= end; i++ )
{
- CacheElement<String, String> elem = new CacheElement<String, String>( "testCache1", i + ":key", i + "data" );
+ CacheElement<String, String> elem = new CacheElement<>( "testCache1", i + ":key", i + "data" );
queue.addPutEvent( elem );
}
@@ -221,7 +221,7 @@
System.out.println( "queue is empty, begin" );
// get it going
- CacheElement<String, String> elem = new CacheElement<String, String>( "testCache1", "a:key", "adata" );
+ CacheElement<String, String> elem = new CacheElement<>( "testCache1", "a:key", "adata" );
queue.addPutEvent( elem );
for ( int i = 0; i <= end; i++ )
@@ -237,7 +237,7 @@
this.wait( idleTime / 2 );
}
}
- CacheElement<String, String> elem2 = new CacheElement<String, String>( "testCache1", i + ":key", i + "data" );
+ CacheElement<String, String> elem2 = new CacheElement<>( "testCache1", i + ":key", i + "data" );
queue.addPutEvent( elem2 );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/MockCacheServiceNonLocal.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/MockCacheServiceNonLocal.java
index a2d71b9..662d2d7 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/MockCacheServiceNonLocal.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/MockCacheServiceNonLocal.java
@@ -49,10 +49,10 @@
public ICacheElement<K, V> lastUpdate;
/** List of updates. */
- public List<ICacheElement<K, V>> updateRequestList = new ArrayList<ICacheElement<K,V>>();
+ public List<ICacheElement<K, V>> updateRequestList = new ArrayList<>();
/** List of request ids. */
- public List<Long> updateRequestIdList = new ArrayList<Long>();
+ public List<Long> updateRequestIdList = new ArrayList<>();
/** The key that was last passed to remove. */
public K lastRemoveKey;
@@ -80,7 +80,7 @@
@Override
public Set<K> getKeySet( String cacheName )
{
- return new HashSet<K>();
+ return new HashSet<>();
}
/**
@@ -199,7 +199,7 @@
public Map<K, ICacheElement<K, V>> getMultiple( String cacheName, Set<K> keys, long requesterId )
{
lastGetMultipleKeys = keys;
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
@@ -240,6 +240,6 @@
throws IOException
{
lastGetMatchingPattern = pattern;
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocalUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocalUnitTest.java
index 81aae25..1fa5bb6 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocalUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/ZombieCacheServiceNonLocalUnitTest.java
@@ -37,14 +37,14 @@
throws Exception
{
// SETUP
- MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<String, String>();
+ MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
zombie.update( element, 123l );
zombie.propagateEvents( service );
@@ -61,14 +61,14 @@
throws Exception
{
// SETUP
- MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<String, String>();
+ MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 0 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 0 );
String cacheName = "testUpdate";
// DO WORK
- ICacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key", "value" );
+ ICacheElement<String, String> element = new CacheElement<>( cacheName, "key", "value" );
zombie.update( element, 123l );
zombie.propagateEvents( service );
@@ -85,9 +85,9 @@
throws Exception
{
// SETUP
- MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<String, String>();
+ MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testRemoveThenWalk";
String key = "myKey";
@@ -109,9 +109,9 @@
throws Exception
{
// SETUP
- MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<String, String>();
+ MockCacheServiceNonLocal<String, String> service = new MockCacheServiceNonLocal<>();
- ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<String, String>( 10 );
+ ZombieCacheServiceNonLocal<String, String> zombie = new ZombieCacheServiceNonLocal<>( 10 );
String cacheName = "testRemoveThenWalk";
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
index 3f7a520..c965166 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
@@ -103,16 +103,16 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.spoolToDisk( inputElement );
@@ -135,16 +135,16 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.spoolToDisk( inputElement );
@@ -171,16 +171,16 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.updateAuxiliaries( inputElement, true );
@@ -209,16 +209,16 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.updateAuxiliaries( inputElement, false );
@@ -247,16 +247,16 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.updateAuxiliaries( inputElement, true );
@@ -283,19 +283,19 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, String> cache = new CompositeCache<String, String>( cattr, attr );
+ CompositeCache<String, String> cache = new CompositeCache<>( cattr, attr );
- MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mock = new MockAuxCache<>();
mock.cacheType = CacheType.DISK_CACHE;
- MockAuxCache<String, String> mockLateral = new MockAuxCache<String, String>();
+ MockAuxCache<String, String> mockLateral = new MockAuxCache<>();
mockLateral.cacheType = CacheType.LATERAL_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock, mockLateral };
cache.setAuxCaches( auxArray );
- ICacheElement<String, String> inputElement = new CacheElement<String, String>( CACHE_NAME, "key", "value" );
+ ICacheElement<String, String> inputElement = new CacheElement<>( CACHE_NAME, "key", "value" );
// DO WORK
cache.updateAuxiliaries( inputElement, false );
@@ -366,7 +366,7 @@
@Override
public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
{
- return new HashMap<K, ICacheElement<K, V>>();
+ return new HashMap<>();
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheUnitTest.java
index 7f012c6..a7b0d3b 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/CompositeCacheUnitTest.java
@@ -59,9 +59,9 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr );
+ CompositeCache<String, Integer> cache = new CompositeCache<>( cattr, attr );
- MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>();
+ MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<>();
diskMock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
@@ -71,7 +71,7 @@
int numToInsert = 10;
for ( int i = 0; i < numToInsert; i++ )
{
- ICacheElement<String, Integer> element = new CacheElement<String, Integer>( cacheName, String.valueOf( i ), Integer.valueOf( i ) );
+ ICacheElement<String, Integer> element = new CacheElement<>( cacheName, String.valueOf( i ), Integer.valueOf( i ) );
cache.update( element, false );
}
@@ -99,9 +99,9 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr );
+ CompositeCache<String, Integer> cache = new CompositeCache<>( cattr, attr );
- MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>();
+ MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<>();
diskMock.cacheType = CacheType.REMOTE_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
@@ -111,7 +111,7 @@
int numToInsert = 10;
for ( int i = 0; i < numToInsert; i++ )
{
- ICacheElement<String, Integer> element = new CacheElement<String, Integer>( cacheName, String.valueOf( i ), Integer.valueOf( i ) );
+ ICacheElement<String, Integer> element = new CacheElement<>( cacheName, String.valueOf( i ), Integer.valueOf( i ) );
cache.update( element, false );
}
@@ -142,9 +142,9 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr );
+ CompositeCache<String, Integer> cache = new CompositeCache<>( cattr, attr );
- MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>();
+ MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<>();
diskMock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
@@ -155,7 +155,7 @@
// insert with prefix1
for ( int i = 0; i < numToInsertPrefix1; i++ )
{
- ICacheElement<String, Integer> element = new CacheElement<String, Integer>( cacheName, keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
+ ICacheElement<String, Integer> element = new CacheElement<>( cacheName, keyprefix1 + String.valueOf( i ), Integer.valueOf( i ) );
cache.update( element, false );
}
@@ -163,7 +163,7 @@
// insert with prefix1
for ( int i = 0; i < numToInsertPrefix2; i++ )
{
- ICacheElement<String, Integer> element = new CacheElement<String, Integer>( cacheName, keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
+ ICacheElement<String, Integer> element = new CacheElement<>( cacheName, keyprefix2 + String.valueOf( i ), Integer.valueOf( i ) );
cache.update( element, false );
}
@@ -194,9 +194,9 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr );
+ CompositeCache<String, Integer> cache = new CompositeCache<>( cattr, attr );
- MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>();
+ MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<>();
diskMock.cacheType = CacheType.DISK_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
@@ -228,9 +228,9 @@
IElementAttributes attr = new ElementAttributes();
- CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>( cattr, attr );
+ CompositeCache<String, Integer> cache = new CompositeCache<>( cattr, attr );
- MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String, Integer>();
+ MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<>();
diskMock.cacheType = CacheType.REMOTE_CACHE;
@SuppressWarnings("unchecked")
AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
index 53b2f14..1099919 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/control/MockCompositeCacheManager.java
@@ -49,7 +49,7 @@
{
// System.out.println( "Creating mock cache" );
CompositeCache<K, V> newCache =
- new CompositeCache<K, V>( new CompositeCacheAttributes(), new ElementAttributes() );
+ new CompositeCache<>( new CompositeCacheAttributes(), new ElementAttributes() );
this.setCache( newCache );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java
index 6e7c35f..b2768c6 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/logging/MockCacheEventLogger.java
@@ -65,7 +65,7 @@
public <T> ICacheEvent<T> createICacheEvent( String source, String region, String eventName, String optionalDetails,
T key )
{
- return new CacheEvent<T>();
+ return new CacheEvent<>();
}
/**
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
index 5b8ee37..9847b62 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/match/KeyMatcherPatternImpllUnitTest.java
@@ -35,7 +35,7 @@
{
// SETUP
int numToInsertPrefix1 = 10;
- Set<String> keyArray = new HashSet<String>();
+ Set<String> keyArray = new HashSet<>();
String keyprefix1 = "MyPrefixC";
@@ -45,7 +45,7 @@
keyArray.add(keyprefix1 + String.valueOf( i ));
}
- KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();
+ KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<>();
// DO WORK
Set<String> result1 = keyMatcher.getMatchingKeysFromArray( keyprefix1 + ".", keyArray );
@@ -61,7 +61,7 @@
{
// SETUP
int numToInsertPrefix1 = 10;
- Set<String> keyArray = new HashSet<String>();
+ Set<String> keyArray = new HashSet<>();
String keyprefix1 = "MyPrefixC";
@@ -71,7 +71,7 @@
keyArray.add(keyprefix1 + String.valueOf( i ));
}
- KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();
+ KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<>();
// DO WORK
Set<String> result1 = keyMatcher.getMatchingKeysFromArray( keyprefix1 + "\\S+", keyArray );
@@ -88,7 +88,7 @@
// SETUP
int numToInsertPrefix1 = 10;
int numToInsertPrefix2 = 50;
- Set<String> keyArray = new HashSet<String>();
+ Set<String> keyArray = new HashSet<>();
String keyprefix1 = "MyPrefixA";
String keyprefix2 = "MyPrefixB";
@@ -105,7 +105,7 @@
keyArray.add(keyprefix2 + String.valueOf( i ));
}
- KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<String>();
+ KeyMatcherPatternImpl<String> keyMatcher = new KeyMatcherPatternImpl<>();
// DO WORK
Set<String> result1 = keyMatcher.getMatchingKeysFromArray( keyprefix1 + ".+", keyArray );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/MockMemoryCache.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/MockMemoryCache.java
index 6a1f550..d4ba8ca 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/MockMemoryCache.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/MockMemoryCache.java
@@ -44,7 +44,7 @@
private ICompositeCacheAttributes cacheAttr;
/** Internal map */
- private final HashMap<K, ICacheElement<K, V>> map = new HashMap<K, ICacheElement<K, V>>();
+ private final HashMap<K, ICacheElement<K, V>> map = new HashMap<>();
/** The number of times waterfall was called. */
public int waterfallCallCount = 0;
@@ -93,7 +93,7 @@
@Override
public Set<K> getKeySet()
{
- return new LinkedHashSet<K>(map.keySet());
+ return new LinkedHashSet<>(map.keySet());
}
/**
@@ -139,7 +139,7 @@
public Map<K, ICacheElement<K, V>> getMultiple(Set<K> keys)
throws IOException
{
- Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>();
+ Map<K, ICacheElement<K, V>> elements = new HashMap<>();
if ( keys != null && !keys.isEmpty() )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/fifo/FIFOMemoryCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
index c3d82b3..35b6cff 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/fifo/FIFOMemoryCacheUnitTest.java
@@ -50,16 +50,16 @@
attributes.setMaxObjects( maxObjects );
attributes.setSpoolChunkSize( 1 );
- FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<String, String>();
- cache.initialize( new CompositeCache<String, String>( attributes, new ElementAttributes() ) );
+ FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<>();
+ cache.initialize( new CompositeCache<>( attributes, new ElementAttributes() ) );
for ( int i = 0; i <= maxObjects; i++ )
{
- CacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key" + i, "value" + i );
+ CacheElement<String, String> element = new CacheElement<>( cacheName, "key" + i, "value" + i );
cache.update( element );
}
- CacheElement<String, String> oneMoreElement = new CacheElement<String, String>( cacheName, "onemore", "onemore" );
+ CacheElement<String, String> oneMoreElement = new CacheElement<>( cacheName, "onemore", "onemore" );
// DO WORK
cache.update( oneMoreElement );
@@ -91,13 +91,13 @@
attributes.setMaxObjects( maxObjects );
attributes.setSpoolChunkSize( 1 );
- FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<String, String>();
- cache.initialize( new CompositeCache<String, String>( attributes, new ElementAttributes() ) );
+ FIFOMemoryCache<String, String> cache = new FIFOMemoryCache<>();
+ cache.initialize( new CompositeCache<>( attributes, new ElementAttributes() ) );
// DO WORK
for ( int i = 0; i <= (maxObjects * 2); i++ )
{
- CacheElement<String, String> element = new CacheElement<String, String>( cacheName, "key" + i, "value" + i );
+ CacheElement<String, String> element = new CacheElement<>( cacheName, "key" + i, "value" + i );
cache.update( element );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
index 733b3c7..e981456 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheConcurrentUnitTest.java
@@ -113,14 +113,14 @@
cacheMgr.configure( "/TestLHMLRUCache.ccf" );
CompositeCache<String, String> cache = cacheMgr.getCache( region );
- LRUMemoryCache<String, String> lru = new LRUMemoryCache<String, String>();
+ LRUMemoryCache<String, String> lru = new LRUMemoryCache<>();
lru.initialize( cache );
// Add items to cache
for ( int i = 0; i < items; i++ )
{
- ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", region + " data " + i );
+ ICacheElement<String, String> ice = new CacheElement<>( cache.getCacheName(), i + ":key", region + " data " + i );
ice.setElementAttributes( cache.getElementAttributes() );
lru.update( ice );
}
@@ -139,7 +139,7 @@
}
// Test that getMultiple returns all the items remaining in cache and none of the missing ones
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
index c8595b0..03adb35 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LHMLRUMemoryCacheUnitTest.java
@@ -95,7 +95,7 @@
}
// Test that getMultiple returns all the items remaining in cache and none of the missing ones
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
@@ -252,7 +252,7 @@
cacheMgr.configure( "/TestLHMLRUCache.ccf" );
CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" );
- LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<String, String>();
+ LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<>();
mru.initialize( cache );
int max = cache.getCacheAttributes().getMaxObjects();
@@ -260,7 +260,7 @@
for ( int i = 0; i < items; i++ )
{
- ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
+ ICacheElement<String, String> ice = new CacheElement<>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
ice.setElementAttributes( cache.getElementAttributes() );
mru.update( ice );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
index 3efcc77..031691d 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/lru/LRUMemoryCacheConcurrentUnitTest.java
@@ -112,14 +112,14 @@
cacheMgr.configure( "/TestDiskCache.ccf" );
CompositeCache<String, String> cache = cacheMgr.getCache( region );
- LRUMemoryCache<String, String> lru = new LRUMemoryCache<String, String>();
+ LRUMemoryCache<String, String> lru = new LRUMemoryCache<>();
lru.initialize( cache );
// Add items to cache
for ( int i = 0; i < items; i++ )
{
- ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", region + " data " + i );
+ ICacheElement<String, String> ice = new CacheElement<>( cache.getCacheName(), i + ":key", region + " data " + i );
ice.setElementAttributes( cache.getElementAttributes() );
lru.update( ice );
}
@@ -138,7 +138,7 @@
}
// Test that getMultiple returns all the items remaining in cache and none of the missing ones
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
index 093c14e..7b427d2 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/mru/MRUMemoryCacheUnitTest.java
@@ -95,7 +95,7 @@
}
// Test that getMultiple returns all the items remaining in cache and none of the missing ones
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
@@ -252,7 +252,7 @@
cacheMgr.configure( "/TestMRUCache.ccf" );
CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" );
- MRUMemoryCache<String, String> mru = new MRUMemoryCache<String, String>();
+ MRUMemoryCache<String, String> mru = new MRUMemoryCache<>();
mru.initialize( cache );
int max = cache.getCacheAttributes().getMaxObjects();
@@ -260,7 +260,7 @@
for ( int i = 0; i < items; i++ )
{
- ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
+ ICacheElement<String, String> ice = new CacheElement<>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
ice.setElementAttributes( cache.getElementAttributes() );
mru.update( ice );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
index f38e9f8..97511fe 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/shrinking/ShrinkerThreadUnitTest.java
@@ -51,12 +51,12 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
cacheAttr.setMaxSpoolPerRun( 10 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
String key = "key";
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
element.setElementAttributes( elementAttr );
@@ -86,12 +86,12 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
cacheAttr.setMaxSpoolPerRun( 10 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
String key = "key";
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
element.setElementAttributes( elementAttr );
@@ -121,12 +121,12 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
cacheAttr.setMaxSpoolPerRun( 10 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
String key = "key";
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
element.setElementAttributes( elementAttr );
@@ -157,12 +157,12 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 10 );
cacheAttr.setMaxSpoolPerRun( 10 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
String key = "key";
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
element.setElementAttributes( elementAttr );
@@ -198,13 +198,13 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
cacheAttr.setMaxSpoolPerRun( 10 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
MockMemoryCache<String, String> memory = (MockMemoryCache<String, String>)cache.getMemoryCache();
String key = "key";
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
@@ -219,7 +219,7 @@
ElementAttributesUtils.setLastAccessTime( elementAttr, System.currentTimeMillis() - 2000 );
// DO WORK
- ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>( cache );
+ ShrinkerThread<String, String> shrinker = new ShrinkerThread<>( cache );
shrinker.run();
Thread.sleep( 500 );
@@ -245,7 +245,7 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
cacheAttr.setMaxSpoolPerRun( 3 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
MockMemoryCache<String, String> memory = (MockMemoryCache<String, String>)cache.getMemoryCache();
for ( int i = 0; i < 10; i++ )
@@ -253,7 +253,7 @@
String key = "key" + i;
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.setIsEternal( false );
@@ -269,7 +269,7 @@
}
// DO WORK
- ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>( cache );
+ ShrinkerThread<String, String> shrinker = new ShrinkerThread<>( cache );
shrinker.run();
// VERIFY
@@ -295,7 +295,7 @@
cacheAttr.setMaxMemoryIdleTimeSeconds( 1 );
cacheAttr.setMaxSpoolPerRun( 3 );
- CompositeCache<String, String> cache = new CompositeCache<String, String>(cacheAttr, new ElementAttributes());
+ CompositeCache<String, String> cache = new CompositeCache<>(cacheAttr, new ElementAttributes());
MockMemoryCache<String, String> memory = (MockMemoryCache<String, String>)cache.getMemoryCache();
ElementEventHandlerMockImpl handler = new ElementEventHandlerMockImpl();
@@ -305,7 +305,7 @@
String key = "key" + i;
String value = "value";
- ICacheElement<String, String> element = new CacheElement<String, String>( "testRegion", key, value );
+ ICacheElement<String, String> element = new CacheElement<>( "testRegion", key, value );
ElementAttributes elementAttr = new ElementAttributes();
elementAttr.addElementEventHandler( handler );
@@ -322,7 +322,7 @@
}
// DO WORK
- ShrinkerThread<String, String> shrinker = new ShrinkerThread<String, String>( cache );
+ ShrinkerThread<String, String> shrinker = new ShrinkerThread<>( cache );
shrinker.run();
// VERIFY
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
index 68164b1..3a96d68 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/engine/memory/soft/SoftReferenceMemoryCacheUnitTest.java
@@ -98,7 +98,7 @@
}
// Test that getMultiple returns all the items remaining in cache and none of the missing ones
- Set<String> keys = new HashSet<String>();
+ Set<String> keys = new HashSet<>();
for ( int i = 0; i < items; i++ )
{
keys.add( i + ":key" );
@@ -187,7 +187,7 @@
cacheMgr.configure( "/TestSoftReferenceCache.ccf" );
CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" );
- SoftReferenceMemoryCache<String, String> srmc = new SoftReferenceMemoryCache<String, String>();
+ SoftReferenceMemoryCache<String, String> srmc = new SoftReferenceMemoryCache<>();
srmc.initialize( cache );
int max = cache.getCacheAttributes().getMaxObjects();
@@ -195,7 +195,7 @@
for ( int i = 0; i < items; i++ )
{
- ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
+ ICacheElement<String, String> ice = new CacheElement<>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i );
ice.setElementAttributes( cache.getElementAttributes() );
srmc.update( ice );
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/access/JCSWorkerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/access/JCSWorkerUnitTest.java
index 9f504fd..7dec5d3 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/access/JCSWorkerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/access/JCSWorkerUnitTest.java
@@ -42,7 +42,7 @@
public void testSimpleGet()
throws Exception
{
- JCSWorker<String, Long> cachingWorker = new JCSWorker<String, Long>( "example region" );
+ JCSWorker<String, Long> cachingWorker = new JCSWorker<>( "example region" );
// This is the helper.
JCSWorkerHelper<Long> helper = new AbstractJCSWorkerHelper<Long>()
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/MockDiscoveryListener.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/MockDiscoveryListener.java
index a8b5f75..746639a 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/MockDiscoveryListener.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/MockDiscoveryListener.java
@@ -29,7 +29,7 @@
implements IDiscoveryListener
{
/** discovered services. */
- public List<DiscoveredService> discoveredServices = new ArrayList<DiscoveredService>();
+ public List<DiscoveredService> discoveredServices = new ArrayList<>();
/**
* Adds the entry to a list. I'm not using a set. I want to see if we get dupes.
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
index 93ac1ff..c47b52e 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoverySenderUnitTest.java
@@ -87,7 +87,7 @@
throws Exception
{
// SETUP
- ArrayList<String> cacheNames = new ArrayList<String>();
+ ArrayList<String> cacheNames = new ArrayList<>();
// DO WORK
sender.passiveBroadcast( SENDING_HOST, SENDING_PORT, cacheNames, 1L );
@@ -114,7 +114,7 @@
throws Exception
{
// SETUP
- ArrayList<String> cacheNames = new ArrayList<String>();
+ ArrayList<String> cacheNames = new ArrayList<>();
// DO WORK
sender.removeBroadcast( SENDING_HOST, SENDING_PORT, cacheNames, 1L );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryServiceUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryServiceUnitTest.java
index a77b1c7..054c152 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryServiceUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryServiceUnitTest.java
@@ -48,7 +48,7 @@
DiscoveredService discoveredService = new DiscoveredService();
discoveredService.setServiceAddress( host );
- discoveredService.setCacheNames( new ArrayList<String>() );
+ discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
discoveredService.setLastHearFromTime( 100 );
@@ -81,7 +81,7 @@
MockDiscoveryListener discoveryListener = new MockDiscoveryListener();
service.addDiscoveryListener( discoveryListener );
- ArrayList<String> sametCacheNames = new ArrayList<String>();
+ ArrayList<String> sametCacheNames = new ArrayList<>();
sametCacheNames.add( "name1" );
DiscoveredService discoveredService = new DiscoveredService();
@@ -146,11 +146,11 @@
DiscoveredService discoveredService = new DiscoveredService();
discoveredService.setServiceAddress( host );
- discoveredService.setCacheNames( new ArrayList<String>() );
+ discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
discoveredService.setLastHearFromTime( 100 );
- ArrayList<String> differentCacheNames = new ArrayList<String>();
+ ArrayList<String> differentCacheNames = new ArrayList<>();
differentCacheNames.add( "name1" );
DiscoveredService discoveredService2 = new DiscoveredService();
discoveredService2.setServiceAddress( host );
@@ -208,7 +208,7 @@
DiscoveredService discoveredService = new DiscoveredService();
discoveredService.setServiceAddress( host );
- discoveredService.setCacheNames( new ArrayList<String>() );
+ discoveredService.setCacheNames( new ArrayList<>() );
discoveredService.setServicePort( 1000 );
discoveredService.setLastHearFromTime( 100 );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
index 3590038..32855c1 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/discovery/UDPDiscoveryUnitTest.java
@@ -63,7 +63,7 @@
// create more names than we have no wait facades for
// the only one that gets added should be testCache1
- ArrayList<String> cacheNames = new ArrayList<String>();
+ ArrayList<String> cacheNames = new ArrayList<>();
int numJunk = 10;
for ( int i = 0; i < numJunk; i++ )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
index df5cb2d..9f8b6a1 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/serialization/SerializationConversionUtilUnitTest.java
@@ -95,7 +95,7 @@
IElementAttributes attr = new ElementAttributes();
attr.setMaxLife(34);
- ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
+ ICacheElement<String, String> before = new CacheElement<>( cacheName, key, value );
before.setElementAttributes( attr );
// DO WORK
@@ -136,7 +136,7 @@
IElementAttributes attr = new ElementAttributes();
attr.setMaxLife(34);
- ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
+ ICacheElement<String, String> before = new CacheElement<>( cacheName, key, value );
before.setElementAttributes( attr );
// DO WORK
@@ -176,7 +176,7 @@
IElementAttributes attr = new ElementAttributes();
attr.setMaxLife(34);
- ICacheElement<String, String> before = new CacheElement<String, String>( cacheName, key, value );
+ ICacheElement<String, String> before = new CacheElement<>( cacheName, key, value );
before.setElementAttributes( attr );
// DO WORK
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/DoubleLinkedListUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/DoubleLinkedListUnitTest.java
index 46bad53..a7ca1d8 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/DoubleLinkedListUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/DoubleLinkedListUnitTest.java
@@ -32,10 +32,10 @@
public void testAddLast_Empty()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
// WO WORK
list.addLast( node1 );
@@ -48,13 +48,13 @@
public void testAddLast_NotEmpty()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
String payload2 = "payload2";
- DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 );
+ DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
// WO WORK
list.addLast( node1 );
@@ -68,13 +68,13 @@
public void testMakeLast_wasFirst()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
String payload2 = "payload2";
- DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 );
+ DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
list.addFirst( node2 );
list.addFirst( node1 );
@@ -92,13 +92,13 @@
public void testMakeLast_wasLast()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
String payload2 = "payload2";
- DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 );
+ DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
list.addFirst( node1 );
list.addFirst( node2 );
@@ -116,10 +116,10 @@
public void testMakeLast_wasAlone()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
list.addFirst( node1 );
@@ -136,16 +136,16 @@
public void testMakeLast_wasInMiddle()
{
// SETUP
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
String payload2 = "payload2";
- DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 );
+ DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
String payload3 = "payload3";
- DoubleLinkedListNode<String> node3 = new DoubleLinkedListNode<String>( payload3 );
+ DoubleLinkedListNode<String> node3 = new DoubleLinkedListNode<>( payload3 );
list.addFirst( node2 );
list.addFirst( node1 );
@@ -167,13 +167,13 @@
StringWriter stringWriter = new StringWriter();
TestLogConfigurationUtil.configureLogger( stringWriter, DoubleLinkedList.class.getName() );
- DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<DoubleLinkedListNode<String>>();
+ DoubleLinkedList<DoubleLinkedListNode<String>> list = new DoubleLinkedList<>();
String payload1 = "payload1";
- DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<String>( payload1 );
+ DoubleLinkedListNode<String> node1 = new DoubleLinkedListNode<>( payload1 );
String payload2 = "payload2";
- DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<String>( payload2 );
+ DoubleLinkedListNode<String> node2 = new DoubleLinkedListNode<>( payload2 );
list.addLast( node1 );
list.addLast( node2 );
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
index a09e025..be6b546 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/JCSvsCommonsLRUMapPerformanceTest.java
@@ -113,7 +113,7 @@
try
{
- Map<String, String> cache = new LRUMap<String, String>( tries );
+ Map<String, String> cache = new LRUMap<>( tries );
for ( int j = 0; j < loops; j++ )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapConcurrentUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapConcurrentUnitTest.java
index 6ce5625..46fbf8b 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapConcurrentUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapConcurrentUnitTest.java
@@ -57,7 +57,7 @@
TestSuite suite = new TestSuite( LRUMapConcurrentUnitTest.class );
// run concurrent tests
- final LRUMap<String, String> map = new LRUMap<String, String>( 2000 );
+ final LRUMap<String, String> map = new LRUMap<>( 2000 );
suite.addTest( new LRUMapConcurrentUnitTest( "conc1" )
{
@Override
@@ -88,7 +88,7 @@
// run more concurrent tests
final int max2 = 20000;
- final LRUMap<String, String> map2 = new LRUMap<String, String>( max2 );
+ final LRUMap<String, String> map2 = new LRUMap<>( max2 );
suite.addTest( new LRUMapConcurrentUnitTest( "concB1" )
{
@Override
@@ -120,7 +120,7 @@
public void testSimpleLoad()
throws Exception
{
- LRUMap<String, String> map = new LRUMap<String, String>( items );
+ LRUMap<String, String> map = new LRUMap<>( items );
for ( int i = 0; i < items; i++ )
{
@@ -149,7 +149,7 @@
throws Exception
{
int total = 10;
- LRUMap<String, String> map = new LRUMap<String, String>( total );
+ LRUMap<String, String> map = new LRUMap<>( total );
// put the max in
for ( int i = 0; i < total; i++ )
@@ -187,7 +187,7 @@
throws Exception
{
int total = 10000;
- LRUMap<String, String> map = new LRUMap<String, String>( total );
+ LRUMap<String, String> map = new LRUMap<>( total );
// put the max in
for ( int i = 0; i < total * 2; i++ )
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapPerformanceTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapPerformanceTest.java
index e11d7ab..188ee83 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapPerformanceTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapPerformanceTest.java
@@ -107,7 +107,7 @@
try
{
- LRUMap<String, String> cache = new LRUMap<String, String>( tries );
+ LRUMap<String, String> cache = new LRUMap<>( tries );
for ( int j = 0; j < loops; j++ )
{
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapUnitTest.java
index e05c95d..3d33c95 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/struct/LRUMapUnitTest.java
@@ -42,7 +42,7 @@
public void testPutWithSizeLimit()
{
int size = 10;
- Map<String, String> cache = new LRUMap<String, String>( size );
+ Map<String, String> cache = new LRUMap<>( size );
for ( int i = 0; i < size; i++ )
{
@@ -63,7 +63,7 @@
public void testPutWithNoSizeLimit()
{
int size = 10;
- Map<String, String> cache = new LRUMap<String, String>( );
+ Map<String, String> cache = new LRUMap<>( );
for ( int i = 0; i < size; i++ )
{
@@ -84,7 +84,7 @@
public void testPutAndRemove()
{
int size = 10;
- Map<String, String> cache = new LRUMap<String, String>( size );
+ Map<String, String> cache = new LRUMap<>( size );
cache.put( "key:" + 1, "data:" + 1 );
String data = cache.remove( "key:" + 1 );
@@ -98,7 +98,7 @@
public void testRemoveEmpty()
{
int size = 10;
- Map<String, String> cache = new LRUMap<String, String>( size );
+ Map<String, String> cache = new LRUMap<>( size );
Object returned = cache.remove( "key:" + 1 );
assertNull( "Shouldn't hvae anything.", returned );
@@ -112,7 +112,7 @@
public void testGetEntrySet()
{
int size = 10;
- Map<String, String> cache = new LRUMap<String, String>( size );
+ Map<String, String> cache = new LRUMap<>( size );
for ( int i = 0; i < size; i++ )
{