continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r732243 - in /continuum/branches/continuum-parallel-builds/continuum-core/src: main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
Date Wed, 07 Jan 2009 06:57:43 GMT
Author: oching
Date: Tue Jan  6 22:57:42 2009
New Revision: 732243

URL: http://svn.apache.org/viewvc?rev=732243&view=rev
Log:
ported more parallel builds manager tests to jmock

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

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java?rev=732243&r1=732242&r2=732243&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
Tue Jan  6 22:57:42 2009
@@ -1093,15 +1093,13 @@
 
         // use default overall build queue if none is configured
         if ( whereToBeQueued == null )
-        {     
-            boolean found = false;            
+        {                
             Set<Integer> keySet = overallBuildQueues.keySet();
             for( Integer key : keySet )
             {
                 OverallBuildQueue overallBuildQueue = overallBuildQueues.get( key );    
           
                 if( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME
) )
                 {
-                    found = true;
                     return overallBuildQueue;
                 }
             }

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=732243&r1=732242&r2=732243&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:57:42 2009
@@ -725,11 +725,112 @@
         }
     }
     
+    public void testNoBuildQueuesConfigured()
+        throws Exception
+    {
+        overallBuildQueue = context.mock( OverallBuildQueue.class ); 
+        
+        Map<Integer, OverallBuildQueue> overallBuildQueues =
+            Collections.synchronizedMap( new HashMap<Integer, OverallBuildQueue>()
);
+        overallBuildQueues.put( 1, overallBuildQueue );
+        
+        buildsManager.setOverallBuildQueues( overallBuildQueues );
+        
+        Schedule schedule = new Schedule();
+        schedule.setId( 1 );
+        schedule.setName( "DEFAULT_SCHEDULE" );
+        schedule.setCronExpression( "0 0 * * * ?" );
+        schedule.setDelay( 100 );
+        schedule.setMaxJobExecutionTime( 10000 );
+        
+        BuildDefinition buildDef = new BuildDefinition();
+        buildDef.setId( 1 );
+        buildDef.setSchedule( schedule );
+        
+        context.checking( new Expectations() 
+        {
+            {
+                one( overallBuildQueue ).isInBuildQueue( with( any(int.class) ) );
+                will( returnValue( false ) );
+                
+                one( configurationService ).getNumberOfBuildsInParallel();
+                will( returnValue( 2 ) );                
+                
+                exactly(2).of( overallBuildQueue ).getName();
+                will( returnValue( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME ) );
+                
+                one(overallBuildQueue).addToBuildQueue( with( any( Task.class) ) );
+            }            
+        });
+        
+        buildsManager.buildProject( 1, buildDef, "continuum-project-test-1", 1 );
+        context.assertIsSatisfied();
+    }
+    
+    public void testGetProjectsInBuildQueue()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+    
+        final List<Task> tasks = new ArrayList<Task>();
+        tasks.add( new BuildProjectTask(  2, 1, 1, "continuum-project-test-2", "BUILD_DEF"
) );
+        
+        context.checking( new Expectations()  
+        {
+            {
+                exactly(5).of( overallBuildQueue ).getName();
+                will( returnValue( "BUILD_QUEUE" ) );
+                
+                exactly(5).of( overallBuildQueue).getProjectsInBuildQueue();
+                will( returnValue( tasks ) );
+            }
+        });
+        
+        buildsManager.getProjectsInBuildQueues();
+        context.assertIsSatisfied();
+    }
+
+    public void testGetProjectsInCheckoutQueue()
+        throws Exception
+    {
+        setupMockOverallBuildQueues();
+        
+        final List<Task> tasks = new ArrayList<Task>();
+        tasks.add( new CheckOutTask( 2, new File( getBasedir(), "/target/test-working-dir/1"
), "continuum-project-test-2",
+                                     "dummy", "dummypass" ) );
+        
+        context.checking( new Expectations()  
+        {
+            {
+                exactly(5).of( overallBuildQueue ).getName();
+                will( returnValue( "BUILD_QUEUE" ) );
+                
+                exactly(5).of( overallBuildQueue).getCheckOutTasksInQueue();
+                will( returnValue( tasks ) );
+            }
+        });
+        
+        buildsManager.getProjectsInCheckoutQueues();
+        context.assertIsSatisfied();
+    }
+    
     /*
     public void testNumOfAllowedParallelBuildsIsLessThanConfiguredBuildQueues()
         throws Exception
     {
     
     }
+    
+    public void testPrepareBuildProjects()
+        throws Exception
+    {
+    
+    }
+    
+    public void testRemoveProjectFromPrepareBuildQueue()
+        throws Exception
+    {
+
+    }
     */
 }



Mime
View raw message