You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by js...@apache.org on 2003/05/13 09:51:32 UTC

cvs commit: jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool TestThreadPool.java

jstrachan    2003/05/13 00:51:31

  Modified:    threadpool project.xml maven.xml .cvsignore
               threadpool/src/java/org/apache/commons/threadpool
                        MTQueue.java
               threadpool/src/test/org/apache/commons/threadpool
                        TestThreadPool.java
  Log:
  Updated the Maven build to remove old redundant details and to add a Clover coverage report by default.

Removed some compiler warnings.

Added a simple unit test case.
  
  Revision  Changes    Path
  1.2       +1 -17     jakarta-commons-sandbox/threadpool/project.xml
  
  Index: project.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/project.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- project.xml	10 Oct 2002 20:05:20 -0000	1.1
  +++ project.xml	13 May 2003 07:51:31 -0000	1.2
  @@ -67,17 +67,6 @@
         <id>commons-logging</id>
         <version>1.0.1</version>
       </dependency>
  -    
  -    <!-- this isn't really a dependency, its just here to get around a Maven bug in test:test... -->
  -    <dependency>
  -      <id>xml-apis</id>
  -      <version>2.0.2</version>
  -    </dependency>
  -    <dependency>
  -      <id>xerces</id>
  -      <version>2.0.2</version>
  -    </dependency>
  -
   	</dependencies>
   	
   	<build>
  @@ -95,15 +84,10 @@
         </includes>
       </unitTest>
   
  -    
  -    <!-- Integration unit test classes -->
  -    <integrationUnitTestPatterns></integrationUnitTestPatterns>
  -
  -    <!-- J A R  R E S O U R C E S -->
       <!-- Resources that are packaged up inside the JAR file -->
       <resources>
         <includes>
  -        <include>**/*.properties, **/*.betwixt</include>
  +        <include>**/*.properties</include>
         </includes>
       </resources>
     </build>
  
  
  
  1.2       +4 -0      jakarta-commons-sandbox/threadpool/maven.xml
  
  Index: maven.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/maven.xml,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- maven.xml	10 Oct 2002 20:05:20 -0000	1.1
  +++ maven.xml	13 May 2003 07:51:31 -0000	1.2
  @@ -1,2 +1,6 @@
   <project default="java:jar" xmlns:j="jelly:core">
  +  <preGoal name="site">
  +    <attainGoal name="java:compile"/>
  +    <attainGoal name="clover"/>
  +  </preGoal>
   </project>
  
  
  
  1.2       +4 -1      jakarta-commons-sandbox/threadpool/.cvsignore
  
  Index: .cvsignore
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/.cvsignore,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- .cvsignore	10 Oct 2002 20:05:20 -0000	1.1
  +++ .cvsignore	13 May 2003 07:51:31 -0000	1.2
  @@ -1,2 +1,5 @@
   target
  -*.log
  \ No newline at end of file
  +*.log
  +bin
  +.classpath
  +.project
  
  
  
  1.2       +2 -2      jakarta-commons-sandbox/threadpool/src/java/org/apache/commons/threadpool/MTQueue.java
  
  Index: MTQueue.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/src/java/org/apache/commons/threadpool/MTQueue.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- MTQueue.java	10 Oct 2002 20:05:20 -0000	1.1
  +++ MTQueue.java	13 May 2003 07:51:31 -0000	1.2
  @@ -85,7 +85,7 @@
   
   
       private LinkedList list = new LinkedList();
  -    private long timeout = 10000;
  +    private long defaultTimeout = 10000;
   
       public MTQueue() {
       }
  @@ -117,7 +117,7 @@
                   return answer;
               }
               try {
  -                wait( timeout );
  +                wait( defaultTimeout );
               }
               catch (InterruptedException e) {
                   log.error( "Thread was interrupted: " + e, e );
  
  
  
  1.2       +28 -21    jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool/TestThreadPool.java
  
  Index: TestThreadPool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/threadpool/src/test/org/apache/commons/threadpool/TestThreadPool.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TestThreadPool.java	10 Oct 2002 20:05:20 -0000	1.1
  +++ TestThreadPool.java	13 May 2003 07:51:31 -0000	1.2
  @@ -64,44 +64,51 @@
   import junit.framework.Test;
   import junit.framework.TestCase;
   import junit.framework.TestSuite;
  -import junit.textui.TestRunner;
  -
  -import org.apache.commons.logging.Log;
  -import org.apache.commons.logging.LogFactory;
   
   /**
  - * Test harness for the IO package
  - *
  - * @author <a href="mailto:jason@zenplex.com">Jason van Zyl</a>
  + * Simple test harness
  + * 
  + * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
    * @version $Revision$
    */
   public class TestThreadPool extends TestCase {
   
  -    /**
  -     * A unit test suite for JUnit
  -     */
  +    private boolean flag;
  +
       public static Test suite() {
           return new TestSuite(TestThreadPool.class);
       }
   
  -    /**
  -     * Constructor for the TestThreadPool object
  -     *
  -     * @param testName
  -     */
       public TestThreadPool(String testName) {
           super(testName);
       }
   
  -    /**
  -     * The JUnit setup method
  -     */
  -    protected void setUp() throws Exception {
  +    public void testThreadPool() throws Exception {
  +        ThreadPool pool = createThreadPool();
  +        final Object lock = new Object();
  +        
  +        flag = false;
  +
  +        pool.invokeLater(new Runnable() {
  +            public void run() {
  +                synchronized (lock) {
  +                    flag = true;
  +                    lock.notifyAll();
  +                }
  +            }
  +        });
  +        
  +        synchronized (lock) {
  +            lock.wait(10000);
  +        }
  +        
  +        assertTrue("The asynchronous task should have set the flag by now!", flag);
       }
   
       /**
  -     * A unit test for JUnit
  +     * Factory method to create a new thread pool implementation
        */
  -    public void testThreadPool() throws Exception {
  +    protected ThreadPool createThreadPool() {
  +        return new DefaultThreadPool();
       }
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org