continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r726572 - in /continuum/branches/continuum-parallel-builds: continuum-api/src/main/java/org/apache/continuum/dao/ continuum-api/src/main/java/org/apache/maven/continuum/configuration/ continuum-commons/src/main/java/org/apache/maven/continu...
Date Sun, 14 Dec 2008 23:10:17 GMT
Author: oching
Date: Sun Dec 14 15:10:16 2008
New Revision: 726572

URL: http://svn.apache.org/viewvc?rev=726572&view=rev
Log:
-fixed some test cases
-added BuildQueueDao 

Added:
    continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
    continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
Modified:
    continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
    continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
    continuum/branches/continuum-parallel-builds/continuum-commons/src/main/resources/META-INF/spring-context.xml
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/continuum/buildmanager/ParallelBuildsManager.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
    continuum/branches/continuum-parallel-builds/continuum-core/src/test/java/org/apache/continuum/buildmanager/ParallelBuildsManagerTest.java
    continuum/branches/continuum-parallel-builds/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java

Added: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java?rev=726572&view=auto
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
(added)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/continuum/dao/BuildQueueDao.java
Sun Dec 14 15:10:16 2008
@@ -0,0 +1,49 @@
+package org.apache.continuum.dao;
+
+/*
+ * 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 java.util.List;
+
+import org.apache.maven.continuum.model.project.BuildQueue;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+
+/**
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ */
+public interface BuildQueueDao
+{
+    BuildQueue addBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException;
+
+    BuildQueue getBuildQueue( int buildQueueId )
+        throws ContinuumStoreException;
+
+    BuildQueue getBuildQueueByName( String buildQueueName )
+        throws ContinuumStoreException;
+
+    void removeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException;
+
+    BuildQueue storeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException;
+
+    List<BuildQueue> getAllBuildQueues()
+        throws ContinuumStoreException;
+}

Modified: continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java?rev=726572&r1=726571&r2=726572&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-api/src/main/java/org/apache/maven/continuum/configuration/ConfigurationService.java
Sun Dec 14 15:10:16 2008
@@ -20,6 +20,7 @@
  */
 
 import org.apache.continuum.configuration.ContinuumConfigurationException;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
@@ -34,6 +35,8 @@
     String ROLE = ConfigurationService.class.getName();
 
     public static final String DEFAULT_SCHEDULE_NAME = "DEFAULT_SCHEDULE";
+    
+    public static final String DEFAULT_BUILD_QUEUE_NAME = "DEFAULT_BUILD_QUEUE";
 
     // ----------------------------------------------------------------------
     //
@@ -87,6 +90,9 @@
     int getNumberOfBuildsInParallel();
     
     void setNumberOfBuildsInParallel( int num );
+    
+    BuildQueue getDefaultBuildQueue()
+        throws ContinuumStoreException;
 
     // ----------------------------------------------------------------------
     //

Modified: continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java?rev=726572&r1=726571&r2=726572&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-commons/src/main/java/org/apache/maven/continuum/configuration/DefaultConfigurationService.java
Sun Dec 14 15:10:16 2008
@@ -22,8 +22,10 @@
 import org.apache.continuum.configuration.ContinuumConfiguration;
 import org.apache.continuum.configuration.ContinuumConfigurationException;
 import org.apache.continuum.configuration.GeneralConfiguration;
+import org.apache.continuum.dao.BuildQueueDao;
 import org.apache.continuum.dao.ScheduleDao;
 import org.apache.continuum.dao.SystemConfigurationDao;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.model.system.SystemConfiguration;
 import org.apache.maven.continuum.store.ContinuumStoreException;
@@ -44,7 +46,7 @@
 {
     private Logger log = LoggerFactory.getLogger( this.getClass() );
 
-    // when adding requirement the template in application.xml must be updated CONTINUUM-1207
+    // when adding requirement the template in spring-context.xml must be updated CONTINUUM-1207
 
     /**
      * @plexus.configuration default-value="${plexus.home}"
@@ -60,6 +62,11 @@
      * @plexus.requirement
      */
     private SystemConfigurationDao systemConfigurationDao;
+    
+    /**
+     * @plexus.requirement
+     */
+    private BuildQueueDao buildQueueDao;
 
     /**
      * @plexus.requirement
@@ -95,6 +102,16 @@
     {
         this.scheduleDao = scheduleDao;
     }
+    
+    public BuildQueueDao getBuildQueueDao()
+    {
+        return buildQueueDao;
+    }
+    
+    public void setBuildQueueDao( BuildQueueDao buildQueueDao )
+    {
+        this.buildQueueDao = buildQueueDao;
+    }
 
     public SystemConfigurationDao getSystemConfigurationDao()
     {
@@ -390,7 +407,7 @@
     {
         generalConfiguration.setNumberOfBuildsInParallel( num );
     }
-
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -495,13 +512,28 @@
 
         return defaultSchedule;
     }
-
+    
+    public BuildQueue getDefaultBuildQueue()
+        throws ContinuumStoreException
+    {     
+        BuildQueue defaultBuildQueue = buildQueueDao.getBuildQueueByName( DEFAULT_BUILD_QUEUE_NAME
);
+    
+        if ( defaultBuildQueue == null )
+        {
+            defaultBuildQueue = createDefaultBuildQueue();
+    
+            defaultBuildQueue = buildQueueDao.addBuildQueue( defaultBuildQueue );
+        }
+    
+        return defaultBuildQueue;
+    }
+    
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
     private Schedule createDefaultSchedule()
-        throws ConfigurationLoadingException, ContinuumConfigurationException
+        throws ConfigurationLoadingException, ContinuumConfigurationException, ContinuumStoreException
     {
 
         log.info( "create Default Schedule" );
@@ -521,8 +553,22 @@
         schedule.setCronExpression( systemConf.getDefaultScheduleCronExpression() );
 
         schedule.setActive( true );
+        
+        BuildQueue buildQueue = getDefaultBuildQueue();
+        
+        schedule.addBuildQueue( buildQueue );
 
         return schedule;
     }
-
+    
+    private BuildQueue createDefaultBuildQueue()
+    {
+        log.info( "create Default Build Queue" );
+        
+        BuildQueue buildQueue = new BuildQueue();
+        
+        buildQueue.setName( DEFAULT_BUILD_QUEUE_NAME );        
+        
+        return buildQueue;
+    }
 }

Modified: continuum/branches/continuum-parallel-builds/continuum-commons/src/main/resources/META-INF/spring-context.xml
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-commons/src/main/resources/META-INF/spring-context.xml?rev=726572&r1=726571&r2=726572&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-commons/src/main/resources/META-INF/spring-context.xml
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-commons/src/main/resources/META-INF/spring-context.xml
Sun Dec 14 15:10:16 2008
@@ -29,6 +29,7 @@
     <property name="scheduleDao" ref="scheduleDao"/>
     <property name="systemConfigurationDao" ref="systemConfigurationDao"/>
     <property name="configuration" ref="continuumConfiguration"/>
+    <property name="buildQueueDao" ref="buildQueueDao"/>
   </bean>
   <bean id="workingDirectoryService" class="org.apache.maven.continuum.utils.DefaultWorkingDirectoryService">
     <property name="configurationService" ref="configurationService"/>

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=726572&r1=726571&r2=726572&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
Sun Dec 14 15:10:16 2008
@@ -29,6 +29,7 @@
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.taskqueue.OverallBuildQueue;
 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.Project;
@@ -90,28 +91,12 @@
      */
     private TaskQueue prepareBuildQueue;
     
-    private PlexusContainer container;
-        
-    public ParallelBuildsManager()
-    {
-        /*synchronized( overallBuildQueues )
-        {
-            try
-            {
-                OverallBuildQueue defaultOverallBuildQueue = ( OverallBuildQueue ) container.lookup(
OverallBuildQueue.class );
-                defaultOverallBuildQueue.setId( 1 );
-                defaultOverallBuildQueue.setName( "DEFAULT_BUILD_QUEUE" );
-            }
-            catch ( ComponentLookupException e )
-            {
-                log.error( "Cannot create default build queue: " + e.getMessage() );
-            }
-        }*/
-        // - add a default OverallBuildQueue which cannot be deleted nor edited
-        // - this default overall build queue must be used whenever no build queue is found
or configured
-        // NOTE: as a workaround for now.. just throw an exception when build or checkout
is attempted without a 
-        //      build queue configured
-    }
+    /**
+     * @plexus.requirement
+     */
+    private ConfigurationService configurationService;
+    
+    private PlexusContainer container;     
     
     // REQUIREMENTS:
     // UI:
@@ -153,7 +138,10 @@
         
         OverallBuildQueue overallBuildQueue =
             getOverallBuildQueue( projectId, BUILD_QUEUE, buildDefinition.getSchedule().getBuildQueues()
);
-                
+        
+        log.info( "\n+++++ project :: " + projectId );
+        log.info( "+++++overall build queue :: " + overallBuildQueue.getId() );
+        
         String buildDefinitionLabel = buildDefinition.getDescription();
         if ( StringUtils.isEmpty( buildDefinitionLabel ) )
         {
@@ -672,7 +660,14 @@
         
         synchronized( overallBuildQueues )
         {
-            this.overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue );
+            if( overallBuildQueues.get( overallBuildQueue.getId() ) == null )
+            {
+                this.overallBuildQueues.put( overallBuildQueue.getId(), overallBuildQueue
);
+            }
+            else
+            {   
+                log.warn( "Overall build queue already in the map" );
+            }
         }
     }
     
@@ -689,6 +684,11 @@
         synchronized( overallBuildQueues )        
         {   
             OverallBuildQueue overallBuildQueue = overallBuildQueues.get( overallBuildQueueId
);
+            if( overallBuildQueue.getName().equals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME
) )
+            {
+                throw new BuildManagerException( "Cannot remove default build queue." );
+            }
+            
             try
             {
                 tasks = overallBuildQueue.getProjectsInBuildQueue();                
@@ -832,12 +832,14 @@
                 throw new BuildManagerException( "No build queues configured." );
             }
             
+            System.out.println( "+++++build queues size : " + buildQueues.size() );
             int size = 0;
             int idx = 0;
             try
             {
                 for( BuildQueue buildQueue : buildQueues )
                 {
+                    System.out.println( "+++++build queue id : " + buildQueue.getId() );
                     OverallBuildQueue overallBuildQueue = overallBuildQueues.get( buildQueue.getId()
); 
                     if( overallBuildQueue != null )
                     {
@@ -879,6 +881,7 @@
         
         if( whereToBeQueued == null )
         {
+            // TODO queue in the default overall build queue
             throw new BuildManagerException( "No build queue found." );
         }
         
@@ -892,8 +895,31 @@
     
     public void contextualize( Context context )
         throws ContextException
-    {
+    {   
         container = (PlexusContainer) context.get( PlexusConstants.PLEXUS_KEY );
+        
+        synchronized( overallBuildQueues )
+        {
+            try
+            {   
+                BuildQueue defaultBuildQueue = configurationService.getDefaultBuildQueue();
+                
+                OverallBuildQueue defaultOverallBuildQueue = ( OverallBuildQueue ) container.lookup(
OverallBuildQueue.class );
+                defaultOverallBuildQueue.setId( defaultBuildQueue.getId() );
+                defaultOverallBuildQueue.setName( defaultBuildQueue.getName() );
+                defaultOverallBuildQueue.setContainer( container );
+                
+                overallBuildQueues.put( defaultOverallBuildQueue.getId(), defaultOverallBuildQueue
);
+            }
+            catch ( ComponentLookupException e )
+            {
+                log.error( "Cannot add default build queue: " + e.getMessage() );
+            }
+            catch ( ContinuumStoreException e )
+            {
+                log.error( "Cannot add default build queue: " + e.getMessage() );
+            }
+        }
     }
 
     public void setContainer( PlexusContainer container )

Modified: continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java?rev=726572&r1=726571&r2=726572&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-core/src/main/java/org/apache/maven/continuum/DefaultContinuum.java
Sun Dec 14 15:10:16 2008
@@ -1478,6 +1478,9 @@
         context.put( AbstractContinuumAction.KEY_UNVALIDATED_PROJECT_GROUP, projectGroup
);
 
         context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId()
) );
+        
+     // used by BuildManager to determine on which build queue will the project be put
+        context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, ( BuildDefinition ) project.getBuildDefinitions().get(
0 ) );
 
         executeAction( "validate-project", context );
 
@@ -1705,6 +1708,20 @@
                 // olamy  : read again the project to have values because store.updateProjectGroup(
projectGroup ); 
                 // remove object data -> we don't display the project name in the build
queue
                 context.put( AbstractContinuumAction.KEY_PROJECT, projectDao.getProject(
project.getId() ) );
+                
+                BuildDefinition defaultBuildDefinition = null;
+                if( projectBuilderId.equals( MavenTwoContinuumProjectBuilder.ID ) )
+                {
+                    defaultBuildDefinition = ( BuildDefinition ) buildDefinitionService.getDefaultMavenTwoBuildDefinitionTemplate().getBuildDefinitions().get(
0 );
+                }
+                else if( projectBuilderId.equals( MavenOneContinuumProjectBuilder.ID ) )
+                {
+                    defaultBuildDefinition = ( BuildDefinition ) buildDefinitionService.getDefaultMavenOneBuildDefinitionTemplate().getBuildDefinitions().get(
0 );
+                }
+                    
+                // used by BuildManager to determine on which build queue will the project
be put
+                context.put( AbstractContinuumAction.KEY_BUILD_DEFINITION, defaultBuildDefinition
);
+                
                 executeAction( "add-project-to-checkout-queue", context );
             }
         }
@@ -1712,6 +1729,10 @@
         {
             throw new ContinuumException( "Error adding projects from modules", e );
         }
+        catch ( BuildDefinitionServiceException e )
+        {
+            throw new ContinuumException( "Error adding projects from modules", e );
+        }
 
         context.put( AbstractContinuumAction.KEY_PROJECT_GROUP_ID, new Integer( projectGroup.getId()
) );
         // add the relevent security administration roles for this project

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=726572&r1=726571&r2=726572&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
Sun Dec 14 15:10:16 2008
@@ -27,6 +27,7 @@
 
 import org.apache.continuum.dao.BuildDefinitionDao;
 import org.apache.continuum.taskqueue.OverallBuildQueue;
+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.Project;
@@ -35,6 +36,8 @@
 import org.jmock.Expectations;
 import org.jmock.Mockery;
 import org.jmock.integration.junit3.JUnit3Mockery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * 
@@ -100,7 +103,7 @@
     
     private void setupOverallBuildQueues()
     {
-        for( int i = 1; i <= 5; i++ )
+        for( int i = 2; i <= 5; i++ )
         {
             OverallBuildQueue overallBuildQueue = ( OverallBuildQueue ) lookup( OverallBuildQueue.class
);            
             overallBuildQueue.setId( i );
@@ -140,7 +143,7 @@
         
         assertNotNull( whereBuildIsQueued );
         assertEquals( 1, whereBuildIsQueued.getId() );
-        assertEquals( "BUILD_QUEUE_1", whereBuildIsQueued.getName() );
+        assertEquals( ConfigurationService.DEFAULT_BUILD_QUEUE_NAME, whereBuildIsQueued.getName()
);
         
         // verify that other build queues are not used
         assertFalse( overallBuildQueues.get( 2 ).isInBuildQueue( 1 ) );
@@ -537,9 +540,23 @@
 
     }*/
     
-    public void testRemoveOverallBuildQueue()
+    public void testRemoveDefaultOverallBuildQueue()
         throws Exception
     {
+        try
+        {
+            buildsManager.removeOverallBuildQueue( 1 );
+            fail( "An exception should have been thrown." );
+        }
+        catch ( BuildManagerException e )
+        {
+            assertEquals( "Cannot remove default build queue.", e.getMessage() );
+        }
+    }
+    
+    public void testRemoveOverallBuildQueue()
+        throws Exception
+    {   
         // queued tasks (both checkout & build tasks) must be transferred to the other
queues!
         setupOverallBuildQueues();
         assertEquals( 5, buildsManager.getOverallBuildQueues().size() );
@@ -596,15 +613,15 @@
         context.checking( new Expectations()
         {
             {
-                one( buildDefinitionDao ).getDefaultBuildDefinition( 6 );
+                one( buildDefinitionDao ).getDefaultBuildDefinition( 7 );
                 will( returnValue( buildDefinition ) );
                 
-                one( buildDefinitionDao ).getDefaultBuildDefinition( 9 );
+                one( buildDefinitionDao ).getDefaultBuildDefinition( 10 );
                 will( returnValue( buildDefinition ) );
             }
         } );
         
-        buildsManager.removeOverallBuildQueue( 1 );
+        buildsManager.removeOverallBuildQueue( 2 );
         
         // verify
         context.assertIsSatisfied();
@@ -613,21 +630,24 @@
         assertEquals( 4, overallBuildQueues.size() );
         
         // checkout queues
-        assertNull( overallBuildQueues.get( 1 ) );           
-        assertTrue( overallBuildQueues.get( 2 ).isInCheckoutQueue( 7 ) );
+        assertNull( overallBuildQueues.get( 2 ) );           
+        assertTrue( overallBuildQueues.get( 1 ).isInCheckoutQueue( 6 ) );   
+        assertTrue( overallBuildQueues.get( 3 ).isInCheckoutQueue( 7 ) ); 
         assertTrue( overallBuildQueues.get( 3 ).isInCheckoutQueue( 8 ) );
-        assertTrue( overallBuildQueues.get( 2 ).isInCheckoutQueue( 10 ) );
-        assertTrue( overallBuildQueues.get( 3 ).isInCheckoutQueue( 6 ) );
-        assertTrue( overallBuildQueues.get( 2 ).isInCheckoutQueue( 9 ) );
+        assertTrue( overallBuildQueues.get( 1 ).isInCheckoutQueue( 9 ) );
+        // shouldn't this be queued in build queue #1?
+        assertTrue( overallBuildQueues.get( 3 ).isInCheckoutQueue( 10 ) );
         
-        // build queues           
-        assertTrue( overallBuildQueues.get( 2 ).isInBuildQueue( 2 ) );
-        assertTrue( overallBuildQueues.get( 3 ).isInBuildQueue( 3 ) );        
-        assertTrue( overallBuildQueues.get( 2 ).isInBuildQueue( 5 ) );
-        assertTrue( overallBuildQueues.get( 3 ).isInBuildQueue( 1 ) );
-        assertTrue( overallBuildQueues.get( 2 ).isInBuildQueue( 4 ) );
+        // build queues                   
+        assertTrue( overallBuildQueues.get( 1 ).isInBuildQueue( 1 ) );   
+        assertTrue( overallBuildQueues.get( 3 ).isInBuildQueue( 2 ) );
+        assertTrue( overallBuildQueues.get( 3 ).isInBuildQueue( 3 ) );
+        assertTrue( overallBuildQueues.get( 1 ).isInBuildQueue( 4 ) );
+        // shouldn't this be queued in build queue #1?
+        assertTrue( overallBuildQueues.get( 3 ).isInBuildQueue( 5 ) );        
     }
     
+    // TODO use the default build queue instead!
     public void testNoBuildQueuesConfigured()
         throws Exception
     {    

Added: continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java?rev=726572&view=auto
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
(added)
+++ continuum/branches/continuum-parallel-builds/continuum-store/src/main/java/org/apache/continuum/dao/BuildQueueDaoImpl.java
Sun Dec 14 15:10:16 2008
@@ -0,0 +1,141 @@
+package org.apache.continuum.dao;
+
+/*
+ * 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 java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+
+import javax.jdo.Extent;
+import javax.jdo.PersistenceManager;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.maven.continuum.model.project.BuildQueue;
+import org.apache.maven.continuum.store.ContinuumStoreException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * 
+ * @author <a href="mailto:oching@apache.org">Maria Odea Ching</a>
+ * @plexus.component role="org.apache.continuum.dao.BuildQueueDao"
+ */
+public class BuildQueueDaoImpl
+    extends AbstractDao
+    implements BuildQueueDao
+{
+    private static Logger log = LoggerFactory.getLogger( BuildQueueDaoImpl.class );
+
+    public BuildQueue addBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException
+    {
+        return (BuildQueue) addObject( buildQueue );
+    }
+
+    public List<BuildQueue> getAllBuildQueues()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildQueue.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            List result = (List) query.execute();
+
+            return result == null ? Collections.EMPTY_LIST : (List<BuildQueue>) pm.detachCopyAll(
result );
+        }
+        finally
+        {
+            tx.commit();
+
+            rollback( tx );
+        }
+    }
+
+    public BuildQueue getBuildQueue( int buildQueueId )
+        throws ContinuumStoreException
+    {
+        return (BuildQueue) getObjectById( BuildQueue.class, buildQueueId );
+    }
+
+    public BuildQueue getBuildQueueByName( String name )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( BuildQueue.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareImports( "import java.lang.String" );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.name == name" );
+
+            Collection result = (Collection) query.execute( name );
+
+            if ( result.size() == 0 )
+            {
+                tx.commit();
+
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            tx.commit();
+
+            return (BuildQueue) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+    
+    public void removeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException
+    {
+        removeObject( buildQueue );
+    }
+
+    public BuildQueue storeBuildQueue( BuildQueue buildQueue )
+        throws ContinuumStoreException
+    {
+        updateObject( buildQueue );
+
+        return buildQueue;
+    }
+}

Modified: continuum/branches/continuum-parallel-builds/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
URL: http://svn.apache.org/viewvc/continuum/branches/continuum-parallel-builds/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java?rev=726572&r1=726571&r2=726572&view=diff
==============================================================================
--- continuum/branches/continuum-parallel-builds/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
(original)
+++ continuum/branches/continuum-parallel-builds/continuum-test/src/main/java/org/apache/maven/continuum/configuration/ConfigurationServiceMock.java
Sun Dec 14 15:10:16 2008
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.Schedule;
 import org.apache.maven.continuum.store.ContinuumStoreException;
 
@@ -188,6 +189,12 @@
     {
     }
 
+    public BuildQueue getDefaultBuildQueue()
+        throws ContinuumStoreException
+    {
+        return null;
+    }
+    
     public Schedule getDefaultSchedule()
         throws ContinuumStoreException
     {



Mime
View raw message