cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anathan...@apache.org
Subject svn commit: r1853899 - in /cocoon/branches/BRANCH_2_1_X/src: java/org/apache/cocoon/components/thread/DefaultRunnableManager.java test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java
Date Tue, 19 Feb 2019 17:10:10 GMT
Author: anathaniel
Date: Tue Feb 19 17:10:09 2019
New Revision: 1853899

URL: http://svn.apache.org/viewvc?rev=1853899&view=rev
Log:
Fix DefaultRunnableManagerTestCase

Modified:
    cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
    cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java

Modified: cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java?rev=1853899&r1=1853898&r2=1853899&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/java/org/apache/cocoon/components/thread/DefaultRunnableManager.java
Tue Feb 19 17:10:09 2019
@@ -27,6 +27,7 @@ import org.apache.avalon.framework.threa
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.LinkedHashMap;
 import java.util.Map;
 import java.util.SortedSet;
 import java.util.TreeSet;
@@ -111,13 +112,13 @@ public class DefaultRunnableManager
      * Sorted set of <code>ExecutionInfo</code> instances, based on their next
      * execution time.
      */
-    protected SortedSet m_commandStack = new TreeSet(  );
+    protected final SortedSet<ExecutionInfo> m_commandStack = new TreeSet<ExecutionInfo>();
 
-    /** The managed thread pools */
-    final Map m_pools = new HashMap(  );
+    /** The managed thread pools. Use LinkedHashMap to preserve order for test cases. */
+    final Map<String, DefaultThreadPool> m_pools = new LinkedHashMap<String, DefaultThreadPool>();
 
     /** The configured default ThreadFactory class instance */
-    private Class m_defaultThreadFactoryClass;
+    private Class<?> m_defaultThreadFactoryClass;
 
     /** Keep us running? */
     private boolean m_keepRunning = false;
@@ -147,14 +148,13 @@ public class DefaultRunnableManager
         final Configuration [] threadpools =
             config.getChild( "thread-pools" ).getChildren( "thread-pool" );
 
-        for( int i = 0; i < threadpools.length; i++ )
+        for (Configuration threadpool : threadpools)
         {
-            final DefaultThreadPool pool = configThreadPool( threadpools[ i ] );
+            configThreadPool(threadpool);
         }
 
         // Check if a "default" pool has been created
-        final ThreadPool defaultThreadPool =
-            (ThreadPool)m_pools.get( DEFAULT_THREADPOOL_NAME );
+        final ThreadPool defaultThreadPool = m_pools.get(DEFAULT_THREADPOOL_NAME);
 
         if( null == defaultThreadPool )
         {
@@ -260,11 +260,9 @@ public class DefaultRunnableManager
             getLogger(  ).debug( "Disposing all thread pools" );
         }
 
-        for( final Iterator i = m_pools.keySet(  ).iterator(  ); i.hasNext(  ); )
+        for (final String poolName : m_pools.keySet())
         {
-            final String poolName = (String)i.next(  );
-            final DefaultThreadPool pool =
-                (DefaultThreadPool)m_pools.get( poolName );
+            final DefaultThreadPool pool = m_pools.get(poolName);
 
             if( getLogger(  ).isDebugEnabled(  ) )
             {
@@ -316,14 +314,14 @@ public class DefaultRunnableManager
             throw new IllegalArgumentException( "interval < 0" );
         }
 
-        ThreadPool pool = (ThreadPool)m_pools.get( threadPoolName );
+        ThreadPool pool = m_pools.get(threadPoolName);
 
         if( null == pool )
         {
             getLogger(  ).warn( "ThreadPool \"" + threadPoolName +
                                 "\" is not known. Will use ThreadPool \"" +
                                 DEFAULT_THREADPOOL_NAME + "\"" );
-            pool = (ThreadPool)m_pools.get( DEFAULT_THREADPOOL_NAME );
+            pool = m_pools.get(DEFAULT_THREADPOOL_NAME);
         }
 
         if( getLogger(  ).isDebugEnabled(  ) )
@@ -407,9 +405,9 @@ public class DefaultRunnableManager
     {
         synchronized( m_commandStack )
         {
-            for( final Iterator i = m_commandStack.iterator(  ); i.hasNext(  ); )
+            for (final Iterator<ExecutionInfo> i = m_commandStack.iterator(); i.hasNext();)
             {
-                final ExecutionInfo info = (ExecutionInfo)i.next(  );
+                final ExecutionInfo info = i.next();
 
                 if( info.m_command == command )
                 {
@@ -443,8 +441,7 @@ public class DefaultRunnableManager
                 {
                     if( m_commandStack.size(  ) > 0 )
                     {
-                        final ExecutionInfo info =
-                            (ExecutionInfo)m_commandStack.first(  );
+                        final ExecutionInfo info = m_commandStack.first();
                         final long delay =
                             info.m_nextRun - System.currentTimeMillis(  );
 
@@ -475,8 +472,7 @@ public class DefaultRunnableManager
                 {
                     if( m_commandStack.size(  ) > 0 )
                     {
-                        final ExecutionInfo info =
-                            (ExecutionInfo)m_commandStack.first(  );
+                        final ExecutionInfo info = m_commandStack.first();
                         final long delay =
                             info.m_nextRun - System.currentTimeMillis(  );
 
@@ -508,16 +504,13 @@ public class DefaultRunnableManager
         }
 
         m_keepRunning = true;
-        ( (ThreadPool) m_pools.get( DEFAULT_THREADPOOL_NAME ) ).execute( this );
+        m_pools.get(DEFAULT_THREADPOOL_NAME).execute(this);
     }
 
     /**
      * Stop the managing thread
-     *
-     * @throws Exception DOCUMENT ME!
      */
-    public void stop(  )
-        throws Exception
+    public void stop()
     {
         m_keepRunning = false;
 
@@ -642,7 +635,7 @@ public class DefaultRunnableManager
         pool.enableLogging( getLogger(  ).getChildLogger( name ) );
         pool.setName( name );
 
-        ThreadFactory factory = null;
+        ThreadFactory factory;
         try
         {
             factory =
@@ -703,31 +696,28 @@ public class DefaultRunnableManager
         {
             if( pool.isQueued(  ) )
             {
-                final StringBuffer msg = new StringBuffer(  );
-                msg.append( "ThreadPool named \"" ).append( pool.getName(  ) );
-                msg.append( "\" created with maximum queue-size=" );
-                msg.append( pool.getMaxQueueSize(  ) );
-                msg.append( ",max-pool-size=" ).append( pool.getMaximumPoolSize(  ) );
-                msg.append( ",min-pool-size=" ).append( pool.getMinimumPoolSize(  ) );
-                msg.append( ",priority=" ).append( pool.getPriority(  ) );
-                msg.append( ",isDaemon=" ).append( ( (ThreadFactory)pool.getThreadFactory(
 ) ).isDaemon(  ) );
-                msg.append( ",keep-alive-time-ms=" ).append( pool.getKeepAliveTime(  ) );
-                msg.append( ",block-policy=\"" ).append( pool.getBlockPolicy(  ) );
-                msg.append( "\",shutdown-wait-time-ms=" ).append( pool.getShutdownWaitTimeMs(
 ) );
-                getLogger(  ).info( msg.toString(  ) );
+                String msg = "ThreadPool named \"" + pool.getName()
+                        + "\" created with maximum queue-size=" + pool.getMaxQueueSize()
+                        + ",max-pool-size=" + pool.getMaximumPoolSize()
+                        + ",min-pool-size=" + pool.getMinimumPoolSize()
+                        + ",priority=" + pool.getPriority()
+                        + ",isDaemon=" + ((ThreadFactory) pool.getThreadFactory()).isDaemon()
+                        + ",keep-alive-time-ms=" + pool.getKeepAliveTime()
+                        + ",block-policy=\"" + pool.getBlockPolicy()
+                        + "\",shutdown-wait-time-ms=" + pool.getShutdownWaitTimeMs();
+                getLogger().info(msg);
             }
             else
             {
-                final StringBuffer msg = new StringBuffer(  );
-                msg.append( "ThreadPool named \"" ).append( pool.getName(  ) );
-                msg.append( "\" created with no queue,max-pool-size=" ).append( pool.getMaximumPoolSize(
 ) );
-                msg.append( ",min-pool-size=" ).append( pool.getMinimumPoolSize(  ) );
-                msg.append( ",priority=" ).append( pool.getPriority(  ) );
-                msg.append( ",isDaemon=" ).append( ( (ThreadFactory)pool.getThreadFactory(
 ) ).isDaemon(  ) );
-                msg.append( ",keep-alive-time-ms=" ).append( pool.getKeepAliveTime(  ) );
-                msg.append( ",block-policy=" ).append( pool.getBlockPolicy(  ) );
-                msg.append( ",shutdown-wait-time-ms=" ).append( pool.getShutdownWaitTimeMs(
 ) );
-                getLogger(  ).info( msg.toString(  ) );
+                String msg = "ThreadPool named \"" + pool.getName()
+                        + "\" created with no queue,max-pool-size=" + pool.getMaximumPoolSize()
+                        + ",min-pool-size=" + pool.getMinimumPoolSize()
+                        + ",priority=" + pool.getPriority()
+                        + ",isDaemon=" + ((ThreadFactory) pool.getThreadFactory()).isDaemon()
+                        + ",keep-alive-time-ms=" + pool.getKeepAliveTime()
+                        + ",block-policy=" + pool.getBlockPolicy()
+                        + ",shutdown-wait-time-ms=" + pool.getShutdownWaitTimeMs();
+                getLogger().info(msg);
             }
         }
     }
@@ -740,7 +730,7 @@ public class DefaultRunnableManager
      * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati</a>
      * @version $Id: DefaultRunnableManager.java 56848 2004-11-07 14:09:23Z giacomo $
      */
-    private class ExecutionInfo implements Comparable
+    private class ExecutionInfo implements Comparable<ExecutionInfo>
     {
         //~ Instance fields ----------------------------------------------------
 
@@ -760,7 +750,7 @@ public class DefaultRunnableManager
         final long m_interval;
 
         /** DOCUMENT ME! */
-        long m_nextRun = 0;
+        long m_nextRun;
 
         //~ Constructors -------------------------------------------------------
 
@@ -803,10 +793,9 @@ public class DefaultRunnableManager
          *
          * @return DOCUMENT ME!
          */
-        public int compareTo( final Object other )
+        public int compareTo(final ExecutionInfo other)
         {
-            final ExecutionInfo otherInfo = (ExecutionInfo)other;
-            int diff = (int)( m_nextRun - otherInfo.m_nextRun );
+            int diff = (int)( m_nextRun - other.m_nextRun );
             if (diff == 0) {
                 if (this == other) {
                     // Same object, return 0.

Modified: cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java
URL: http://svn.apache.org/viewvc/cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java?rev=1853899&r1=1853898&r2=1853899&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/test/org/apache/cocoon/components/thread/DefaultRunnableManagerTestCase.java
Tue Feb 19 17:10:09 2019
@@ -14,6 +14,7 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+
 package org.apache.cocoon.components.thread;
 
 import org.apache.avalon.framework.configuration.Configuration;
@@ -22,27 +23,13 @@ import org.apache.avalon.framework.logge
 import org.easymock.MockControl;
 
 /**
- * The $classType$ class ...
+ * The DefaultRunnableManagerTestCase class ...
  *
  * @author <a href="mailto:giacomo.at.apache.org">Giacomo Pati </a>
  * @version $Id$
  */
 public class DefaultRunnableManagerTestCase extends AbstractTestCase
 {
-    //~ Constructors -----------------------------------------------------------
-
-    /**
-     * Constructor for DefaultRunnableManagerTestCase.
-     *
-     * @param name
-     */
-    public DefaultRunnableManagerTestCase( String name )
-    {
-        super( name );
-    }
-
-    //~ Methods ----------------------------------------------------------------
-
     /**
      * DOCUMENT ME!
      *
@@ -140,14 +127,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         runnableManager.dispose(  );
         verify(  );
@@ -156,7 +136,8 @@ public class DefaultRunnableManagerTestC
     /**
      * DOCUMENT ME!
      */
-    public final void testConfigureMinimal(  )
+    public final void testConfigureMinimal()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -194,14 +175,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         runnableManager.dispose(  );
         verify(  );
@@ -303,14 +277,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         runnableManager.dispose(  );
         verify(  );
@@ -320,7 +287,8 @@ public class DefaultRunnableManagerTestC
      * Class under test for void createPool(String, int, int, int, int,
      * boolean, long, String, boolean, int)
      */
-    public final void testCreatePoolStringintintintintbooleanlongStringbooleanint(  )
+    public final void testCreatePoolStringintintintintbooleanlongStringbooleanint()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -359,27 +327,20 @@ public class DefaultRunnableManagerTestC
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing all thread pools" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Disposing thread pool mypool" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Thread pool mypool disposed" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing thread pool default" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Thread pool default disposed" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Disposing thread pool mypool" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Thread pool mypool disposed" );
         loggerControl.replay(  );
 
         final DefaultRunnableManager runnableManager =
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         runnableManager.createPool( "mypool", 230, 15, 12, Thread.MIN_PRIORITY,
                                     false, 15500, "DISCARD", false, 22200 );
@@ -391,7 +352,8 @@ public class DefaultRunnableManagerTestC
      * Class under test for ThreadPool createPool(int, int, int, int, boolean,
      * long, String, boolean, int)
      */
-    public final void testCreatePoolintintintintbooleanlongStringbooleanint(  )
+    public final void testCreatePoolintintintintbooleanlongStringbooleanint()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -447,14 +409,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final ThreadPool threadPool =
             runnableManager.createPool( 200, 5, 2, Thread.MAX_PRIORITY, true,
@@ -474,7 +429,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(Runnable)
      */
-    public final void testExecuteRunnable(  )
+    public final void testExecuteRunnable()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -530,14 +486,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -545,25 +494,17 @@ public class DefaultRunnableManagerTestC
         runnable.run(  );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.execute( runnable );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.execute(runnable);
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }
@@ -571,7 +512,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(Runnable, long)
      */
-    public final void testExecuteRunnablelong(  )
+    public final void testExecuteRunnablelong()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -627,14 +569,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -642,25 +577,17 @@ public class DefaultRunnableManagerTestC
         runnable.run(  );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.execute( runnable, 100, 0 );
-            Thread.yield(  );
-            Thread.sleep( 200 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.execute(runnable, 100, 0);
+        Thread.yield();
+        Thread.sleep(200);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }
@@ -668,7 +595,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(Runnable, long, long)
      */
-    public final void testExecuteRunnablelonglong(  )
+    public final void testExecuteRunnablelonglong()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -722,14 +650,7 @@ public class DefaultRunnableManagerTestC
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -738,25 +659,17 @@ public class DefaultRunnableManagerTestC
         runnableControl.setVoidCallable( MockControl.ONE_OR_MORE );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.execute( runnable, 100, 100 );
-            Thread.yield(  );
-            Thread.sleep( 200 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.execute(runnable, 100, 100);
+        Thread.yield();
+        Thread.sleep(200);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }
@@ -764,7 +677,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(String, Runnable)
      */
-    public final void testExecuteStringRunnable(  )
+    public final void testExecuteStringRunnable()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -824,27 +738,20 @@ public class DefaultRunnableManagerTestC
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing all thread pools" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Disposing thread pool mypool" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Thread pool mypool disposed" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing thread pool default" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Thread pool default disposed" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Disposing thread pool mypool" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Thread pool mypool disposed" );
         loggerControl.replay(  );
 
         final DefaultRunnableManager runnableManager =
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -852,28 +759,20 @@ public class DefaultRunnableManagerTestC
         runnable.run(  );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.createPool( "mypool", 230, 15, 12,
-                                        Thread.MIN_PRIORITY, false, 15500,
-                                        "DISCARD", false, 22200 );
-            runnableManager.execute( "mypool", runnable );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.createPool("mypool", 230, 15, 12,
+                                   Thread.MIN_PRIORITY, false, 15500,
+                                   "DISCARD", false, 22200);
+        runnableManager.execute("mypool", runnable);
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }
@@ -881,7 +780,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(String, Runnable, long)
      */
-    public final void testExecuteStringRunnablelong(  )
+    public final void testExecuteStringRunnablelong()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -941,27 +841,20 @@ public class DefaultRunnableManagerTestC
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing all thread pools" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Disposing thread pool mypool" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Thread pool mypool disposed" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing thread pool default" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Thread pool default disposed" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Disposing thread pool mypool" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Thread pool mypool disposed" );
         loggerControl.replay(  );
 
         final DefaultRunnableManager runnableManager =
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -969,28 +862,20 @@ public class DefaultRunnableManagerTestC
         runnable.run(  );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.createPool( "mypool", 230, 15, 12,
-                                        Thread.MIN_PRIORITY, false, 15500,
-                                        "DISCARD", false, 22200 );
-            runnableManager.execute( "mypool", runnable, 100, 0 );
-            Thread.yield(  );
-            Thread.sleep( 200 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.createPool("mypool", 230, 15, 12,
+                                   Thread.MIN_PRIORITY, false, 15500,
+                                   "DISCARD", false, 22200);
+        runnableManager.execute("mypool", runnable, 100, 0);
+        Thread.yield();
+        Thread.sleep(200);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }
@@ -998,7 +883,8 @@ public class DefaultRunnableManagerTestC
     /**
      * Class under test for void execute(String, Runnable, long, long)
      */
-    public final void testExecuteStringRunnablelonglong(  )
+    public final void testExecuteStringRunnablelonglong()
+            throws Exception
     {
         final MockControl mainConfigControl =
             createStrictControl( Configuration.class );
@@ -1056,27 +942,20 @@ public class DefaultRunnableManagerTestC
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing all thread pools" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Disposing thread pool mypool" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
-        logger.debug( "Thread pool mypool disposed" );
-        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Disposing thread pool default" );
         loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
         logger.debug( "Thread pool default disposed" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Disposing thread pool mypool" );
+        loggerControl.expectAndReturn( logger.isDebugEnabled(  ), true );
+        logger.debug( "Thread pool mypool disposed" );
         loggerControl.replay(  );
 
         final DefaultRunnableManager runnableManager =
             new DefaultRunnableManager(  );
         runnableManager.enableLogging( logger );
 
-        try
-        {
-            runnableManager.configure( mainConfig );
-        }
-        catch( final ConfigurationException ce )
-        {
-            assertTrue( "Throw unexpected ConfigurationException", false );
-        }
+        runnableManager.configure(mainConfig);
 
         final MockControl runnableControl =
             createStrictControl( Runnable.class );
@@ -1084,28 +963,20 @@ public class DefaultRunnableManagerTestC
         runnable.run(  );
         runnableControl.replay(  );
 
-        try
-        {
-            runnableManager.start(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.createPool( "mypool", 230, 15, 12,
-                                        Thread.MIN_PRIORITY, false, 15500,
-                                        "DISCARD", false, 22200 );
-            runnableManager.execute( "mypool", runnable, 100, 100 );
-            Thread.yield(  );
-            Thread.sleep( 200 );
-            runnableManager.stop(  );
-            Thread.yield(  );
-            Thread.sleep( 20 );
-            runnableManager.dispose(  );
-            Thread.sleep( 20 );
-        }
-        catch( final Throwable ex )
-        {
-            ex.printStackTrace(  );
-            assertTrue( "Unexpected Exception", false );
-        }
+        runnableManager.start();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.createPool("mypool", 230, 15, 12,
+                                   Thread.MIN_PRIORITY, false, 15500,
+                                   "DISCARD", false, 22200);
+        runnableManager.execute("mypool", runnable, 100, 100);
+        Thread.yield();
+        Thread.sleep(150);
+        runnableManager.stop();
+        Thread.yield();
+        Thread.sleep(20);
+        runnableManager.dispose();
+        Thread.sleep(20);
 
         verify(  );
     }



Mime
View raw message