continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r732238 - in /continuum/branches/continuum-parallel-builds: continuum-core/pom.xml continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java pom.xml
Date Wed, 07 Jan 2009 06:29:33 GMT
Author: oching
Date: Tue Jan  6 22:29:32 2009
New Revision: 732238

URL: http://svn.apache.org/viewvc?rev=732238&view=rev
Log:
o migrated more parallel builds test cases to use jmock
o added cglib-nodep 2.1_3, objenesis 1.0 and jmock-legacy 2.4.0 as test dependencies for mocking
concrete classes

Modified:
    continuum/branches/continuum-parallel-builds/continuum-core/pom.xml
    continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
    continuum/branches/continuum-parallel-builds/pom.xml

Modified: continuum/branches/continuum-parallel-builds/continuum-core/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/pom.xml?rev=732238&r1=732237&r2=732238&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/pom.xml (original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/pom.xml Tue Jan  6 22:29:32
2009
@@ -255,6 +255,21 @@
       <artifactId>jmock-junit3</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jmock</groupId>
+      <artifactId>jmock-legacy</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>cglib</groupId>
+      <artifactId>cglib-nodep</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.objenesis</groupId>
+      <artifactId>objenesis</artifactId>    
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <plugins>

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java?rev=732238&r1=732237&r2=732238&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
Tue Jan  6 22:29:32 2009
@@ -29,20 +29,25 @@
 import org.apache.continuum.buildqueue.BuildQueueService;
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.taskqueue.OverallBuildQueue;
+import org.apache.continuum.taskqueueexecutor.ParallelBuildsThreadedTaskQueueExecutor;
 import org.apache.maven.continuum.buildqueue.BuildProjectTask;
 import org.apache.maven.continuum.configuration.ConfigurationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
+import org.apache.maven.continuum.scm.queue.CheckOutTask;
 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
 import org.codehaus.plexus.taskqueue.Task;
 import org.codehaus.plexus.taskqueue.TaskQueue;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
+import org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor;
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.integration.junit3.JUnit3Mockery;
+import org.jmock.lib.legacy.ClassImposteriser;
 
 /**
+ * ParallelBuildsManagerTest
  * 
  * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
  */
@@ -75,6 +80,7 @@
         buildsManager = (ParallelBuildsManager) lookup( BuildsManager.class, "parallel" );
 
         context = new JUnit3Mockery();
+        context.setImposteriser( ClassImposteriser.INSTANCE );
 
         buildDefinitionDao = context.mock( BuildDefinitionDao.class );
 
@@ -138,21 +144,6 @@
 
         return schedule;
     }
-
-    /*private void setupOverallBuildQueues()
-        throws Exception
-    {   
-        for ( int i = 2; i <= 5; i++ )
-        {
-            BuildQueue buildQueue = new BuildQueue();
-            buildQueue.setId( i );
-            buildQueue.setName( "BUILD_QUEUE_" + String.valueOf( i ) );
-                        
-            buildsManager.addOverallBuildQueue( buildQueue );
-        }
-
-        assertEquals( 5, buildsManager.getOverallBuildQueues().size() );
-    }*/
     
     public void setupMockOverallBuildQueues()
         throws Exception
@@ -167,8 +158,9 @@
         
         buildsManager.setOverallBuildQueues( overallBuildQueues );
     }
-    
-    private void recordStartOfProcess( )
+   
+    // build project recordings
+    private void recordStartOfBuildProjectSequence()
         throws TaskQueueException
     {
         context.checking( new Expectations()
@@ -176,58 +168,100 @@
             {
                 exactly(5).of( overallBuildQueue ).isInBuildQueue( with( any(int.class) )
);
                 will( returnValue( false ) );
+                
+                one( configurationService ).getNumberOfBuildsInParallel();
+                will( returnValue( 2 ) );
+                
+                exactly(2).of( overallBuildQueue ).getBuildQueue();
+                will( returnValue( buildQueue ) );
             }
-        } );
+        } );        
+    }
+    
+    private void recordBuildProjectBuildQueuesAreEmpty()
+        throws TaskQueueException
+    {
+        // shouldn't only the build queues attached to the schedule be checked?
+        recordStartOfBuildProjectSequence();
         
+        final List<Task> tasks = new ArrayList<Task>();        
         context.checking( new Expectations()
         {
             {
-                one( configurationService ).getNumberOfBuildsInParallel();
-                will( returnValue( 2 ) );
+                exactly(3).of( buildQueue ).getQueueSnapshot();
+                will( returnValue( tasks ) );
+                
+                one( overallBuildQueue).getName();
+                will( returnValue( "BUILD_QUEUE_2" ) );
             }
         } );
-        
+                
+        recordAddToBuildQueue();
+    }
+    
+    private void recordAddToBuildQueue()
+        throws TaskQueueException
+    {
         context.checking( new Expectations()
         {
             {
-                exactly(2).of( overallBuildQueue ).getBuildQueue();
-                will( returnValue( buildQueue ) );
+                one( overallBuildQueue).addToBuildQueue( with( any( Task.class ) ) );
             }
         } );
     }
     
-    private void recordBuildProjectBuildQueuesAreEmpty()
+    // checkout project recordings
+    private void recordStartOfCheckoutProjectSequence()
         throws TaskQueueException
     {
-        // shouldn't only the build queues attached to the schedule be checked?
-        recordStartOfProcess();
-        
-        final List<Task> tasks = new ArrayList<Task>();        
         context.checking( new Expectations()
         {
             {
-                exactly(3).of( buildQueue ).getQueueSnapshot();
-                will( returnValue( tasks ) );
+                exactly(5).of(overallBuildQueue).isInCheckoutQueue( with( any( int.class
) ) );
+                will( returnValue( false ) ); 
+                
+                one( configurationService ).getNumberOfBuildsInParallel();
+                will( returnValue( 2 ) );
+                
+                exactly(2).of( overallBuildQueue ).getCheckoutQueue();
+                will( returnValue( checkoutQueue ) );
             }
         } );
         
+    }
+    
+    private void recordCheckoutProjectBuildQueuesAreEmpty()
+        throws TaskQueueException
+    {
+        recordStartOfCheckoutProjectSequence();
+        
+        final List<Task> tasks = new ArrayList<Task>();        
         context.checking( new Expectations()
         {
             {
+                exactly(3).of( checkoutQueue ).getQueueSnapshot();
+                will( returnValue( tasks ) );
+                
                 one( overallBuildQueue).getName();
                 will( returnValue( "BUILD_QUEUE_2" ) );
             }
         } );
-        
+                
+        recordAddToCheckoutQueue();
+    }
+    
+    private void recordAddToCheckoutQueue()
+        throws TaskQueueException
+    {
         context.checking( new Expectations()
         {
             {
-                one( overallBuildQueue).addToBuildQueue( with( any( Task.class ) ) );
+                one( overallBuildQueue ).addToCheckoutQueue( with( any( Task.class ) ) );
             }
         } );
     }
 
-    // start of tests...
+    // start of test cases..
     
     public void testContainer()
         throws Exception
@@ -270,9 +304,10 @@
         context.assertIsSatisfied();
         
         //queue second project - 1st queue is not empty, 2nd queue is empty 
-        recordStartOfProcess();
+        recordStartOfBuildProjectSequence();
         
         // the first build queue already has a task queued
+        final List<Task> tasks = new ArrayList<Task>();
         final List<Task> tasksOfFirstBuildQueue = new ArrayList<Task>();
         tasksOfFirstBuildQueue.add( new BuildProjectTask( 2, 1, 1, "continuum-project-test-2",
buildDef.getDescription() ) );        
         context.checking( new Expectations()
@@ -280,40 +315,23 @@
             {
                 exactly(2).of( buildQueue ).getQueueSnapshot();
                 will( returnValue( tasksOfFirstBuildQueue ) );
-            }
-        } );
-        
-        final List<Task> tasks = new ArrayList<Task>();
-        
-        // the second build queue has no tasks queued, so it should return 0
-        context.checking( new Expectations()
-        {
-            {
+                
+                // the second build queue has no tasks queued, so it should return 0
                 exactly(2).of(buildQueue).getQueueSnapshot();
                 will( returnValue( tasks ) );
-            }
-        } );
-        
-        context.checking( new Expectations()
-        {
-            {
+                
                 one( overallBuildQueue).getName();
                 will( returnValue( "BUILD_QUEUE_3" ) );
             }
         } );
         
-        context.checking( new Expectations()
-        {
-            {
-                one( overallBuildQueue).addToBuildQueue( with( any( Task.class ) ) );
-            }
-        } );
+        recordAddToBuildQueue();
         
         buildsManager.buildProject( 2, buildDef, "continuum-project-test-2", 1 );
         context.assertIsSatisfied();
         
         // queue third project - both queues have 1 task queued each
-        recordStartOfProcess();
+        recordStartOfBuildProjectSequence();
         
         // both queues have 1 task each        
         context.checking( new Expectations()
@@ -321,23 +339,13 @@
             {
                 exactly(3).of( buildQueue ).getQueueSnapshot();
                 will( returnValue( tasksOfFirstBuildQueue ) );
-            }
-        } );
                 
-        context.checking( new Expectations()
-        {
-            {
                 one( overallBuildQueue).getName();
                 will( returnValue( "BUILD_QUEUE_2" ) );
             }
         } );
-        
-        context.checking( new Expectations()
-        {
-            {
-                one( overallBuildQueue).addToBuildQueue( with( any( Task.class ) ) );
-            }
-        } );
+                        
+        recordAddToBuildQueue();
         
         buildsManager.buildProject( 3, buildDef, "continuum-project-test-3", 1 );
         context.assertIsSatisfied();
@@ -353,12 +361,7 @@
             {
                 one(overallBuildQueue).isInBuildQueue( 1 );
                 will( returnValue( true ) );
-            }
-        } );
-        
-        context.checking( new Expectations()
-        {
-            {
+                
                 one(overallBuildQueue).removeProjectFromBuildQueue( 1 );
             }
         } );
@@ -372,22 +375,17 @@
     {
         setupMockOverallBuildQueues();
         int[] projectIds = new int[] { 1, 2, 3 };
-    
+            
         context.checking( new Expectations()
         {
             {
                 exactly(3).of(overallBuildQueue).isInBuildQueue( with( any( int.class ) )
);
-                will( returnValue( true ) );
-            }
-        } );
-        
-        context.checking( new Expectations()
-        {
-            {
+                will( returnValue( true ) );                
+                
                 exactly(3).of(overallBuildQueue).removeProjectFromBuildQueue( with( any(
int.class ) ) );
             }
         } );
-        
+                
         buildsManager.removeProjectsFromBuildQueue( projectIds );
         context.assertIsSatisfied();
     }
@@ -401,56 +399,337 @@
         buildDef.setId( 1 );
         buildDef.setSchedule( getSchedule( 1, 1, 2 ) );
     
+        recordCheckoutProjectBuildQueuesAreEmpty();
+        
+        buildsManager.checkoutProject( 1, "continuum-project-test-1", new File( getBasedir(),
"/target/test-working-dir/1" ),
+                                       "dummy", "dummypass", buildDef );
+        context.assertIsSatisfied();
+    }
+
+    public void testCheckoutProjectMultiple()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+    
+        BuildDefinition buildDef = new BuildDefinition();
+        buildDef.setId( 1 );
+        buildDef.setSchedule( getSchedule( 1, 1, 2 ) );
+    
+        recordCheckoutProjectBuildQueuesAreEmpty();
+        
+        buildsManager.checkoutProject( 1, "continuum-project-test-1", new File( getBasedir(),
"/target/test-working-dir/1" ),
+                                       "dummy", "dummypass", buildDef );
+        context.assertIsSatisfied();
+        
+        // queue second project - 1st queue has 1 task while 2nd queue is empty; project
should be queued in
+        //      2nd queue
+        recordStartOfCheckoutProjectSequence();
+                
+        final List<Task> tasks = new ArrayList<Task>();
+        
+        final List<Task> tasksInFirstCheckoutQueue = new ArrayList<Task>();
+        tasksInFirstCheckoutQueue.add( new CheckOutTask( 1, new File( getBasedir(), "/target/test-working-dir/1"
),
+                                                 "continuum-project-test-1", "dummy", "dummypass"
) );
+        
         context.checking( new Expectations()
         {
             {
-                exactly(5).of(overallBuildQueue).isInCheckoutQueue( 1 );
-                will( returnValue( false ) );
+                exactly(2).of( checkoutQueue ).getQueueSnapshot();
+                will( returnValue( tasksInFirstCheckoutQueue ) );
+                
+                exactly(2).of( checkoutQueue ).getQueueSnapshot();
+                will( returnValue( tasks ) );
+                
+                one( overallBuildQueue).getName();
+                will( returnValue( "BUILD_QUEUE_3" ) );
             }
         } );
         
+        recordAddToCheckoutQueue();
+        
+        buildsManager.checkoutProject( 2, "continuum-project-test-2", new File( getBasedir(),
"/target/test-working-dir/1" ),
+                                       "dummy", "dummypass", buildDef );
+        context.assertIsSatisfied();                
+        
+        // queue third project - both queues have 1 task queued each; third project should
be queued in 1st queue
+        recordStartOfCheckoutProjectSequence();
+        
         context.checking( new Expectations()
         {
             {
-                one( configurationService ).getNumberOfBuildsInParallel();
-                will( returnValue( 2 ) );
+                exactly(3).of( checkoutQueue ).getQueueSnapshot();
+                will( returnValue( tasksInFirstCheckoutQueue ) );
+                
+                one( overallBuildQueue).getName();
+                will( returnValue( "BUILD_QUEUE_2" ) );
             }
         } );
+                     
+        recordAddToCheckoutQueue();
         
+        buildsManager.checkoutProject( 3, "continuum-project-test-3", new File( getBasedir(),
"/target/test-working-dir/1" ),
+                                       "dummy", "dummypass", buildDef );
+        context.assertIsSatisfied();
+    }
+
+    public void testRemoveProjectFromCheckoutQueue()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+    
         context.checking( new Expectations()
         {
             {
-                exactly(2).of( overallBuildQueue ).getCheckoutQueue();
-                will( returnValue( checkoutQueue ) );
+                one(overallBuildQueue).isInCheckoutQueue( 1 );
+                will( returnValue( true ) );
+                
+                one(overallBuildQueue).removeProjectFromCheckoutQueue( 1 );
             }
         } );
-        
-        final List<Task> tasks = new ArrayList<Task>();        
+                
+        buildsManager.removeProjectFromCheckoutQueue( 1 );
+        context.assertIsSatisfied();
+    }
+    
+    public void testRemoveProjectsFromCheckoutQueue()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();    
+    
         context.checking( new Expectations()
         {
             {
-                exactly(3).of( checkoutQueue ).getQueueSnapshot();
-                will( returnValue( tasks ) );
+                exactly(3).of(overallBuildQueue).isInCheckoutQueue( with( any( int.class
) ) );
+                will( returnValue( true ) );
+                
+                exactly(3).of(overallBuildQueue).removeProjectFromCheckoutQueue( with( any(
int.class ) ) );
             }
         } );
+                
+        int[] projectIds = new int[] { 1, 2, 3 };
         
+        buildsManager.removeProjectsFromCheckoutQueue( projectIds );
+        context.assertIsSatisfied();
+    }
+    
+    public void testRemoveProjectFromCheckoutQueueProjectNotFound()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+        
+        // shouldn't only the project's build queues be checked instead of all the overall
build queues?
         context.checking( new Expectations()
         {
             {
-                one( overallBuildQueue).getName();
-                will( returnValue( "BUILD_QUEUE_2" ) );
+                exactly(5).of(overallBuildQueue).isInCheckoutQueue( 1 );
+                will( returnValue( false ) );
             }
         } );
         
+        buildsManager.removeProjectFromCheckoutQueue( 1 );
+        context.assertIsSatisfied();
+    }
+    
+    public void testRemoveDefaultOverallBuildQueue()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+        
+        try
+        {
+            context.checking( new Expectations()
+            {
+                {
+                    one(overallBuildQueue).getName();
+                    will( returnValue( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME ) );
+                }
+            } );
+            
+            buildsManager.removeOverallBuildQueue( 1 );
+            context.assertIsSatisfied();
+            fail( "An exception should have been thrown." );
+        }
+        catch ( BuildManagerException e )
+        {
+            assertEquals( "Cannot remove default build queue.", e.getMessage() );
+        }
+    }
+    
+    public void testRemoveOverallBuildQueueNoTasksCurrentlyExecuting()
+        throws Exception
+    {
+        // queued tasks (both checkout & build tasks) must be transferred to the other
queues!
+        setupMockOverallBuildQueues();
+        
+        final BuildDefinition buildDef = new BuildDefinition();
+        buildDef.setId( 1 );
+        buildDef.setSchedule( getSchedule( 1, 1, 2 ) );
+        
+        final TaskQueueExecutor buildQueueExecutor = context.mock( TaskQueueExecutor.class,
"build-queue-executor" );
+        final TaskQueueExecutor checkoutQueueExecutor =
+            context.mock( TaskQueueExecutor.class, "checkout-queue-executor" );
+        
+        final List<Task> buildTasks = new ArrayList<Task>();
+        buildTasks.add( new BuildProjectTask(  2, 1, 1, "continuum-project-test-2", "BUILD_DEF"
) );
+        
+        final List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
+        checkoutTasks.add( new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1"
), "continuum-project-test-2",
+                                          "dummy", "dummypass" ) );
+        
+        final ParallelBuildsThreadedTaskQueueExecutor buildTaskQueueExecutor = context.mock(
ParallelBuildsThreadedTaskQueueExecutor.class, "parallel-build-task-executor" );
+        final ParallelBuildsThreadedTaskQueueExecutor checkoutTaskQueueExecutor = context.mock(
ParallelBuildsThreadedTaskQueueExecutor.class, "parallel-checkout-task-executor" );
+        
+        final List<Task> tasks = new ArrayList<Task>();     
+        
         context.checking( new Expectations()
         {
             {
-                one( overallBuildQueue).addToCheckoutQueue( with( any( Task.class ) ) );
+                one( overallBuildQueue ).getName();
+                will( returnValue( "BUILD_QUEUE_5" ) );
+                
+             // check if there is any build task currently being executed
+                one( overallBuildQueue ).getBuildTaskQueueExecutor();
+                will( returnValue( buildQueueExecutor ) );                
+                one( buildQueueExecutor ).getCurrentTask();
+                will ( returnValue( null ) );
+                //will( returnValue( buildTask ) );
+                
+             // check if there is any checkout task currently being executed
+                one( overallBuildQueue ).getCheckoutTaskQueueExecutor();
+                will( returnValue( checkoutQueueExecutor ) );                
+                one( checkoutQueueExecutor ).getCurrentTask();
+                will ( returnValue( null ) );
+                //will( returnValue( checkoutTask ) );
+                
+             // get all queued build tasks & remove them
+                one(overallBuildQueue).getProjectsInBuildQueue();
+                will( returnValue( buildTasks ) );
+                one(overallBuildQueue).getBuildQueue();
+                will( returnValue( buildQueue ) );
+                one(buildQueue).removeAll( buildTasks );
+                
+             // get all queued checkout tasks & remove them
+                one(overallBuildQueue).getCheckOutTasksInQueue();
+                will( returnValue( checkoutTasks ) );                
+                one(overallBuildQueue).getCheckoutQueue();
+                will( returnValue( checkoutQueue ) );
+                one(checkoutQueue).removeAll( checkoutTasks );
+                
+             // stop the build & checkout task queue executors
+                one(overallBuildQueue).getBuildTaskQueueExecutor();
+                will( returnValue( buildTaskQueueExecutor ) );
+                one(overallBuildQueue).getCheckoutTaskQueueExecutor();
+                will( returnValue( checkoutTaskQueueExecutor ) );
+                
+                one( buildTaskQueueExecutor ).stop();
+                one( checkoutTaskQueueExecutor ).stop();
+             
+                // TODO: test scenario when there are no longer build queues configured aside
from the one removed?
+                //      - the behaviour should be that the default build queue will be used!
+                
+             // re-queue projects in the build queue of the deleted overall build queue
+                one( buildDefinitionDao ).getBuildDefinition( 1 );
+                will( returnValue( buildDef ) );
+                
+                // queue to other build queue
+                exactly(4).of( overallBuildQueue ).isInBuildQueue( with( any(int.class) )
);
+                will( returnValue( false ) );
+                
+                one( configurationService ).getNumberOfBuildsInParallel();
+                will( returnValue( 2 ) );                
+                
+                exactly(2).of( overallBuildQueue ).getBuildQueue();
+                will( returnValue( buildQueue ) );
+                
+                exactly(3).of( buildQueue ).getQueueSnapshot();
+                will( returnValue( tasks ) );
+                
+                one( overallBuildQueue).getName();
+                will( returnValue( "BUILD_QUEUE_2" ) );
+                
+                recordAddToBuildQueue();
+                
+             // re-queue projects in the checkout queue of the deleted overall build queue
+                one( buildDefinitionDao ).getDefaultBuildDefinition( 2 );
+                will( returnValue( buildDef ) );
+                
+                // queue to other checkout queues
+                exactly(4).of(overallBuildQueue).isInCheckoutQueue( with( any( int.class
) ) );
+                will( returnValue( false ) ); 
+                
+                one( configurationService ).getNumberOfBuildsInParallel();
+                will( returnValue( 2 ) );
+                
+                exactly(2).of( overallBuildQueue ).getCheckoutQueue();
+                will( returnValue( checkoutQueue ) );
+                
+                exactly(3).of( checkoutQueue ).getQueueSnapshot();
+                will( returnValue( tasks ) );
+                
+                one( overallBuildQueue).getName();
+                will( returnValue( "BUILD_QUEUE_2" ) );
+                
+                recordAddToCheckoutQueue();
             }
         } );
-        
-        buildsManager.checkoutProject( 1, "continuum-project-test-1", new File( getBasedir(),
"/target/test-working-dir/1" ),
-                                       "dummy", "dummypass", buildDef );
+                   
+        buildsManager.removeOverallBuildQueue( 5 );
         context.assertIsSatisfied();
+
+        Map<Integer, OverallBuildQueue> overallBuildQueues = buildsManager.getOverallBuildQueues();
+        assertNull( overallBuildQueues.get( 5 ) );
+    }
+    
+    public void testRemoveOverallBuildQueueTasksCurrentlyExecuting()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+        
+        final BuildDefinition buildDef = new BuildDefinition();
+        buildDef.setId( 1 );
+        buildDef.setSchedule( getSchedule( 1, 1, 2 ) );
+        
+        final TaskQueueExecutor buildQueueExecutor = context.mock( TaskQueueExecutor.class,
"build-queue-executor" );
+        final Task buildTask = new BuildProjectTask( 1, 1, 1, "continuum-project-test-1",
"BUILD_DEF" );
+
+        final List<Task> buildTasks = new ArrayList<Task>();
+        buildTasks.add( new BuildProjectTask(  2, 1, 1, "continuum-project-test-2", "BUILD_DEF"
) );
+        
+        final List<CheckOutTask> checkoutTasks = new ArrayList<CheckOutTask>();
+        checkoutTasks.add( new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1"
), "continuum-project-test-2",
+                                          "dummy", "dummypass" ) );
+        
+        try
+        {
+            context.checking( new Expectations()
+            {
+                {
+                    one( overallBuildQueue ).getName();
+                    will( returnValue( "BUILD_QUEUE_5" ) );
+                    
+                 // check if there is any build task currently being executed
+                    one( overallBuildQueue ).getBuildTaskQueueExecutor();
+                    will( returnValue( buildQueueExecutor ) );                
+                    one( buildQueueExecutor ).getCurrentTask();                
+                    will( returnValue( buildTask ) );                        
+                }
+            } );
+                       
+            buildsManager.removeOverallBuildQueue( 5 );
+            context.assertIsSatisfied();
+            fail( "An exception should have been thrown." );
+        }
+        catch ( BuildManagerException e )
+        {
+            assertEquals( "Cannot remove build queue. A task is currently executing.", e.getMessage()
);
+        }
+    }
+    
+    /*
+    public void testNumOfAllowedParallelBuildsIsLessThanConfiguredBuildQueues()
+        throws Exception
+    {
+    
     }
+    */
 }

Modified: continuum/branches/continuum-parallel-builds/pom.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/pom.xml?rev=732238&r1=732237&r2=732238&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/pom.xml (original)
+++ continuum/branches/continuum-parallel-builds/pom.xml Tue Jan  6 22:29:32 2009
@@ -286,12 +286,30 @@
         <scope>test</scope>
       </dependency>
       <dependency>
+        <groupId>org.jmock</groupId>
+        <artifactId>jmock-legacy</artifactId>
+        <version>2.4.0</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>jmock</groupId>
         <artifactId>jmock</artifactId>
         <version>1.0.1</version>
         <scope>test</scope>
       </dependency>
       <dependency>
+        <groupId>cglib</groupId>
+        <artifactId>cglib-nodep</artifactId>
+        <version>2.1_3</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
+        <groupId>org.objenesis</groupId>
+        <artifactId>objenesis</artifactId>
+        <version>1.0</version>
+        <scope>test</scope>
+      </dependency>
+      <dependency>
         <groupId>org.apache.maven</groupId>
         <artifactId>maven-core</artifactId>
         <version>${maven.version}</version>



Mime
View raw message