continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject svn commit: r759015 - in /continuum/trunk/continuum-store/src: main/java/org/apache/continuum/dao/ test/java/org/apache/maven/continuum/store/
Date Fri, 27 Mar 2009 03:38:21 GMT
Author: ctan
Date: Fri Mar 27 03:38:20 2009
New Revision: 759015

URL: http://svn.apache.org/viewvc?rev=759015&view=rev
Log:
- include BuildQueue when erasing database
- fixed unit test for BuildQueue

Modified:
    continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
    continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java

Modified: continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java?rev=759015&r1=759014&r2=759015&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
(original)
+++ continuum/trunk/continuum-store/src/main/java/org/apache/continuum/dao/DaoUtilsImpl.java
Fri Mar 27 03:38:20 2009
@@ -26,6 +26,7 @@
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
@@ -90,6 +91,7 @@
         PlexusJdoUtils.removeAll( getPersistenceManager(), LocalRepository.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), DirectoryPurgeConfiguration.class
);
         PlexusJdoUtils.removeAll( getPersistenceManager(), Schedule.class );
+        PlexusJdoUtils.removeAll( getPersistenceManager(), BuildQueue.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Profile.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), Installation.class );
         PlexusJdoUtils.removeAll( getPersistenceManager(), ScmResult.class );

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java?rev=759015&r1=759014&r2=759015&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
(original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTestCase.java
Fri Mar 27 03:38:20 2009
@@ -19,6 +19,7 @@
  * under the License.
  */
 
+import org.apache.continuum.dao.BuildQueueDao;
 import org.apache.continuum.dao.ContinuumReleaseResultDao;
 import org.apache.continuum.dao.DaoUtils;
 import org.apache.continuum.dao.DirectoryPurgeConfigurationDao;
@@ -38,6 +39,7 @@
 import org.apache.continuum.model.repository.RepositoryPurgeConfiguration;
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
@@ -91,6 +93,8 @@
 
     protected ContinuumReleaseResultDao releaseResultDao;
 
+    protected BuildQueueDao buildQueueDao;
+
     protected ProjectGroup defaultProjectGroup;
 
     protected ProjectGroup testProjectGroup2;
@@ -143,6 +147,12 @@
 
     protected ContinuumReleaseResult testContinuumReleaseResult;
 
+    protected BuildQueue testBuildQueue1;
+
+    protected BuildQueue testBuildQueue2;
+
+    protected BuildQueue testBuildQueue3;
+
     private SystemConfiguration systemConfiguration;
 
     @Override
@@ -176,6 +186,8 @@
         projectScmRootDao = (ProjectScmRootDao) lookup( ProjectScmRootDao.class.getName()
);
 
         releaseResultDao = (ContinuumReleaseResultDao) lookup( ContinuumReleaseResultDao.class.getName()
);
+
+        buildQueueDao = (BuildQueueDao) lookup( BuildQueueDao.class.getName() );
     }
 
     protected void createBuildDatabase( boolean isTestFromDataManagementTool )
@@ -230,6 +242,48 @@
             testLocalRepository3.setId( 3 );
         }
 
+        testBuildQueue1 = createTestBuildQueue( "build queue 1" );
+
+        BuildQueue buildQueue1 = createTestBuildQueue( testBuildQueue1 );
+        if ( addToStore )
+        {
+            buildQueue1 = buildQueueDao.addBuildQueue( buildQueue1 );
+            testBuildQueue1.setId( buildQueue1.getId() );
+        }
+        else
+        {
+            buildQueue1.setId( 1 );
+            testBuildQueue1.setId( 1 );
+        }
+
+        testBuildQueue2 = createTestBuildQueue( "build queue 2" );
+
+        BuildQueue buildQueue2 = createTestBuildQueue( testBuildQueue2 );
+        if ( addToStore )
+        {
+            buildQueue2 = buildQueueDao.addBuildQueue( buildQueue2 );
+            testBuildQueue2.setId( buildQueue2.getId() );
+        }
+        else
+        {
+            buildQueue2.setId( 2 );
+            testBuildQueue2.setId( 2 );
+        }
+
+        testBuildQueue3 = createTestBuildQueue( "build queue 3" );
+
+        BuildQueue buildQueue3 = createTestBuildQueue( testBuildQueue3 );
+        if ( addToStore )
+        {
+            buildQueue3 = buildQueueDao.addBuildQueue( buildQueue3 );
+            testBuildQueue3.setId( buildQueue3.getId() );
+        }
+        else
+        {
+            buildQueue3.setId( 3 );
+            testBuildQueue3.setId( 3 );
+        }
+
         defaultProjectGroup = createTestProjectGroup( "Default Group", "The Default Group",
                                                       "org.apache.maven.test.default", localRepository1
);
 
@@ -244,7 +298,12 @@
                                           "scmUrl2", 1, "url2", "version2", "workingDirectory2"
);
 
         testSchedule1 = createTestSchedule( "name1", "description1", 1, "cronExpression1",
true );
+        testSchedule1.addBuildQueue( buildQueue1 );
+        testSchedule1.addBuildQueue( buildQueue2 );
+        
         testSchedule2 = createTestSchedule( "name2", "description2", 2, "cronExpression2",
true );
+        testSchedule2.addBuildQueue( buildQueue3 );
+
         testSchedule3 = createTestSchedule( "name3", "description3", 3, "cronExpression3",
true );
 
         testInstallationJava13 =
@@ -1020,18 +1079,26 @@
     protected static Schedule createTestSchedule( Schedule schedule )
     {
         return createTestSchedule( schedule.getName(), schedule.getDescription(), schedule.getDelay(),
schedule
-            .getCronExpression(), schedule.isActive() );
+            .getCronExpression(), schedule.isActive(), schedule.getBuildQueues() );
     }
 
     protected static Schedule createTestSchedule( String name, String description, int delay,
String cronExpression,
                                                   boolean active )
     {
+        return createTestSchedule( name, description, delay, cronExpression, active, null
);
+    }
+                                                  
+    protected static Schedule createTestSchedule( String name, String description, int delay,
String cronExpression,
+                                                  boolean active, List<BuildQueue>
buildQueues )
+    {
         Schedule schedule = new Schedule();
         schedule.setActive( active );
         schedule.setCronExpression( cronExpression );
         schedule.setDelay( delay );
         schedule.setDescription( description );
         schedule.setName( name );
+        schedule.setBuildQueues( buildQueues );
+
         return schedule;
     }
 
@@ -1523,6 +1590,25 @@
                       actualConfig.getEndTime() );
     }
 
+    protected static BuildQueue createTestBuildQueue( String name )
+    {
+        BuildQueue buildQueue = new BuildQueue();
+        buildQueue.setName( name );
+
+        return buildQueue;
+    }
+
+    protected static BuildQueue createTestBuildQueue( BuildQueue buildQueue )
+    {
+        return createTestBuildQueue( buildQueue.getName() );
+    }
+
+    protected static void assertBuildQueueEquals( BuildQueue expectedConfig, BuildQueue actualConfig
)
+    {
+        assertEquals( "compare build queue - id", expectedConfig.getId(), actualConfig.getId()
);
+        assertEquals( "compare build queue - name", expectedConfig.getName(), actualConfig.getName()
);
+    }
+
     /**
      * Setup JDO Factory
      *

Modified: continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java?rev=759015&r1=759014&r2=759015&view=diff
==============================================================================
--- continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
(original)
+++ continuum/trunk/continuum-store/src/test/java/org/apache/maven/continuum/store/ContinuumStoreTest.java
Fri Mar 27 03:38:20 2009
@@ -31,6 +31,7 @@
 import org.apache.maven.continuum.installation.InstallationService;
 import org.apache.maven.continuum.model.project.BuildDefinition;
 import org.apache.maven.continuum.model.project.BuildDefinitionTemplate;
+import org.apache.maven.continuum.model.project.BuildQueue;
 import org.apache.maven.continuum.model.project.BuildResult;
 import org.apache.maven.continuum.model.project.Project;
 import org.apache.maven.continuum.model.project.ProjectDependency;
@@ -297,8 +298,13 @@
     }
 
     public void testAddSchedule()
+        throws ContinuumStoreException
     {
+        BuildQueue buildQueue = buildQueueDao.getAllBuildQueues().get( 0 );
+
         Schedule newSchedule = createTestSchedule( "testAddSchedule", "testAddSchedule desc",
10, "cron test", false );
+        newSchedule.addBuildQueue( buildQueue );
+
         Schedule copy = createTestSchedule( newSchedule );
         scheduleDao.addSchedule( newSchedule );
         copy.setId( newSchedule.getId() );
@@ -306,6 +312,8 @@
         List schedules = scheduleDao.getAllSchedulesByName();
         Schedule retrievedSchedule = (Schedule) schedules.get( schedules.size() - 1 );
         assertScheduleEquals( copy, retrievedSchedule );
+        assertEquals( "check size of build queues", 1, retrievedSchedule.getBuildQueues().size()
);
+        assertBuildQueueEquals( buildQueue, (BuildQueue) retrievedSchedule.getBuildQueues().get(
0 ) );
     }
 
     public void testEditSchedule()
@@ -315,12 +323,18 @@
         newSchedule.setName( "name1.1" );
         newSchedule.setDescription( "testEditSchedule updated description" );
 
+        assertEquals( "check size of build queues", 2, newSchedule.getBuildQueues().size()
);
+        BuildQueue buildQueue1 = (BuildQueue)newSchedule.getBuildQueues().get( 0 );
+        BuildQueue buildQueue2 = (BuildQueue)newSchedule.getBuildQueues().get( 1 );
+
         Schedule copy = createTestSchedule( newSchedule );
         copy.setId( newSchedule.getId() );
         scheduleDao.updateSchedule( newSchedule );
 
         Schedule retrievedSchedule = (Schedule) scheduleDao.getAllSchedulesByName().get(
0 );
         assertScheduleEquals( copy, retrievedSchedule );
+        assertBuildQueueEquals( buildQueue1, (BuildQueue) retrievedSchedule.getBuildQueues().get(
0 ) );
+        assertBuildQueueEquals( buildQueue2, (BuildQueue) retrievedSchedule.getBuildQueues().get(
1 ) );
     }
 
     public void testRemoveSchedule()
@@ -328,7 +342,7 @@
         Schedule schedule = (Schedule) scheduleDao.getAllSchedulesByName().get( 2 );
 
         // TODO: test if it has any attachments
-
+        assertEquals( "check size of build queues", 0, schedule.getBuildQueues().size() );
         scheduleDao.removeSchedule( schedule );
 
         List schedules = scheduleDao.getAllSchedulesByName();
@@ -337,18 +351,33 @@
     }
 
     public void testGetAllSchedules()
+        throws ContinuumStoreException
     {
         List schedules = scheduleDao.getAllSchedulesByName();
+        List<BuildQueue> buildQueues = buildQueueDao.getAllBuildQueues();
 
         assertEquals( "check item count", 3, schedules.size() );
+        assertEquals( "check build queues count", 3, buildQueues.size() );
+
+        BuildQueue buildQueue1 = buildQueues.get( 0 );
+        BuildQueue buildQueue2 = buildQueues.get( 1 );
+        BuildQueue buildQueue3 = buildQueues.get( 2 );
 
         // check equality and order
         Schedule schedule = (Schedule) schedules.get( 0 );
         assertScheduleEquals( testSchedule1, schedule );
+        assertEquals( "check size of buildQueues", 2, schedule.getBuildQueues().size() );
+        assertBuildQueueEquals( buildQueue1, (BuildQueue) schedule.getBuildQueues().get(
0 ) );
+        assertBuildQueueEquals( buildQueue2, (BuildQueue) schedule.getBuildQueues().get(
1 ) );
+        
         schedule = (Schedule) schedules.get( 1 );
         assertScheduleEquals( testSchedule2, schedule );
+        assertEquals( "check size of buildQueues", 1, schedule.getBuildQueues().size() );
+        assertBuildQueueEquals( buildQueue3, (BuildQueue) schedule.getBuildQueues().get(
0 ) );
+
         schedule = (Schedule) schedules.get( 2 );
         assertScheduleEquals( testSchedule3, schedule );
+        assertEquals( "check size of buildQueues", 0, schedule.getBuildQueues().size() );
     }
 
     public void testAddProfile()



Mime
View raw message