Remove deprecated code
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/jcs/trunk@1809534 13f79535-47bb-0310-9956-ffa450edef68
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 a51da23..282988b 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
@@ -49,65 +49,6 @@
private static CompositeCacheManager cacheMgr;
/**
- * Define a new cache region with the given name. In the oracle specification, these attributes
- * are global and not region specific, regional overrides is a value add each region should be
- * able to house both cache and element attribute sets. It is more efficient to define a cache
- * in the props file and then strictly use the get access method. Use of the define region
- * outside of an initialization block should be avoided.
- * <p>
- * @param name Name that will identify the region
- * @return CacheAccess instance for the new region
- * @throws CacheException
- *
- * @deprecated Duplicate of getInstance(String)
- */
- @Deprecated
- public static <K, V> CacheAccess<K, V> defineRegion( String name )
- throws CacheException
- {
- CompositeCache<K, V> cache = getCacheManager().getCache( name );
- return new CacheAccess<K, V>( cache );
- }
-
- /**
- * Define a new cache region with the specified name and attributes.
- * <p>
- * @param name Name that will identify the region
- * @param cattr CompositeCacheAttributes for the region
- * @return CacheAccess instance for the new region
- * @throws CacheException
- *
- * @deprecated Duplicate of getInstance(String, ICompositeCacheAttributes)
- */
- @Deprecated
- public static <K, V> CacheAccess<K, V> defineRegion( String name, ICompositeCacheAttributes cattr )
- throws CacheException
- {
- CompositeCache<K, V> cache = getCacheManager().getCache( name, cattr );
- return new CacheAccess<K, V>( cache );
- }
-
- /**
- * Define a new cache region with the specified name and attributes and return a CacheAccess to
- * it.
- * <p>
- * @param name Name that will identify the region
- * @param cattr CompositeCacheAttributes for the region
- * @param attr Attributes for the region
- * @return CacheAccess instance for the new region
- * @throws CacheException
- *
- * @deprecated Duplicate of getInstance(String, ICompositeCacheAttributes, IElementAttributes)
- */
- @Deprecated
- public static <K, V> CacheAccess<K, V> defineRegion( String name, ICompositeCacheAttributes cattr, IElementAttributes attr )
- throws CacheException
- {
- CompositeCache<K, V> cache = getCacheManager().getCache( name, cattr, attr );
- return new CacheAccess<K, V>( cache );
- }
-
- /**
* Set the filename that the cache manager will be initialized with. Only matters before the
* instance is initialized.
* <p>
@@ -221,7 +162,7 @@
CompositeCache<K, V> cache = getCacheManager().getCache( region, icca, eattr );
return new CacheAccess<K, V>( cache );
}
-
+
/**
* Get a GroupCacheAccess which accesses the provided region.
* <p>
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 261026a..8d3e046 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
@@ -375,19 +375,6 @@
* Calculates the file offset for a particular block.
* <p>
* @param block number
- * @return the byte offset for this block in the file as an int; may overflow
- * @deprecated (since 2.0) use {@link #calculateByteOffsetForBlockAsLong(int)} instead
- */
- @Deprecated
- protected int calculateByteOffsetForBlock( int block )
- {
- return block * blockSizeBytes;
- }
-
- /**
- * Calculates the file offset for a particular block.
- * <p>
- * @param block number
* @return the byte offset for this block in the file as a long
* @since 2.0
*/
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 30ae72c..da541d5 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
@@ -30,9 +30,7 @@
import org.apache.commons.jcs.auxiliary.AbstractAuxiliaryCache;
import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
import org.apache.commons.jcs.engine.CacheStatus;
-import org.apache.commons.jcs.engine.behavior.ICache;
import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
import org.apache.commons.jcs.engine.behavior.IElementSerializer;
import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
import org.apache.commons.jcs.engine.stats.StatElement;
@@ -82,37 +80,6 @@
}
/**
- * Constructs with the given remote cache, and fires events to any listeners.
- * <p>
- * @param noWaits
- * @param rca
- * @param cacheMgr
- * @param cacheEventLogger
- * @param elementSerializer
- * @deprecated Unused parameter cacheMgr scheduled for removal
- */
- @Deprecated
- public AbstractRemoteCacheNoWaitFacade( List<ICache<K, V>> noWaits, RemoteCacheAttributes rca,
- ICompositeCacheManager cacheMgr, ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer )
- {
- if ( log.isDebugEnabled() )
- {
- log.debug( "CONSTRUCTING NO WAIT FACADE" );
- }
- this.remoteCacheAttributes = rca;
- setCacheEventLogger( cacheEventLogger );
- setElementSerializer( elementSerializer );
- this.noWaits = new ArrayList<RemoteCacheNoWait<K,V>>();
- for (ICache<K, V> nw : noWaits)
- {
- RemoteCacheNoWait<K,V> rcnw = (RemoteCacheNoWait<K,V>)nw;
- ((RemoteCache<K, V>)rcnw.getRemoteCache()).setFacade(this);
- this.noWaits.add(rcnw);
- }
- }
-
- /**
* Put an element in the cache.
* <p>
* @param ce
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 eb88eed..3fd4e46 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
@@ -24,8 +24,6 @@
import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheAttributes;
import org.apache.commons.jcs.auxiliary.remote.server.behavior.RemoteType;
import org.apache.commons.jcs.engine.CacheStatus;
-import org.apache.commons.jcs.engine.behavior.ICache;
-import org.apache.commons.jcs.engine.behavior.ICompositeCacheManager;
import org.apache.commons.jcs.engine.behavior.IElementSerializer;
import org.apache.commons.jcs.engine.logging.behavior.ICacheEventLogger;
import org.apache.commons.logging.Log;
@@ -68,29 +66,6 @@
}
/**
- * Constructs with the given remote cache, and fires events to any listeners.
- * <p>
- * @param noWaits
- * @param rca
- * @param cacheMgr
- * @param cacheEventLogger
- * @param elementSerializer
- * @param cacheFactory
- * @deprecated Unused parameter cacheMgr scheduled for removal
- */
- @Deprecated
- public RemoteCacheNoWaitFacade( List<ICache<K, V>> noWaits,
- RemoteCacheAttributes rca,
- ICompositeCacheManager cacheMgr,
- ICacheEventLogger cacheEventLogger,
- IElementSerializer elementSerializer,
- RemoteCacheFactory cacheFactory)
- {
- super( noWaits, rca, cacheMgr, cacheEventLogger, elementSerializer );
- this.cacheFactory = cacheFactory;
- }
-
- /**
* Begin the failover process if this is a local cache. Clustered remote caches do not failover.
* <p>
* @param rcnw The no wait in error.
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 271f7ca..507f109 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
@@ -36,7 +36,6 @@
import java.util.concurrent.locks.ReentrantLock;
import org.apache.commons.jcs.access.exception.CacheException;
-import org.apache.commons.jcs.auxiliary.remote.RemoteUtils;
import org.apache.commons.jcs.auxiliary.remote.behavior.IRemoteCacheListener;
import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServer;
import org.apache.commons.jcs.auxiliary.remote.server.behavior.IRemoteCacheServerAttributes;
@@ -127,7 +126,7 @@
* Constructor for the RemoteCacheServer object. This initializes the server with the values
* from the properties object.
* <p>
- * @param rcsa
+ * @param rcsa
* @param config cache hub configuration
* @throws RemoteException
*/
@@ -157,69 +156,6 @@
}
/**
- * Constructor for the RemoteCacheServer object. This initializes the server with the values
- * from the config file.
- * <p>
- * @param rcsa
- * @throws RemoteException
- *
- * @deprecated Use version with Properties object instead
- */
- @Deprecated
- protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa )
- throws RemoteException
- {
- super( rcsa.getServicePort() );
- this.remoteCacheServerAttributes = rcsa;
- init( rcsa.getConfigFileName() );
- }
-
- /**
- * Constructor for the RemoteCacheServer object. This initializes the server with the values
- * from the config file.
- * <p>
- * @param rcsa
- * @param customRMISocketFactory
- * @throws RemoteException
- *
- * @deprecated Use version with Properties object instead
- */
- @Deprecated
- protected RemoteCacheServer( IRemoteCacheServerAttributes rcsa, RMISocketFactory customRMISocketFactory )
- throws RemoteException
- {
- super( rcsa.getServicePort(), customRMISocketFactory, customRMISocketFactory );
- this.remoteCacheServerAttributes = rcsa;
- init( rcsa.getConfigFileName() );
- }
-
- /**
- * Initialize the RMI Cache Server from a properties file.
- * <p>
- * @param prop
- * @throws RemoteException if the configuration of the cache manager instance fails
- *
- * @deprecated Use version with Properties parameter instead
- */
- @Deprecated
- private void init( String propFile ) throws RemoteException
- {
- String propFileName = propFile == null ? DFEAULT_REMOTE_CONFIGURATION_FILE : propFile;
-
- Properties prop = null;
- try
- {
- prop = RemoteUtils.loadProps(propFileName);
- }
- catch (IOException e)
- {
- throw new RemoteException(e.getMessage(), e);
- }
-
- init(prop);
- }
-
- /**
* Initialize the RMI Cache Server from a properties object.
* <p>
* @param prop the configuration properties
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 2b6f1a3..e0c616e 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
@@ -94,56 +94,6 @@
* <p>
* A remote cache is either a local cache or a cluster cache.
* <p>
- * @param host the host name
- * @param port the port number
- * @param propFile the remote cache hub configuration file
- * @throws IOException
- *
- * @deprecated Use startup(String, int, Properties) instead
- */
- @Deprecated
- public static void startup( String host, int port, String propFile )
- throws IOException
- {
- if ( log.isInfoEnabled() )
- {
- log.info( "ConfigFileName = [" + propFile + "]" );
- }
- Properties props = RemoteUtils.loadProps( propFile );
- startup(host, port, props);
- }
-
- /**
- * Starts up the remote cache server on this JVM, and binds it to the registry on the given host
- * and port.
- * <p>
- * A remote cache is either a local cache or a cluster cache.
- * <p>
- * @param host the host name
- * @param port the port number
- * @param props the remote cache hub configuration
- * @param propFile the remote cache hub configuration file
- * @throws IOException
- *
- * @deprecated Use startup(String, int, Properties) instead
- */
- @Deprecated
- public static void startup( String host, int port, Properties props, String propFile )
- throws IOException
- {
- if ( log.isWarnEnabled() )
- {
- log.warn( "ConfigFileName = [" + propFile + "] ignored" );
- }
- startup(host, port, props);
- }
-
- /**
- * Starts up the remote cache server on this JVM, and binds it to the registry on the given host
- * and port.
- * <p>
- * A remote cache is either a local cache or a cluster cache.
- * <p>
* @param host
* @param port
* @param props
@@ -516,12 +466,12 @@
/**
* Look up the remote cache service admin instance
- *
+ *
* @param config the configuration properties
* @param port the local port
* @return the admin object instance
- *
- * @throws Exception if lookup fails
+ *
+ * @throws Exception if lookup fails
*/
private static ICacheServiceAdmin lookupCacheServiceAdmin(Properties config, int port) throws Exception
{
@@ -537,10 +487,10 @@
{
log.debug( "server found" );
}
-
+
return (ICacheServiceAdmin) obj;
}
-
+
/**
* @param serviceName the serviceName to set
*/
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
index 9f37b0c..55b0af8 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/AbstractCacheEventQueue.java
@@ -102,33 +102,6 @@
}
/**
- * If they queue has an active thread it is considered alive.
- * <p>
- * @return The alive value
- *
- * @deprecated The alive-logic is not used
- */
- @Deprecated
- @Override
- public boolean isAlive()
- {
- return true;
- }
-
- /**
- * Sets whether the queue is actively processing -- if there are working threads.
- * <p>
- * @param aState
- *
- * @deprecated The alive-logic is not used
- */
- @Deprecated
- public void setAlive( boolean aState )
- {
- // do nothing
- }
-
- /**
* @return The listenerId value
*/
@Override
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/ICacheEventQueue.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/ICacheEventQueue.java
index a29ed33..3676385 100644
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/ICacheEventQueue.java
+++ b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/behavior/ICacheEventQueue.java
@@ -95,15 +95,6 @@
void destroy();
/**
- * Gets the alive attribute of the ICacheEventQueue object. Alive just
- * indicates that there are active threads. This is less important that if
- * the queue is working.
- * <p>
- * @return The alive value
- */
- boolean isAlive();
-
- /**
* A Queue is working unless it has reached its max failure count.
* <p>
* @return boolean
diff --git a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/DefaultMemoryElementDescriptor.java b/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/DefaultMemoryElementDescriptor.java
deleted file mode 100644
index e06b2f6..0000000
--- a/commons-jcs-core/src/main/java/org/apache/commons/jcs/engine/memory/util/DefaultMemoryElementDescriptor.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package org.apache.commons.jcs.engine.memory.util;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import org.apache.commons.jcs.engine.behavior.ICacheElement;
-
-/**
- * This wrapper is needed for double linked lists.
- *
- * @deprecated Use MemoryElementDescriptor directly
- */
-@Deprecated
-public class DefaultMemoryElementDescriptor<K, V>
- extends MemoryElementDescriptor<K, V>
-{
- /** Don't change */
- private static final long serialVersionUID = -1905161209035522460L;
-
- /**
- * Constructs a usable MemoryElementDescriptor.
- * <p>
- * @param ce
- */
- public DefaultMemoryElementDescriptor( ICacheElement<K, V> ce )
- {
- super( ce );
- }
-}
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 93ca842..44a73bb 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
@@ -107,7 +107,7 @@
{
return createPool(config, threadNamePrefix, Thread.NORM_PRIORITY);
}
-
+
/**
* Creates a pool based on the configuration info.
* <p>
@@ -183,12 +183,12 @@
public ScheduledExecutorService createSchedulerPool( PoolConfiguration config, String threadNamePrefix, int threadPriority )
{
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(
- config.getMaximumPoolSize(),
+ config.getMaximumPoolSize(),
new DaemonThreadFactory(threadNamePrefix, threadPriority));
return scheduler;
}
-
+
/**
* Returns a configured instance of the ThreadPoolManger To specify a configuration file or
* Properties object to use call the appropriate setter prior to calling getInstance.
@@ -222,7 +222,7 @@
log.warn("Failed to close pool " + pool, t);
}
}
-
+
for ( ScheduledExecutorService pool : INSTANCE.schedulerPools.values() )
{
try
@@ -234,7 +234,7 @@
log.warn("Failed to close pool " + pool, t);
}
}
-
+
INSTANCE = null;
}
}
@@ -280,23 +280,6 @@
return pool;
}
-
- /**
- * Returns a pool by name. If a pool by this name does not exist in the configuration file or
- * properties, one will be created using the default values.
- * <p>
- * Pools are lazily created.
- * <p>
- * @param name
- * @return The thread pool configured for the name.
- *
- * @deprecated Use getExecutorService() instead
- */
- @Deprecated
- public ThreadPoolExecutor getPool( String name )
- {
- return (ThreadPoolExecutor) getExecutorService(name);
- }
/**
* Returns a scheduler pool by name. If a pool by this name does not exist in the configuration file or
@@ -389,7 +372,7 @@
{
return loadConfig(root, defaultConfig);
}
-
+
/**
* Configures the PoolConfiguration settings.
* <p>
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 231841a..dbca37e 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
@@ -8,7 +8,6 @@
import org.apache.commons.jcs.engine.CacheElement;
import org.apache.commons.jcs.engine.CacheStatus;
import org.apache.commons.jcs.engine.behavior.ICacheElement;
-import org.apache.commons.jcs.engine.behavior.ICacheEventQueue;
import org.apache.commons.jcs.utils.timing.SleepUtil;
/*
@@ -205,11 +204,8 @@
noWait.update( element );
SleepUtil.sleepAtLeast( 10 );
- ICacheEventQueue<String, String> newQueue = noWait.getCacheEventQueue();
// VERIFY
assertEquals( "Wrong status", service, client.fixed );
- // assertFalse( "Original queue should not alive", originalQueue.isAlive() );
- assertTrue( "New queue should be alive." + newQueue, newQueue.isAlive() );
}
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
index 1c89cc5..753e775 100644
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
+++ b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
@@ -21,9 +21,7 @@
import java.util.ArrayList;
import java.util.Properties;
-import java.util.concurrent.RejectedExecutionHandler;
-import java.util.concurrent.ThreadPoolExecutor;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.ExecutorService;
import org.apache.commons.jcs.utils.props.PropertyLoader;
@@ -49,19 +47,8 @@
ThreadPoolManager mgr = ThreadPoolManager.getInstance();
assertNotNull( mgr );
- ThreadPoolExecutor pool = mgr.getPool( "test1" );
+ ExecutorService pool = mgr.getExecutorService( "test1" );
assertNotNull( pool );
-
- int poolSize = pool.getPoolSize();
- int expectedPoolSize = Integer.parseInt( props.getProperty( "thread_pool.test1.startUpSize" ) );
- assertEquals( poolSize, expectedPoolSize );
-
- // int qs = ((BoundedBuffer)pool.getQueue()).size();
-
- int max = pool.getMaximumPoolSize();
-
- int expected = Integer.parseInt( props.getProperty( "thread_pool.test1.maximumPoolSize" ) );
- assertEquals(expected, max );
}
/**
@@ -74,46 +61,8 @@
ThreadPoolManager mgr = ThreadPoolManager.getInstance();
assertNotNull( mgr );
- ThreadPoolExecutor pool = mgr.getPool( "aborttest" );
+ ExecutorService pool = mgr.getExecutorService( "aborttest" );
assertNotNull( pool );
-
- int poolSize = pool.getCorePoolSize();
- int expectedPoolSize = Integer.parseInt( props.getProperty( "thread_pool.aborttest.startUpSize" ) );
- assertEquals( expectedPoolSize, poolSize);
-
- int minPoolSize = pool.getPoolSize();
- int expectedMinPoolSize = Integer.parseInt( props.getProperty( "thread_pool.aborttest.minimumPoolSize" ) );
- assertEquals( expectedMinPoolSize, minPoolSize );
-
- int maxPoolSize = pool.getMaximumPoolSize();
- int expectedMaxPoolSize = Integer.parseInt( props.getProperty( "thread_pool.aborttest.maximumPoolSize" ) );
- assertEquals( expectedMaxPoolSize, maxPoolSize );
-
- long keepAliveTime = pool.getKeepAliveTime(TimeUnit.MILLISECONDS);
- long expectedKeepAliveTime = Long.parseLong( props.getProperty( "thread_pool.aborttest.keepAliveTime" ) );
- assertEquals( expectedKeepAliveTime, keepAliveTime );
-
- RejectedExecutionHandler whenBlockedPolicy = pool.getRejectedExecutionHandler();
- assertTrue( whenBlockedPolicy instanceof ThreadPoolExecutor.AbortPolicy );
- }
-
- /**
- * Try to get an undefined pool from an existing default file.
- */
- public void testDefaultConfigUndefinedPool()
- {
- Properties props = PropertyLoader.loadProperties( "thread_pool.properties" );
- ThreadPoolManager.setProps( props );
- ThreadPoolManager mgr = ThreadPoolManager.getInstance();
- assertNotNull( mgr );
-
- ThreadPoolExecutor pool = mgr.getPool( "doesnotexist" );
- assertNotNull( pool );
-
- int max = pool.getMaximumPoolSize();
-
- int expected = Integer.parseInt( props.getProperty( "thread_pool.default.maximumPoolSize" ) );
- assertEquals( expected, max );
}
/**
@@ -135,40 +84,4 @@
assertTrue( "Should have name in list.", names.contains( poolName1 ) );
assertTrue( "Should have name in list.", names.contains( poolName2 ) );
}
-
- /**
- * Verify that if we specify not to use a buffer boundary that we get a
- * linked queue.
- *
- */
-// public void testNoBoundary()
-// {
-// ThreadPoolManager.setPropsFileName( "thread_pool.properties" );
-// ThreadPoolManager mgr = ThreadPoolManager.getInstance();
-// assertNotNull( mgr );
-//
-// ThreadPoolExecutor pool = mgr.getPool( "nobound" );
-// assertNotNull( "Should have gotten back a pool.", pool );
-//
-// assertTrue( "Should have a linked queue and not a bounded buffer.", pool.getQueue() instanceof LinkedQueue );
-// }
-
- /**
- * Verify that if we specify useBoundary=true that we get a BoundedBuffer.
- *
- */
-// public void testWithBoundary()
-// {
-// // SETUP
-// ThreadPoolManager.setPropsFileName( "thread_pool.properties" );
-// ThreadPoolManager mgr = ThreadPoolManager.getInstance();
-// assertNotNull( mgr );
-//
-// // DO WORK
-// ThreadPoolExecutor pool = mgr.getPool( "withbound" );
-//
-// // VERIFY
-// assertNotNull( "Should have gotten back a pool.", pool );
-// assertTrue( "Should have a BoundedBuffer and not a linked queue.", pool.getQueue() instanceof BoundedBuffer );
-// }
}
diff --git a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolUnitTest.java b/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolUnitTest.java
deleted file mode 100644
index 17f02a5..0000000
--- a/commons-jcs-core/src/test/java/org/apache/commons/jcs/utils/threadpool/ThreadPoolUnitTest.java
+++ /dev/null
@@ -1,87 +0,0 @@
-package org.apache.commons.jcs.utils.threadpool;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import junit.framework.TestCase;
-
-import java.util.concurrent.ThreadPoolExecutor;
-
-/**
- * This test is experimental. I'm trying to find out if the max size setting will result in the
- * removal of threads.
- * <p>
- * @author Aaron Smuts
- */
-public class ThreadPoolUnitTest
- extends TestCase
-{
- /**
- * Make sure that the max size setting takes effect before the idle time is reached.
- * <p>
- * We just want to ensure that we can adjust the max size of an active pool.
- * <p>
- * http://gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/PooledExecutor.html#setMaximumPoolSize(int)
- * @throws Exception
- */
- public void testMaxReduction()
- throws Exception
- {
- //ThreadPoolManager.setPropsFileName( "thread_pool_test.properties" );
- ThreadPoolExecutor pool = ThreadPoolManager.getInstance().getPool( "maxtest" );
-
- //System.out.println( "pool = " + pool );
- pool.setMaximumPoolSize( 5 );
- //System.out.println( "current size before execute = " + pool.getPool().getPoolSize() );
-
- // add 6
- for ( int i = 1; i < 30; i++ )
- {
- final int cnt = i;
- pool.execute( new Runnable()
- {
-
- @Override
- public void run()
- {
- try
- {
- //System.out.println( cnt );
-// System.out.println( "count = " + cnt + " before sleep current size = " + myPool.getPoolSize() );
- Thread.sleep( 200 / cnt );
- //System.out.println( "count = " + cnt + " after sleep current size = " + myPool.getPool().getPoolSize() );
- }
- catch ( InterruptedException e )
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- } );
- }
-
- //System.out.println( "current size = " + pool.getPool().getPoolSize() );
- pool.setMaximumPoolSize( 4 );
- //Thread.sleep( 200 );
- //System.out.println( "current size after set size to 4= " + pool.getPool().getPoolSize() );
- Thread.sleep( 200 );
- //System.out.println( "current size again after sleep = " + pool.getPool().getPoolSize() );
- assertEquals( "Pool size should have been reduced.", 4, pool.getPoolSize() );
- }
-}