You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by tr...@apache.org on 2005/07/18 00:53:02 UTC

svn commit: r219418 [2/2] - in /maven/continuum/trunk: continuum-api/src/main/java/org/apache/maven/continuum/store/ continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/ continuum-core/src/main/java/org/apache/maven/continuum/execut...

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java Sun Jul 17 15:52:59 2005
@@ -16,57 +16,27 @@
  * limitations under the License.
  */
 
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.apache.maven.continuum.AbstractContinuumTest;
-import org.apache.maven.continuum.utils.ContinuumUtils;
-import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
-import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
-import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumJPoxStore;
-import org.apache.maven.continuum.project.ContinuumNotifier;
-import org.apache.maven.continuum.project.ContinuumProject;
-import org.apache.maven.continuum.project.ContinuumProjectState;
-import org.apache.maven.continuum.project.MavenTwoProject;
-import org.apache.maven.continuum.scm.ScmFile;
-import org.apache.maven.continuum.scm.ScmResult;
 
 import org.codehaus.plexus.jdo.JdoFactory;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.JDOHelper;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public class ModelloJPoxContinuumStoreTest
-    extends AbstractContinuumTest
+    extends AbstractContinuumStoreTest
 {
-    private ContinuumStore store;
-
-    private JdoFactory jdoFactory;
-
-    public void setUp()
-        throws Exception
+    public ModelloJPoxContinuumStoreTest()
     {
-        super.setUp();
-
-        jdoFactory = (JdoFactory) lookup( JdoFactory.ROLE );
-
-        store = (ContinuumStore) lookup( ContinuumStore.ROLE );
+        super( "modello", ModelloJPoxContinuumStore.class );
     }
 
     public void testTransactionHandling()
         throws Exception
     {
+        JdoFactory jdoFactory = (JdoFactory) lookup( JdoFactory.ROLE );
+
         ContinuumJPoxStore store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
 
         // ----------------------------------------------------------------------
@@ -158,816 +128,10 @@
         assertNull( store.getThreadState() );
     }
 
-    // ----------------------------------------------------------------------
-    // Project
-    // ----------------------------------------------------------------------
-
-    public void testStoreProject()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        assertEquals( ModelloJPoxContinuumStore.class, store.getClass() );
-
-        Properties configuration = new Properties();
-
-        configuration.setProperty( "foo", "bar" );
-
-        String projectId = store.addProject( makeMavenTwoProject( "Test Project",
-                                                                  "scm:local:src/test/repo",
-                                                                  "foo@bar.com",
-                                                                  "1.0",
-                                                                  "a b",
-                                                                  "/tmp" ) );
-
-        assertNotNull( "The project id is null.", projectId );
-
-        ContinuumProject actual = store.getProject( projectId );
-
-        assertProjectEquals( projectId, makeMavenTwoProject( "Test Project",
-                                                             "scm:local:src/test/repo",
-                                                             "foo@bar.com",
-                                                             "1.0",
-                                                             "a b",
-                                                             "/tmp" ), actual );
-    }
-
-
-    public void testGetNonExistingProject()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        try
-        {
-            store.getProject( "foo" );
-
-            fail( "Expected ContinuumStoreException.") ;
-        }
-        catch( ContinuumStoreException ex )
-        {
-            // expected
-        }
-    }
-
-    public void testProjectCRUD()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        String name = "Test Project 2";
-        String scmUrl = "scm:local:jalla";
-        String nagEmailAddress = "foo@bar.com";
-        String version = "1.0";
-        String commandLineArguments = "";
-        String workingDirectory = "/tmp";
-
-        ContinuumProject project = makeMavenTwoProject( name,
-                                                        scmUrl,
-                                                        nagEmailAddress,
-                                                        version,
-                                                        commandLineArguments,
-                                                        workingDirectory );
-
-        String projectId = store.addProject( project );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        project = store.getProject( projectId );
-
-        assertNotNull( project );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        ScmResult scmResult = new ScmResult();
-
-        scmResult.setSuccess( true );
-
-        setCheckoutDone( store, projectId, scmResult, null, null );
-
-        project = store.getProject( projectId );
-
-        assertNotNull( project );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        project = store.getProject( projectId );
-
-        String name2 = "name 2";
-        String scmUrl2 = "scm url 2";
-        String emailAddress2 = "2@bar";
-        String version2 = "v2";
-        String commandLineArguments2 = "";
-
-        project.setName( name2 );
-        project.setScmUrl( scmUrl2 );
-
-        ContinuumNotifier notifier = ((ContinuumNotifier) project.getNotifiers().get( 0 ));
-        notifier.setType( "kewk" );
-        notifier.getConfiguration().put( "address", emailAddress2 );
-        notifier.getConfiguration().put( "name", "tryg" );
-        project.setVersion( version2 );
-        project.setCommandLineArguments( commandLineArguments2 );
-
-        store.updateProject( project );
-
-        project = store.getProject( projectId );
-
-        notifier = new ContinuumNotifier();
-        notifier.setType( "kewk" );
-        notifier.getConfiguration().put( "address", emailAddress2 );
-        notifier.getConfiguration().put( "name", "tryg" );
-        List notifiers = new ArrayList();
-        notifiers.add( notifier );
-
-        assertProjectEquals( projectId,
-                             name2,
-                             scmUrl2,
-                             notifiers,
-                             version2,
-                             commandLineArguments2,
-                             MavenTwoBuildExecutor.ID,
-                             workingDirectory,
-                             project );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        store.removeProject( projectId );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        try
-        {
-            store.getProject( "foo" );
-
-            fail( "Expected ContinuumStoreException." );
-        }
-        catch ( ContinuumStoreException ex )
-        {
-            // expected
-        }
-    }
-
-    public void testGetAllProjects()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        String name1 = "Test Project 1";
-        String scmUrl1 = "scm:local:src/test/repo/foo";
-        String nagEmailAddress1 = "foo@bar.com";
-        String version1 = "1.0";
-        String commandLineArguments1 = "";
-        String workingDirectory1 = "/tmp";
-
-        String id1 = addMavenTwoProject( store,
-                                 name1,
-                                 scmUrl1,
-                                 nagEmailAddress1,
-                                 version1,
-                                 commandLineArguments1,
-                                 workingDirectory1 );
-
-        String name2 = "Test Project 2";
-        String scmUrl2 = "scm:local:src/test/repo/bar";
-        String nagEmailAddress2 = "foo@bar.com";
-        String version2 = "1.0";
-        String commandLineArguments2 = "";
-        String workingDirectory2 = "/tmp";
-
-        String id2 = addMavenTwoProject( store,
-                                 name2,
-                                 scmUrl2,
-                                 nagEmailAddress2,
-                                 version2,
-                                 commandLineArguments2,
-                                 workingDirectory2 );
-
-        Map projects = new HashMap();
-
-        for ( Iterator it = store.getAllProjects().iterator(); it.hasNext(); )
-        {
-            ContinuumProject project = (ContinuumProject) it.next();
-
-            assertNotNull( "While getting all projects: project.id == null", project.getId() );
-
-            assertNotNull( "While getting all projects: project.name == null", project.getName() );
-
-            projects.put( project.getName(), project );
-        }
-
-        ContinuumProject project1 = (ContinuumProject) projects.get( name1 );
-
-        assertProjectEquals( id1,
-                             name1,
-                             scmUrl1,
-                             nagEmailAddress1,
-                             version1,
-                             commandLineArguments1,
-                             MavenTwoBuildExecutor.ID,
-                             workingDirectory1,
-                             project1 );
-
-        ContinuumProject project2 = (ContinuumProject) projects.get( name2 );
-
-        assertProjectEquals( id2,
-                             name2,
-                             scmUrl2,
-                             nagEmailAddress2,
-                             version2,
-                             commandLineArguments2,
-                             MavenTwoBuildExecutor.ID,
-                             workingDirectory2,
-                             project2 );
-    }
-
-    public void testRemoveProject()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        String projectId = addMavenTwoProject( "Remove Test Project", "scm:remove-project" );
-
-        String buildId = createBuild( store, projectId, false );
-
-        ScmResult scmResult = new ScmResult();
-
-        ScmFile file = new ScmFile();
-
-        file.setPath( "foo" );
-
-        scmResult.addFile( file );
-
-        setBuildResult( store,
-                        buildId,
-                        ContinuumProjectState.OK,
-                        makeContinuumBuildExecutionResult( true, "", "", 0 ),
-                        scmResult,
-                        null );
-
-        store.removeProject( projectId );
-    }
-
-    private ContinuumBuildExecutionResult makeContinuumBuildExecutionResult( boolean success,
-                                                                             String standardOutput,
-                                                                             String standardError,
-                                                                             int exitCode )
-    {
-        return new ContinuumBuildExecutionResult( success,
-                                                  standardOutput,
-                                                  standardError,
-                                                  exitCode );
-    }
-
-    // ----------------------------------------------------------------------
-    // Maven Two project tests
-    // ----------------------------------------------------------------------
-
-    public void testUpdateMavenTwoProject()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        String projectId = addMavenTwoProject( "Maven Two Project", "scm:foo" );
-
-        MavenTwoProject project = (MavenTwoProject) store.getProject( projectId );
-
-        project.setName( "New name" );
-        project.setGoals( "clean test" );
-
-        store.updateProject( project );
-
-        project = (MavenTwoProject) store.getProject( projectId );
-
-        assertEquals( "New name", project.getName() );
-        assertEquals( "clean test", project.getGoals() );
-    }
-/*
-    public void testUpdateMavenTwoProjectWithANonJdoObject()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        // ----------------------------------------------------------------------
-        // Make a project in the store
-        // ----------------------------------------------------------------------
-
-        String projectId = addMavenTwoProject( "Maven Two Project", "scm:foo" );
-
-        // ----------------------------------------------------------------------
-        // This is a object constructed from outside Continuum, typically
-        // something that comes in over the wire.
-        // ----------------------------------------------------------------------
-
-        MavenTwoProject external = makeStubMavenTwoProject( "Maven Two Project", "scm:foo" );
-
-        external.setId( projectId );
-
-        external.setName( "New name" );
-
-        MavenTwoProject p = (MavenTwoProject) store.getProject( projectId );
-
-        assertEquals( "Maven Two Project", p.getName() );
-
-        store.updateProject( external );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        MavenTwoProject actual = (MavenTwoProject) store.getProject( projectId );
-
-        assertEquals( "New name", actual.getName() );
-    }
-*/
-    // ----------------------------------------------------------------------
-    // Build
-    // ----------------------------------------------------------------------
-
-    public void testBuild()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        lookup( JdoFactory.ROLE );
-
-        String projectId = addMavenTwoProject( "Build Test Project", "scm:build" );
-
-        // ----------------------------------------------------------------------
-        // Construct a build object
-        // ----------------------------------------------------------------------
-
-        String buildId = createBuild( store, projectId, false );
-
-        ScmResult scmResult = new ScmResult();
-
-        scmResult.setCommandOutput( "commandOutput" );
-
-        scmResult.setProviderMessage( "providerMessage" );
-
-        scmResult.setSuccess( true );
-
-        ScmFile scmFile = new ScmFile();
-
-        scmFile.setPath( "/foo" );
-
-        scmResult.getFiles().add( scmFile );
-
-        setBuildComplete( store,
-                          buildId,
-                          scmResult,
-                          makeContinuumBuildExecutionResult( true, "stdout", "stderr", 10 ) );
-
-        // ----------------------------------------------------------------------
-        // Store and check the build object
-        // ----------------------------------------------------------------------
-
-        Collection builds = store.getBuildsForProject( projectId, 0, 0 );
-
-        assertNotNull( "The collection with all builds was null.", builds );
-
-        assertEquals( "Expected the build set to contain a single build.", 1, builds.size() );
-
-        ContinuumBuild build = (ContinuumBuild) builds.iterator().next();
-
-        assertNotNull( build );
-
-        assertEquals( "build.id", buildId, build.getId() );
-    }
-
-    private void setBuildComplete( ContinuumStore store,
-                                   String buildId,
-                                   ScmResult scmResult,
-                                   ContinuumBuildExecutionResult result )
-        throws ContinuumStoreException
-    {
-        ContinuumBuild build = store.getBuild( buildId );
-
-        build.setScmResult( scmResult );
-
-        build.setSuccess( result.isSuccess() );
-
-        build.setStandardOutput( result.getStandardOutput() );
-
-        build.setStandardError( result.getStandardError() );
-
-        build.setExitCode( result.getExitCode() );
-
-        store.updateBuild( build );
-    }
-
-    public void testTheAssociationBetweenTheProjectAndItsBuilds()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        lookup( JdoFactory.ROLE );
-
-        // ----------------------------------------------------------------------
-        // Set up projects
-        // ----------------------------------------------------------------------
-
-        String projectId = addMavenTwoProject( "Association Test Project", "scm:association" );
-
-        String projectIdFoo = addMavenTwoProject( "Foo Project", "scm:association-foo" );
-
-        String projectIdBar = addMavenTwoProject( "Bar Project", "scm:association-bar" );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        List expectedBuilds = new ArrayList();
-
-        for ( int i = 0; i < 10; i++ )
-        {
-            expectedBuilds.add( 0, createBuild( store, projectId, false ) );
-
-            createBuild( store, projectIdFoo, false );
-
-            createBuild( store, projectIdBar, false );
-
-            createBuild( store, projectIdFoo, false );
-        }
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        ContinuumBuild build = store.getLatestBuildForProject( projectId );
-
-        assertNotNull( build );
-
-        assertEquals( build.getId(), (String) expectedBuilds.get( 0 ) );
-
-        Collection actualBuilds = store.getBuildsForProject( projectId, 0, 0 );
-
-        assertEquals( "builds.size", expectedBuilds.size(), actualBuilds.size() );
-
-        Iterator expectedIt = expectedBuilds.iterator();
-
-        Iterator actualIt = actualBuilds.iterator();
-
-        for ( int i = 0; expectedIt.hasNext(); i++ )
-        {
-            String expectedBuildId = (String) expectedIt.next();
-
-            String actualBuildId = ((ContinuumBuild) actualIt.next()).getId();
-
-            assertEquals( "builds[" + i + "]", expectedBuildId, actualBuildId );
-        }
-    }
-
-    public void testGetLatestBuild()
-        throws Exception
-    {
-        String projectId = addMavenTwoProject( "Association Test Project", "scm:association" );
-
-        int size = 10;
-
-        List expectedBuilds = new ArrayList();
-
-        for ( int i = 0; i < size; i++ )
-        {
-            expectedBuilds.add( createBuild( store, projectId, false ) );
-        }
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        ContinuumBuild build = store.getLatestBuildForProject( projectId );
-
-        assertNotNull( build );
-
-        assertEquals( build.getId(), (String) expectedBuilds.get( size - 1 ) );
-
-        Collection actualBuilds = store.getBuildsForProject( projectId, 0, 0 );
-
-        assertEquals( build.getId(), ( (ContinuumBuild) actualBuilds.iterator().next() ).getId() );
-
-        assertEquals( size, actualBuilds.size() );
-    }
-
-    public void testBuildResult()
-        throws Exception
-    {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-  From continuum-commits-return-563-apmail-maven-continuum-commits-archive=maven.apache.org@maven.apache.org Sun Jul 17 22:53:24 2005
Return-Path: <co...@maven.apache.org>
Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org
Received: (qmail 71413 invoked from network); 17 Jul 2005 22:53:23 -0000
Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199)
  by minotaur.apache.org with SMTP; 17 Jul 2005 22:53:23 -0000
Received: (qmail 52282 invoked by uid 500); 17 Jul 2005 22:53:23 -0000
Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org
Received: (qmail 52254 invoked by uid 500); 17 Jul 2005 22:53:23 -0000
Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm
Precedence: bulk
List-Help: <ma...@maven.apache.org>
List-Unsubscribe: <ma...@maven.apache.org>
List-Post: <ma...@maven.apache.org>
Lis      lookup( JdoFactory.ROLE );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        String projectId = addMavenTwoProject( "Build Result Project", "scm:build/result" );
-
-        long now = System.currentTimeMillis();
-
-        String buildId = createBuild( store, projectId, false );
-
-        assertIsCommitted( store );
-
-        assertNotNull( buildId );
-
-        // ----------------------------------------------------------------------
-        // Check that the project's state has been updated
-        // ----------------------------------------------------------------------
-
-        assertIsCommitted( store );
-
-        // ----------------------------------------------------------------------
-        // Check the build
-        // ----------------------------------------------------------------------
-
-        ContinuumBuild build = store.getBuild( buildId t-Id: <continuum-commits.maven.apache.org>
Reply-To: continuum-dev@maven.apache.org
Delivered-To: mailing list continuum-commits@maven.apache.org
Received: (qmail 52213 invoked by uid 99); 17 Jul 2005 22:53:22 -0000
X-ASF-Spam-Status: No, hits=-9.8 required=10.0
	tests=ALL_TRUSTED,NO_REAL_NAME
X-Spam-Check-By: apache.org
Received: from [209.237.227.194] (HELO minotaur.apache.org) (209.237.227.194)
    by apache.org (qpsmtpd/0.29) with SMTP; Sun, 17 Jul 2005 15:53:10 -0700
Received: (qmail 71278 invoked by uid 65534); 17 Jul 2005 22:53:08 -0000
Message-ID: <20...@minotaur.apache.org>
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: svn commit: r219418 [1/2] - in /maven/continuum/trunk:
 continuum-api/src/main/java/org/apache/maven/continuum/store/
 continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/
 continuum-core/src/main/java/org/apache/maven/continuum/execut...
Date: Sun, 17 Jul 2005 22:53:02 -0000
To: continuum-c);
-
-        assertIsCommitted( store );
-
-        assertNotNull( build );
-
-        assertEquals( now / 10000, build.getStartTime() / 10000 );
-
-        assertEquals( 0, build.getEndTime() );
-
-        assertNull( build.getError() );
-
-        assertEquals( ContinuumProjectState.BUILDING, build.getState() );
-
-        // ----------------------------------------------------------------------
-        // Check the build result
-        // ----------------------------------------------------------------------
-
-        assertIsCommitted( store );
-
-        ScmResult scmResult = new ScmResult();
-
-        setBuildResult( store,
-                        buildId,
-                        ContinuumProjectState.OK,
-                        makeContinuumBuildExecutionResult( true, "output", "error", 1 ),
-                        scmResult,
-                        null );
-
-        assertIsCommitted( store );
-
-        // ----------------------------------------------------------------------
-        //
-ommits@maven.apache.org
From: trygvis@apache.org
X-Mailer: svnmailer-1.0.2
X-Virus-Checked: Checked by ClamAV on apache.org
X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N

Author: trygvis
Date: Sun Jul 17 15:52:59 2005
New Revision: 219418

URL: http://svn.apache.org/viewcvs?rev=219418&view=rev
Log:
o Copying the ModelloJPoxContinuumStoreTest to AbstractContinuumTest and made
  both the Modello and JDO test cases extend this class.
o Adding ContinuumObjectNotFoundException.
o Centralizing the lookup of ContinuumStore to make it easier to switch out the
  implementation.
o Removing empty test configuration files.
o Fixing a bug in the Maven 1 project builder where a project would get added
  to the project building result even if the builder threw a exception.
o Fixing a bug in DefaultContinuum where a Maven 1 project would be added even
  if there was warnings while building the project.

Added:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundEx        // ----------------------------------------------------------------------
-
-        build = store.getBuild( buildId );
-
-        assertIsCommitted( store );
-
-        assertEquals( 1, build.getExitCode() );
-
-        assertEquals( "output", build.getStandardOutput() );
-
-        assertEquals( "error", build.getStandardError() );
-    }
-
-    // ----------------------------------------------------------------------
-    // Private utility methods
-    // ----------------------------------------------------------------------
-
-    private String addMavenTwoProject( String name, String scmUrl )
-        throws Exception
-    {
-        return addMavenTwoProject( (ContinuumStore) lookup( ContinuumStore.ROLE ),
-                           makeStubMavenTwoProject( name, scmUrl ) );
-    }
-
-    // ----------------------------------------------------------------------
-    // Public utility methods
-    // ----------------------------------------------------------------------
-
-    public static Strception.java   (with props)
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java   (with props)
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java
      - copied, changed from r219317, maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java   (with props)
Removed:
    maven/continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/core/
    maven/continuum/trunk/continuum-core/src/test/resources/org/apache/maven/continuum/store/
Modified:
    maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
    maven/continuum/truning addMavenTwoProject( ContinuumStore store,
-                                             ContinuumProject project )
-        throws Exception
-    {
-        String projectId = store.addProject( project );
-
-        ScmResult scmResult = new ScmResult();
-
-        scmResult.setSuccess( true );
-
-        scmResult.setCommandOutput( "commandOutput" );
-
-        scmResult.setProviderMessage( "providerMessage" );
-
-        ScmFile scmFile = new ScmFile();
-
-        scmFile.setPath( "/foo" );
-
-        scmResult.addFile( scmFile );
-
-        setCheckoutDone( store, projectId, scmResult, null, null );
-
-        project = store.getProject( projectId );
-
-        assertNotNull( project );
-
-        return projectId;
-    }
-
-    public static String addMavenTwoProject( ContinuumStore store,
-                                             String name,
-                                             String scmUrl )
-        throws Exception
-    {
-        return addMavenTwoProject( store, makeStubMavenTwoPrk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
    maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
    maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AbstractContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/ContinuumCoroject( name, scmUrl ) );
-    }
-
-    public static String addMavenTwoProject( ContinuumStore store,
-                                             String name,
-                                             String scmUrl,
-                                             String nagEmailAddress,
-                                             String version,
-                                             String commandLineArguments,
-                                             String workingDirectory )
-        throws Exception
-    {
-        String projectId = store.addProject( makeMavenTwoProject( name,
-                                                                  scmUrl,
-                                                                  nagEmailAddress,
-                                                                  version,
-                                                                  commandLineArguments,
-                                                                  workingDirectory ) );
-
- eTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/ContinuumJPoxStoreTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
    maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java
    maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProject.java
    maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java

Added: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.       ScmResult scmResult = new ScmResult();
-
-        scmResult.setSuccess( true );
-
-        setCheckoutDone( store, projectId, scmResult, null, null );
-
-        ContinuumProject project = store.getProject( projectId );
-
-        assertNotNull( project );
-
-        return projectId;
-    }
-
-    public static String createBuild( ContinuumStore store, String projectId, boolean forced )
-        throws ContinuumStoreException
-    {
-        ContinuumBuild build = new ContinuumBuild();
-
-        build.setStartTime( System.currentTimeMillis() );
-
-        build.setState( ContinuumProjectState.BUILDING );
-
-        build.setForced( forced );
-
-        return store.addBuild( projectId, build );
-    }
-
-    private static void setCheckoutDone( ContinuumStore store,
-                                  String projectId,
-                                  ScmResult scmResult,
-                                  String errorMessage,
-                                  Throwable exception  )
-        throwsjava
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.java?rev=219418&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.java (added)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.java Sun Jul 17 15:52:59 2005
@@ -0,0 +1,30 @@
+package org.apache.maven.continuum.store;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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 dist ContinuumStoreException
-    {
-        ContinuumProject project = store.getProject( projectId );
-
-        project.setScmResult( scmResult );
-
-        project.setCheckOutErrorMessage( errorMessage );
-
-        project.setCheckOutErrorException( ContinuumUtils.throwableToString( exception ) );
-
-        store.updateProject( project );
-    }
-
-    public static void setBuildResult( ContinuumStore store,
-                                       String buildId,
-                                       int state,
-                                       ContinuumBuildExecutionResult result,
-                                       ScmResult scmResult,
-                                       Throwable error )
-        throws ContinuumStoreException
-    {
-        ContinuumBuild build = store.getBuild( buildId );
-
-        build.setState( state );
-
-        build.setEndTime( new Date().getTime() );
-
-        build.setError( ContinuumUtils.throwableToString( error ) );
-
-        build.setScmResult( scmResulributed 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.
+ */
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class ContinuumObjectNotFoundException
+    extends ContinuumStoreException
+{
+    public ContinuumObjectNotFoundException( String type, String id )
+    {
+        super( "Could not find object. Type '" + type + "'. Id: '" + id + "'." );
+    }
+}

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumObjectNotFoundException.java
-----------------------------------------------------------------------t );
-
-        // ----------------------------------------------------------------------
-        // Copy over the build result
-        // ----------------------------------------------------------------------
-
-        build.setSuccess( result.isSuccess() );
-
-        build.setStandardOutput( result.getStandardOutput() );
-
-        build.setStandardError( result.getStandardError() );
-
-        build.setExitCode( result.getExitCode() );
-
-        store.updateBuild( build );
-    }
-
-    // ----------------------------------------------------------------------
-    // Assertions
-    // ----------------------------------------------------------------------
-
     private void assertIsCommitted( ContinuumStore store )
     {
         ContinuumJPoxStore.ThreadState state = ( (ModelloJPoxContinuumStore) store ).getStore().getThreadState();
 
         assertNull( state );
     }
-
-    private void assertProjectEquals( String projectId,
-                                      ContinuumProject expected,
-   -------
    svn:keywords = Id

Modified: maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-api/src/main/java/org/apache/maven/continuum/store/ContinuumStore.java Sun Jul 17 15:52:59 2005
@@ -53,7 +53,7 @@
     Collection getAllProjects()
         throws ContinuumStoreException;
 
-    ContinuumProject getProjectByName( String nameSearchPattern )
+    ContinuumProject getProjectByName( String name )
         throws ContinuumStoreException;
 
     ContinuumProject getProjectByScmUrl( String scmUrl )

Modified: maven/continuum/trunk/continuum-core/src/main                                   ContinuumProject actual )
-    {
-        assertProjectEquals( projectId,
-                             expected.getName(),
-                             expected.getScmUrl(),
-                             expected.getNotifiers(),
-                             expected.getVersion(),
-                             expected.getCommandLineArguments(),
-                             expected.getExecutorId(),
-                             expected.getWorkingDirectory(),
-                             actual );
-    }
-
-    private void assertProjectEquals( String projectId,
-                                      String name,
-                                      String scmUrl,
-                                      String emailAddress,
-                                      String version,
-                                      String commandLineArguments,
-                                      String builderId,
-                                      String workingDirectory,
-                                      ContinuumProject actual )
-    {
-        assertProjectEquals( projectId,
-                             name,
-                             scmUrl,
-                             createMailNotifierList( emailAddress),
-                             version,
-                             commandLineArguments,
-                             builderId,
-                             workingDirectory,
-                             actual );
-    }
-
-    private void assertProjectEquals( String projectId,
-                                      String name,
-                                      String scmUrl,
-                                      List notifiers,
-                                      String version,
-                                      String commandLineArguments,
-                                      String builderId,
-                                      String workingDirectory,
-                                      ContinuumProject actual )
-    {
-        a/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/buildcontroller/DefaultBuildController.java Sun Jul 17 15:52:59 2005
@@ -18,7 +18,6 @@
 
 import java.util.Collection;
 import java.util.HashMap;
-import java.util.Iterator;
 import java.util.Map;
 
 import org.apache.maven.continuum.core.action.AbstractContinuumAction;
@@ -26,7 +25,6 @@
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.projectssertEquals( "project.id", projectId, actual.getId() );
-
-        assertEquals( "project.name", name, actual.getName() );
-
-        assertEquals( "project.scmUrl", scmUrl, actual.getScmUrl() );
-
-        assertNotNull( "project.notifiers", actual.getNotifiers() );
-
-        assertEquals( "project.notifiers.size", notifiers.size(), actual.getNotifiers().size() );
-
-        for ( int i = 0; i < notifiers.size(); i++ )
-        {
-            ContinuumNotifier notifier = (ContinuumNotifier) notifiers.get( i );
-
-            ContinuumNotifier actualNotifier = (ContinuumNotifier) actual.getNotifiers().get( i );
-
-            assertEquals( "project.notifiers.notifier.type", notifier.getType(), actualNotifier.getType() );
-
-            assertEquals( "project.notifiers.notifier.configuration.address",
-                          notifier.getConfiguration().get( "address" ),
-                          actualNotifier.getConfiguration().get( "address" ) );
-        }
-
-        assertEquals( "project.version", ve.ContinuumProjectState;
-import org.apache.maven.continuum.scm.ScmFile;
 import org.apache.maven.continuum.scm.ContinuumScmException;
 import org.apache.maven.continuum.scm.ScmResult;
 import org.apache.maven.continuum.store.ContinuumStore;
@@ -132,7 +130,9 @@
                     // Check to see if there was a error while checking out the project
                     // ----------------------------------------------------------------------
 
-                    if ( !StringUtils.isEmpty( checkoutErrorMessage ) || !StringUtils.isEmpty( checkoutErrorException ) )
+                    if ( !StringUtils.isEmpty( checkoutErrorMessage ) ||
+                         !StringUtils.isEmpty( checkoutErrorException ) ||
+                         checkOutScmResult == null )
                     {
                         ContinuumBuild build = makeBuildResult( scmResult, startTime, forced );
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadrsion, actual.getVersion() );
-
-        assertEquals( "project.commandLineArguments", commandLineArguments, actual.getCommandLineArguments() );
-
-        assertEquals( "project.executorId", builderId, actual.getExecutorId() );
-
-        assertEquals( "project.workingDirectory", workingDirectory, actual.getWorkingDirectory() );
-    }    
 }

Modified: maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProject.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProject.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProject.java (original)
+++ maven/continuum/trunk/continuum-web/src/main/java/org/apache/maven/continuum/web/action/AddMavenOneProject.java Sun Jul 17 15:52:59 2005
@@ -1,7 +1,20 @@
+paataHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java Sun Jul 17 15:52:59 2005
@@ -72,25 +72,36 @@
         }
 
         // ----------------------------------------------------------------------
-        // groupId
+        // Artifact and group id
         // ----------------------------------------------------------------------
 
-        String groupId = getValue( mavenProject, "groupId", null );
+        String groupId;
 
-        if ( groupId  != null )
+        String artifactId;
+
ckage org.apache.maven.continuum.web.action;
+
 /*
- * Copyright (c) 2005 Your Corporation. All Rights Reserved.
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
  */
-package org.apache.maven.continuum.web.action;
 
 import org.apache.maven.continuum.Continuum;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuildingResult;
@@ -13,7 +26,7 @@
 
 /**
  * @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
- * @version+        String id = getValue( mavenProject, "id", null );
+
+        if ( !StringUtils.isEmpty( id ) )
         {
-            throw new MavenOneMetadataHelperException( "Missing 'groupId' element in the POM." );
+            groupId = id;
+
+            artifactId = id;
         }
+        else
+        {
+            groupId = getValue( mavenProject, "groupId", project.getGroupId() );
 
-        // ----------------------------------------------------------------------
-        // artifactId
-        // ----------------------------------------------------------------------
+            if ( StringUtils.isEmpty( groupId ) )
+            {
+                throw new MavenOneMetadataHelperException( "Missing 'groupId' element in the POM." );
+            }
 
-        String artifactId = getValue( mavenProject, "artifactId", null );
+            artifactId = getValue( mavenProject, "artifactId", project.getArtifactId() );
 
-        if ( groupId  != null )
-        {
-            throw new MavenOneMetadataHelpe $Id:$
+ * @version $Id$
  */
 public class AddMavenOneProject
     extends AbstractEntityAction

Modified: maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java (original)
+++ maven/continuum/trunk/continuum-xmlrpc/src/main/java/org/apache/maven/continuum/xmlrpc/DefaultContinuumXmlRpc.java Sun Jul 17 15:52:59 2005
@@ -503,6 +503,8 @@
             excludedProperties.add( "developers" );
 
             excludedProperties.add( "notifiers" );
+
+            excludedProperties.add( "checkOutScmResult" );
         }
 
         ContinuumProject project = (ContinuumProject) rException( "Missing 'artifactId' element in the POM." );
+            if ( StringUtils.isEmpty( artifactId ) )
+            {
+                throw new MavenOneMetadataHelperException( "Missing 'artifactId' element in the POM." );
+            }
         }
 
         // ----------------------------------------------------------------------
@@ -99,7 +110,8 @@
 
         String version = getValue( mavenProject, "currentVersion", project.getVersion() );
 
-        if ( StringUtils.isEmpty( version ) )
+        if ( StringUtils.isEmpty( project.getVersion() ) &&
+             StringUtils.isEmpty( version ) )
         {
             throw new MavenOneMetadataHelperException( "Missing 'version' element in the POM." );
         }
@@ -110,7 +122,8 @@
 
         String name = getValue( mavenProject, "name", project.getName() );
 
-        if ( StringUtils.isEmpty( name ) )
+        if ( StringUtils.isEmpty( project.getName() ) &&
+             StringUtils.isEmpty( name ) )
         {
             throw new MavenOneMobject;



etadataHelperException( "Missing 'name' element in POM." );
         }
@@ -142,7 +155,7 @@
 
             if ( StringUtils.isEmpty( scmConnection ) )
             {
-                throw new MavenOneMetadataHelperException( "Missing both anonymous and developer scm connection urls." );
+                throw new MavenOneMetadataHelperException( "Missing both anonymous and developer SCM connection URLs." );
             }
         }
 

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java Sun Jul 17 15:52:59 2005
@@ -106,7 +106,7 @@
         // GroupId
         // ----------------------------------------------------------------------
 
-        if ( mavenProject.getGroupId() != null )
+        if ( StringUtils.isEmpty( mavenProject.getGroupId() ) )
         {
            continuumProject.setGroupId( mavenProject.getGroupId() );
         }
@@ -115,7 +115,7 @@
         // artifactId
         // ----------------------------------------------------------------------
 
-        if ( mavenProject.getArtifactId() != null )
+        if ( StringUtils.isEmpty( mavenProject.getArtifactId() ) )
         {
            continuumProject.setArtifactId( mavenProject.getArtifactId() );
         }
@@ -124,7 +124,7 @@
         // Project Url
         // ----------------------------------------------------------------------
 
-        if ( mavenProject.getUrl() != null )
+        if ( StringUtils.isEmpty( mavenProject.getUrl() ) )
         {
            continuumProject.setUrl( mavenProject.getUrl() );
         }

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilder.java Sun Jul 17 15:52:59 2005
@@ -65,18 +65,18 @@
             return result;
         }
 
-        MavenOneProject project = new MavenOneProject();
-
         try
         {
+            MavenOneProject project = new MavenOneProject();
+
             metadataHelper.mapMetadata( pomFile, project );
+
+            result.addProject( project, MavenOneBuildExecutor.ID );
         }
         catch ( MavenOneMetadataHelperException e )
         {
             result.addWarning( e.getMessage() );
         }
-
-        result.addProject( project, MavenOneBuildExecutor.ID );
 
         return result;
     }

Added: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java?rev=219418&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java (added)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java Sun Jul 17 15:52:59 2005
@@ -0,0 +1,554 @@
+package org.apache.maven.continuum.store;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.Iterator;
+import java.util.List;
+
+import javax.jdo.Extent;
+import javax.jdo.JDOObjectNotFoundException;
+import javax.jdo.JDOUserException;
+import javax.jdo.PersistenceManager;
+import javax.jdo.PersistenceManagerFactory;
+import javax.jdo.Query;
+import javax.jdo.Transaction;
+
+import org.apache.maven.continuum.project.ContinuumBuild;
+import org.apache.maven.continuum.project.ContinuumProject;
+import org.apache.maven.continuum.project.ContinuumProjectState;
+import org.apache.maven.continuum.scm.ScmResult;
+
+import org.codehaus.plexus.jdo.JdoFactory;
+import org.codehaus.plexus.logging.AbstractLogEnabled;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
+import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class JdoContinuumStore
+    extends AbstractLogEnabled
+    implements ContinuumStore, Initializable
+{
+    /**
+     * @plexus.requirement
+     */
+    private JdoFactory jdoFactory;
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private PersistenceManagerFactory pmf;
+
+    // ----------------------------------------------------------------------
+    // Component Lifecycle
+    // ----------------------------------------------------------------------
+
+    public void initialize()
+        throws InitializationException
+    {
+        pmf = jdoFactory.getPersistenceManagerFactory();
+    }
+
+    // ----------------------------------------------------------------------
+    // ContinuumStore Implementation
+    // ----------------------------------------------------------------------
+
+    public String addProject( ContinuumProject project )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Object object = makePersistent( pm, project );
+
+            object = pm.detachCopy( object );
+
+            project = (ContinuumProject) object;
+
+            commit( tx );
+
+            return project.getId();
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public void removeProject( String projectId )
+        throws ContinuumStoreException
+    {
+        deletePersistentById( ContinuumProject.class, projectId );
+    }
+
+    public void updateProject( ContinuumProject project )
+        throws ContinuumStoreException
+    {
+        updateObject( project );
+    }
+
+    public Collection getAllProjects()
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumProject.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.setOrdering( "name ascending" );
+
+            Collection result = (Collection) query.execute();
+
+            result = pm.detachCopyAll( result );
+
+            for ( Iterator it = result.iterator(); it.hasNext(); )
+            {
+                setProjectState( (ContinuumProject) it.next() );
+            }
+
+            commit( tx );
+
+            return result;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ContinuumProject getProjectByName( String name )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumProject.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "String name" );
+
+            query.setFilter( "this.name = name" );
+
+            Collection result = ( (Collection) query.execute( name ) );
+
+            commit( tx );
+
+            if ( result.size() == 0 )
+            {
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            return (ContinuumProject) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ContinuumProject getProjectByScmUrl( String scmUrl )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumProject.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.declareParameters( "String scmUrl" );
+
+            query.setFilter( "this.scmUrl = scmUrl" );
+
+            Collection result = ( (Collection) query.execute( scmUrl ) );
+
+            commit( tx );
+
+            if ( result.size() == 0 )
+            {
+                return null;
+            }
+
+            Object object = pm.detachCopy( result.iterator().next() );
+
+            return (ContinuumProject) object;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ContinuumProject getProject( String projectId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            ContinuumProject project = getContinuumProject( pm, projectId );
+
+            project = (ContinuumProject) pm.detachCopy( project );
+
+            commit( tx );
+
+            return project;
+        }
+        catch( JDOObjectNotFoundException e )
+        {
+            throw new ContinuumObjectNotFoundException( ContinuumProject.class.getName(), projectId );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ScmResult getScmResultForProject( String projectId )
+        throws ContinuumStoreException
+    {
+        // TODO:
+        throw new UnsupportedOperationException();
+    }
+
+    public String addBuild( String projectId, ContinuumBuild build )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            ContinuumProject project = getContinuumProject( pm, projectId );
+
+            build.setProject( project );
+
+            build = (ContinuumBuild) makePersistent( pm, build );
+
+            project.setLatestBuildId( build.getId() );
+
+            project.setBuildNumber( project.getBuildNumber() + 1 );
+
+            project.getBuilds().add( build );
+
+            commit( tx );
+
+            return build.getId();
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public void updateBuild( ContinuumBuild build )
+        throws ContinuumStoreException
+    {
+        updateObject( build );
+    }
+
+    public ContinuumBuild getBuild( String buildId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            ContinuumBuild build = getContinuumBuild( pm, buildId );
+
+            build = (ContinuumBuild) pm.detachCopy( build );
+
+            commit( tx );
+
+            return build;
+        }
+        catch ( JDOObjectNotFoundException e )
+        {
+            throw new ContinuumObjectNotFoundException( ContinuumBuild.class.getName(), buildId );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public ContinuumBuild getLatestBuildForProject( String projectId )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            ContinuumProject project = getContinuumProject( pm, projectId );
+
+            String buildId = project.getLatestBuildId();
+
+            if ( buildId == null )
+            {
+                return null;
+            }
+
+            Object id = pm.newObjectIdInstance( ContinuumBuild.class, buildId );
+
+            Object object = pm.getObjectById( id );
+
+            ContinuumBuild build = (ContinuumBuild) pm.detachCopy( object );
+
+            commit( tx );
+
+            return build;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public Collection getBuildsForProject( String projectId, int start, int end )
+        throws ContinuumStoreException
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Extent extent = pm.getExtent( ContinuumBuild.class, true );
+
+            Query query = pm.newQuery( extent );
+
+            query.setFilter( "this.project.id == id" );
+
+            query.declareParameters( "String id" );
+
+            query.setOrdering( "startTime descending" );
+
+            Collection builds = (Collection) query.execute( projectId );
+
+            builds = pm.detachCopyAll( builds );
+
+            commit( tx );
+
+            return builds;
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    public List getChangedFilesForBuild( String buildId )
+        throws ContinuumStoreException
+    {
+        // TODO:
+        throw new UnsupportedOperationException();
+    }
+
+    public void removeNotifier( Object notifier )
+        throws ContinuumStoreException
+    {
+        // TODO:
+        throw new UnsupportedOperationException();
+    }
+
+    public void storeNotifier( Object notifier )
+        throws ContinuumStoreException
+    {
+        // TODO:
+        throw new UnsupportedOperationException();
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private ContinuumProject setProjectState( ContinuumProject project )
+        throws ContinuumStoreException
+    {
+        ContinuumBuild build = getLatestBuildForProject( project.getId() );
+
+        if ( build == null )
+        {
+            project.setState( ContinuumProjectState.NEW );
+        }
+        else
+        {
+            project.setState( build.getState() );
+        }
+
+        return project;
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private ContinuumProject getContinuumProject( PersistenceManager pm, String projectId )
+    {
+        Object id = pm.newObjectIdInstance( ContinuumProject.class, projectId );
+
+        ContinuumProject project = (ContinuumProject) pm.getObjectById( id );
+
+        return project;
+    }
+
+    private ContinuumBuild getContinuumBuild( PersistenceManager pm, String buildId )
+    {
+        Object id = pm.newObjectIdInstance( ContinuumBuild.class, buildId );
+
+        ContinuumBuild build = (ContinuumBuild) pm.getObjectById( id );
+
+        return build;
+    }
+
+    private Object makePersistent( PersistenceManager pm, Object object )
+    {
+        pm.makePersistent( object );
+
+        Object id = pm.getObjectId( object );
+
+        return pm.getObjectById( id );
+    }
+
+    private void deletePersistentById( Class clazz, Object identifier )
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            Object id = pm.newObjectIdInstance( clazz, identifier );
+
+            Object object = pm.getObjectById( id );
+
+            pm.deletePersistent( object );
+
+            commit( tx );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    private void updateObject( Object object )
+    {
+        PersistenceManager pm = pmf.getPersistenceManager();
+
+        Transaction tx = pm.currentTransaction();
+
+        try
+        {
+            tx.begin();
+
+            pm.attachCopy( object, true );
+
+            commit( tx );
+        }
+        finally
+        {
+            rollback( tx );
+        }
+    }
+
+    // ----------------------------------------------------------------------
+    // Transaction Management
+    // ----------------------------------------------------------------------
+
+    private void commit( Transaction tx )
+    {
+        tx.commit();
+    }
+
+    private void rollback( Transaction tx )
+    {
+        PersistenceManager pm = tx.getPersistenceManager();
+
+        try
+        {
+            if ( tx.isActive() )
+            {
+                tx.rollback();
+            }
+        }
+        finally
+        {
+            closePersistenceManager( pm );
+        }
+    }
+
+    private void closePersistenceManager( PersistenceManager pm )
+    {
+        try
+        {
+            pm.close();
+        }
+        catch ( JDOUserException e )
+        {
+            getLogger().warn( "Error while closing the persistence manager.", e );
+        }
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/JdoContinuumStore.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java (original)
+++ maven/continuum/trunk/continuum-core/src/main/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStore.java Sun Jul 17 15:52:59 2005
@@ -16,24 +16,26 @@
  * limitations under the License.
  */
 
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import javax.jdo.JDOHelper;
+import javax.jdo.PersistenceManager;
+
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumJPoxStore;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
 import org.apache.maven.continuum.scm.ScmFile;
 import org.apache.maven.continuum.scm.ScmResult;
+
 import org.codehaus.plexus.jdo.JdoFactory;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.util.StringUtils;
 
-import javax.jdo.JDOHelper;
-import javax.jdo.PersistenceManager;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
@@ -384,7 +386,6 @@
             store.commit();
 
             return b;
-
         }
         catch ( Exception e )
         {

Modified: maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/continuum/trunk/continuum-core/src/main/resources/META-INF/plexus/components.xml Sun Jul 17 15:52:59 2005
@@ -117,6 +117,7 @@
 
     <component>
       <role>org.apache.maven.continuum.store.ContinuumStore</role>
+      <role-hint>modello</role-hint>
       <implementation>org.apache.maven.continuum.store.ModelloJPoxContinuumStore</implementation>
       <requirements>
         <requirement>
@@ -125,6 +126,17 @@
       </requirements>
     </component>
 
+    <component>
+      <role>org.apache.maven.continuum.store.ContinuumStore</role>
+      <role-hint>jdo</role-hint>
+      <implementation>org.apache.maven.continuum.store.JdoContinuumStore</implementation>
+      <requirements>
+        <requirement>
+          <role>org.codehaus.plexus.jdo.JdoFactory</role>
+        </requirement>
+      </requirements>
+    </component>
+
     <!-- Triggers -->
 
     <component>
@@ -135,9 +147,6 @@
         <requirement>
           <role>org.apache.maven.continuum.Continuum</role>
         </requirement>
-        <requirement>
-          <role>org.apache.maven.continuum.store.tx.StoreTransactionManager</role>
-        </requirement>
       </requirements>
       <configuration>
         <interval>60000</interval>
@@ -623,6 +632,5 @@
         </requirement>
       </requirements>
     </component>
-
   </components>
 </component-set>

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AbstractContinuumTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AbstractContinuumTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AbstractContinuumTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/AbstractContinuumTest.java Sun Jul 17 15:52:59 2005
@@ -27,6 +27,7 @@
 import org.apache.maven.continuum.project.ContinuumNotifier;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ShellProject;
+import org.apache.maven.continuum.store.ContinuumStore;
 
 import org.codehaus.plexus.PlexusTestCase;
 
@@ -37,6 +38,16 @@
 public abstract class AbstractContinuumTest
     extends PlexusTestCase
 {
+    // ----------------------------------------------------------------------
+    // Store
+    // ----------------------------------------------------------------------
+
+    protected ContinuumStore getStore()
+        throws Exception
+    {
+        return (ContinuumStore) lookup( ContinuumStore.ROLE, "jdo" );
+    }
+
     // ----------------------------------------------------------------------
     // Build Executor
     // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/DefaultContinuumTest.java Sun Jul 17 15:52:59 2005
@@ -56,8 +56,6 @@
     {
         Continuum continuum = (Continuum) lookup( Continuum.ROLE );
 
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         // ----------------------------------------------------------------------
         // Test projects with duplicate names
         // ----------------------------------------------------------------------

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/buildqueue/BuildQueueTest.java Sun Jul 17 15:52:59 2005
@@ -18,6 +18,7 @@
 
 import org.apache.maven.continuum.store.ContinuumStore;
 import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest;
+import org.apache.maven.continuum.AbstractContinuumTest;
 
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.taskqueue.Task;
@@ -28,7 +29,7 @@
  * @version $Id$
  */
 public class BuildQueueTest
-    extends PlexusTestCase
+    extends AbstractContinuumTest
 {
     private TaskQueue buildQueue;
 

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/ContinuumCoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/ContinuumCoreTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/ContinuumCoreTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/core/ContinuumCoreTest.java Sun Jul 17 15:52:59 2005
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import org.apache.maven.continuum.store.ContinuumStore;
+
 import org.codehaus.plexus.PlexusTestCase;
 
 /**
@@ -39,7 +41,9 @@
 //    }
 
     public void testRemoveMeWhenTheOtherTestsAreEnabledAgain()
+        throws Exception
     {
+        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
     }
 
 //    public void testUpdateProject()

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java Sun Jul 17 15:52:59 2005
@@ -65,6 +65,10 @@
 
         project.setName( "Maven" );
 
+        project.setGroupId( "org.apache.maven" );
+
+        project.setArtifactId( "maven");
+
         project.setScmUrl( "scm:svn:http://svn.apache.org/repos/asf:maven/maven-1/core/trunk/" );
 
         ContinuumNotifier notifier = new ContinuumNotifier();

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/notification/ContinuumNotificationDispatcherTest.java Sun Jul 17 15:52:59 2005
@@ -20,15 +20,14 @@
 import org.apache.maven.continuum.store.ModelloJPoxContinuumStoreTest;
 import org.apache.maven.continuum.project.ContinuumBuild;
 import org.apache.maven.continuum.project.ContinuumProjectState;
-
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.continuum.AbstractContinuumTest;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public class ContinuumNotificationDispatcherTest
-    extends PlexusTestCase
+    extends AbstractContinuumTest
 {
     public void testNotificationDispatcher()
         throws Exception
@@ -36,7 +35,7 @@
         ContinuumNotificationDispatcher notificationDispatcher =
             (ContinuumNotificationDispatcher) lookup( ContinuumNotificationDispatcher.ROLE );
 
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
+        ContinuumStore store = getStore();
 
         String projectId = ModelloJPoxContinuumStoreTest.addMavenTwoProject( store,
                                                                              "Notification Dispatcher Test Project",

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/ContinuumJPoxStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/ContinuumJPoxStoreTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/ContinuumJPoxStoreTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/ContinuumJPoxStoreTest.java Sun Jul 17 15:52:59 2005
@@ -24,7 +24,6 @@
 import javax.jdo.JDODetachedFieldAccessException;
 import javax.jdo.PersistenceManager;
 import javax.jdo.PersistenceManagerFactory;
-import javax.jdo.JDOHelper;
 
 import org.apache.maven.continuum.scm.ScmResult;
 import org.apache.maven.continuum.scm.ScmFile;

Modified: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java?rev=219418&r1=219417&r2=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/project/builder/maven/MavenOneContinuumProjectBuilderTest.java Sun Jul 17 15:52:59 2005
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import java.util.Iterator;
+
 import org.apache.maven.continuum.project.ContinuumNotifier;
 import org.apache.maven.continuum.project.MavenOneProject;
 import org.apache.maven.continuum.project.builder.ContinuumProjectBuilder;
@@ -37,9 +39,20 @@
 
         ContinuumProjectBuildingResult result = projectBuilder.buildProjectsFromMetadata( getTestFile( "src/test/resources/projects/maven-1.pom.xml" ).toURL() );
 
+        assertNotNull( result.getWarnings() );
+
         assertNotNull( result.getProjects() );
 
-        assertEquals( 1, result.getProjects().size() );
+        for ( Iterator it = result.getWarnings().iterator(); it.hasNext(); )
+        {
+            String s = (String) it.next();
+
+            System.err.println( s );
+        }
+
+        assertEquals( "result.warning.length", 0, result.getWarnings().size() );
+
+        assertEquals( "result.projects.length", 1, result.getProjects().size() );
 
         MavenOneProject project = (MavenOneProject) result.getProjects().get( 0 );
 

Copied: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java (from r219317, maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java)
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java?p2=maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java&p1=maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java&r1=219317&r2=219418&rev=219418&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/ModelloJPoxContinuumStoreTest.java (original)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/AbstractContinuumStoreTest.java Sun Jul 17 15:52:59 2005
@@ -24,13 +24,13 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Properties;
+import java.util.Collections;
 
 import org.apache.maven.continuum.AbstractContinuumTest;
 import org.apache.maven.continuum.utils.ContinuumUtils;
 import org.apache.maven.continuum.execution.ContinuumBuildExecutionResult;
 import org.apache.maven.continuum.execution.maven.m2.MavenTwoBuildExecutor;
 import org.apache.maven.continuum.project.ContinuumBuild;
-import org.apache.maven.continuum.project.ContinuumJPoxStore;
 import org.apache.maven.continuum.project.ContinuumNotifier;
 import org.apache.maven.continuum.project.ContinuumProject;
 import org.apache.maven.continuum.project.ContinuumProjectState;
@@ -40,135 +40,50 @@
 
 import org.codehaus.plexus.jdo.JdoFactory;
 
-import javax.jdo.PersistenceManager;
-import javax.jdo.JDOHelper;
-
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
-public class ModelloJPoxContinuumStoreTest
+public class AbstractContinuumStoreTest
     extends AbstractContinuumTest
 {
     private ContinuumStore store;
 
-    private JdoFactory jdoFactory;
+    private String roleHint;
 
-    public void setUp()
-        throws Exception
-    {
-        super.setUp();
+    private Class implementationClass;
 
-        jdoFactory = (JdoFactory) lookup( JdoFactory.ROLE );
+    public AbstractContinuumStoreTest( String roleHint, Class implementationClass )
+    {
+        this.roleHint = roleHint;
 
-        store = (ContinuumStore) lookup( ContinuumStore.ROLE );
+        this.implementationClass = implementationClass;
     }
 
-    public void testTransactionHandling()
+    public void setUp()
         throws Exception
     {
-        ContinuumJPoxStore store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        assertNull( store.getThreadState() );
-
-        store.begin();
-
-        assertNotNull( store.getThreadState() );
-
-        store.commit();
-
-        assertNull( store.getThreadState() );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
-
-        store.begin();
-
-        assertEquals( 0, store.getThreadState().getDepth() );
-
-        store.begin();
-
-        assertEquals( 1, store.getThreadState().getDepth() );
-
-        store.commit();
-
-        assertEquals( 0, store.getThreadState().getDepth() );
-
-        store.commit();
-
-        assertNull( store.getThreadState() );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
-
-        store.begin();
-
-        assertEquals( 0, store.getThreadState().getDepth() );
-
-        store.begin();
-
-        assertEquals( 1, store.getThreadState().getDepth() );
-
-        store.commit();
-
-        assertEquals( 0, store.getThreadState().getDepth() );
-
-        store.rollback();
-
-        assertNull( store.getThreadState() );
-
-        // ----------------------------------------------------------------------
-        //
-        // ----------------------------------------------------------------------
-
-        store = new ContinuumJPoxStore( jdoFactory.getPersistenceManagerFactory() );
-
-        store.begin();
-
-        assertEquals( 0, store.getThreadState().getDepth() );
-
-        store.begin();
-
-        assertEquals( 1, store.getThreadState().getDepth() );
-
-        store.begin();
-
-        assertEquals( 2, store.getThreadState().getDepth() );
-
-        store.rollback();
-
-        assertNull( store.getThreadState() );
+        super.setUp();
 
-        store.begin();
+        store = (ContinuumStore) lookup( ContinuumStore.ROLE, roleHint );
 
-        assertEquals( 0, store.getThreadState().getDepth() );
+        assertEquals( implementationClass, store.getClass() );
 
-        store.commit();
+        for ( Iterator it = store.getAllProjects().iterator(); it.hasNext(); )
+        {
+            ContinuumProject project = (ContinuumProject) it.next();
 
-        assertNull( store.getThreadState() );
+            store.removeProject( project.getId() );
+        }
     }
 
     // ----------------------------------------------------------------------
     // Project
     // ----------------------------------------------------------------------
 
-    public void testStoreProject()
+    public void testAddProject()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        assertEquals( ModelloJPoxContinuumStore.class, store.getClass() );
-
         Properties configuration = new Properties();
 
         configuration.setProperty( "foo", "bar" );
@@ -192,19 +107,21 @@
                                                              "/tmp" ), actual );
     }
 
-
     public void testGetNonExistingProject()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         try
         {
             store.getProject( "foo" );
 
-            fail( "Expected ContinuumStoreException.") ;
+            fail( "Expected ContinuumObjectNotFoundException.") ;
         }
-        catch( ContinuumStoreException ex )
+        catch( ContinuumObjectNotFoundException ex )
+        {
+            // expected
+        }
+        // TODO: Remove me when the generated stuff throws a better exception when the object is missing
+        catch ( ContinuumStoreException ex )
         {
             // expected
         }
@@ -213,8 +130,6 @@
     public void testProjectCRUD()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         String name = "Test Project 2";
         String scmUrl = "scm:local:jalla";
         String nagEmailAddress = "foo@bar.com";
@@ -268,6 +183,8 @@
         project.setName( name2 );
         project.setScmUrl( scmUrl2 );
 
+        assertNotNull( project.getNotifiers() );
+        assertEquals( 1, project.getNotifiers().size() );
         ContinuumNotifier notifier = ((ContinuumNotifier) project.getNotifiers().get( 0 ));
         notifier.setType( "kewk" );
         notifier.getConfiguration().put( "address", emailAddress2 );
@@ -312,6 +229,11 @@
 
             fail( "Expected ContinuumStoreException." );
         }
+        catch ( ContinuumObjectNotFoundException ex )
+        {
+            // expected
+        }
+        // TODO: Remove me when the generated stuff throws a better exception when the object is missing
         catch ( ContinuumStoreException ex )
         {
             // expected
@@ -321,9 +243,7 @@
     public void testGetAllProjects()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
-        String name1 = "Test Project 1";
+        String name1 = "Test All Projects 1";
         String scmUrl1 = "scm:local:src/test/repo/foo";
         String nagEmailAddress1 = "foo@bar.com";
         String version1 = "1.0";
@@ -331,14 +251,14 @@
         String workingDirectory1 = "/tmp";
 
         String id1 = addMavenTwoProject( store,
-                                 name1,
-                                 scmUrl1,
-                                 nagEmailAddress1,
-                                 version1,
-                                 commandLineArguments1,
-                                 workingDirectory1 );
+                                         name1,
+                                         scmUrl1,
+                                         nagEmailAddress1,
+                                         version1,
+                                         commandLineArguments1,
+                                         workingDirectory1 );
 
-        String name2 = "Test Project 2";
+        String name2 = "Test All Projects 2";
         String scmUrl2 = "scm:local:src/test/repo/bar";
         String nagEmailAddress2 = "foo@bar.com";
         String version2 = "1.0";
@@ -346,22 +266,26 @@
         String workingDirectory2 = "/tmp";
 
         String id2 = addMavenTwoProject( store,
-                                 name2,
-                                 scmUrl2,
-                                 nagEmailAddress2,
-                                 version2,
-                                 commandLineArguments2,
-                                 workingDirectory2 );
+                                         name2,
+                                         scmUrl2,
+                                         nagEmailAddress2,
+                                         version2,
+                                         commandLineArguments2,
+                                         workingDirectory2 );
 
         Map projects = new HashMap();
 
-        for ( Iterator it = store.getAllProjects().iterator(); it.hasNext(); )
+        Collection projectsCollection = store.getAllProjects();
+
+        assertEquals( 2, projectsCollection.size() );
+
+        for ( Iterator it = projectsCollection.iterator(); it.hasNext(); )
         {
             ContinuumProject project = (ContinuumProject) it.next();
 
-            assertNotNull( "While getting all projects: project.id == null", project.getId() );
+            assertNotNull( "While getting all projects: project.id", project.getId() );
 
-            assertNotNull( "While getting all projects: project.name == null", project.getName() );
+            assertNotNull( "While getting all projects: project.name", project.getName() );
 
             projects.put( project.getName(), project );
         }
@@ -394,8 +318,6 @@
     public void testRemoveProject()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         String projectId = addMavenTwoProject( "Remove Test Project", "scm:remove-project" );
 
         String buildId = createBuild( store, projectId, false );
@@ -429,6 +351,25 @@
                                                   exitCode );
     }
 
+    public void testGetLatestBuildForProject()
+        throws Exception
+    {
+        String projectId = addMavenTwoProject( store,
+                                               makeStubMavenTwoProject( "Last project", "scm:foo" ) );
+
+        assertNull( store.getLatestBuildForProject( projectId ) );
+
+        List expectedBuilds = new ArrayList();
+
+        for ( int i = 0; i < 10; i++ )
+        {
+            expectedBuilds.add( createBuild( store, projectId, false ) );
+        }
+
+        assertEquals( expectedBuilds.get( expectedBuilds.size() - 1 ),
+                      store.getLatestBuildForProject( projectId ).getId() );
+    }
+
     // ----------------------------------------------------------------------
     // Maven Two project tests
     // ----------------------------------------------------------------------
@@ -436,8 +377,6 @@
     public void testUpdateMavenTwoProject()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         String projectId = addMavenTwoProject( "Maven Two Project", "scm:foo" );
 
         MavenTwoProject project = (MavenTwoProject) store.getProject( projectId );
@@ -497,8 +436,6 @@
     public void testBuild()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         lookup( JdoFactory.ROLE );
 
         String projectId = addMavenTwoProject( "Build Test Project", "scm:build" );
@@ -569,8 +506,6 @@
     public void testTheAssociationBetweenTheProjectAndItsBuilds()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         lookup( JdoFactory.ROLE );
 
         // ----------------------------------------------------------------------
@@ -591,7 +526,7 @@
 
         for ( int i = 0; i < 10; i++ )
         {
-            expectedBuilds.add( 0, createBuild( store, projectId, false ) );
+            expectedBuilds.add( createBuild( store, projectId, false ) );
 
             createBuild( store, projectIdFoo, false );
 
@@ -608,9 +543,11 @@
 
         assertNotNull( build );
 
-        assertEquals( build.getId(), (String) expectedBuilds.get( 0 ) );
+        assertEquals( build.getId(), (String) expectedBuilds.get( expectedBuilds.size() - 1) );
 
-        Collection actualBuilds = store.getBuildsForProject( projectId, 0, 0 );
+        List actualBuilds = new ArrayList( store.getBuildsForProject( projectId, 0, 0 ) );
+
+        Collections.reverse( actualBuilds );
 
         assertEquals( "builds.size", expectedBuilds.size(), actualBuilds.size() );
 
@@ -662,8 +599,6 @@
     public void testBuildResult()
         throws Exception
     {
-        ContinuumStore store = (ContinuumStore) lookup( ContinuumStore.ROLE );
-
         lookup( JdoFactory.ROLE );
 
         // ----------------------------------------------------------------------
@@ -676,24 +611,10 @@
 
         String buildId = createBuild( store, projectId, false );
 
-        assertIsCommitted( store );
-
         assertNotNull( buildId );
 
-        // ----------------------------------------------------------------------
-        // Check that the project's state has been updated
-        // ----------------------------------------------------------------------
-
-        assertIsCommitted( store );
-
-        // ----------------------------------------------------------------------
-        // Check the build
-        // ----------------------------------------------------------------------
-
         ContinuumBuild build = store.getBuild( buildId );
 
-        assertIsCommitted( store );
-
         assertNotNull( build );
 
         assertEquals( now / 10000, build.getStartTime() / 10000 );
@@ -708,8 +629,6 @@
         // Check the build result
         // ----------------------------------------------------------------------
 
-        assertIsCommitted( store );
-
         ScmResult scmResult = new ScmResult();
 
         setBuildResult( store,
@@ -719,16 +638,12 @@
                         scmResult,
                         null );
 
-        assertIsCommitted( store );
-
         // ----------------------------------------------------------------------
         //
         // ----------------------------------------------------------------------
 
         build = store.getBuild( buildId );
 
-        assertIsCommitted( store );
-
         assertEquals( 1, build.getExitCode() );
 
         assertEquals( "output", build.getStandardOutput() );
@@ -743,8 +658,8 @@
     private String addMavenTwoProject( String name, String scmUrl )
         throws Exception
     {
-        return addMavenTwoProject( (ContinuumStore) lookup( ContinuumStore.ROLE ),
-                           makeStubMavenTwoProject( name, scmUrl ) );
+        return addMavenTwoProject( store,
+                                   makeStubMavenTwoProject( name, scmUrl ) );
     }
 
     // ----------------------------------------------------------------------
@@ -886,13 +801,6 @@
     // Assertions
     // ----------------------------------------------------------------------
 
-    private void assertIsCommitted( ContinuumStore store )
-    {
-        ContinuumJPoxStore.ThreadState state = ( (ModelloJPoxContinuumStore) store ).getStore().getThreadState();
-
-        assertNull( state );
-    }
-
     private void assertProjectEquals( String projectId,
                                       ContinuumProject expected,
                                       ContinuumProject actual )
@@ -969,5 +877,5 @@
         assertEquals( "project.executorId", builderId, actual.getExecutorId() );
 
         assertEquals( "project.workingDirectory", workingDirectory, actual.getWorkingDirectory() );
-    }    
+    }
 }

Added: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java?rev=219418&view=auto
==============================================================================
--- maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java (added)
+++ maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java Sun Jul 17 15:52:59 2005
@@ -0,0 +1,30 @@
+package org.apache.maven.continuum.store;
+
+/*
+ * Copyright 2004-2005 The Apache Software Foundation.
+ *
+ * Licensed 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.
+ */
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class JdoContinuumStoreTest
+    extends AbstractContinuumStoreTest
+{
+    public JdoContinuumStoreTest()
+    {
+        super( "jdo", JdoContinuumStore.class );
+    }
+}

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/continuum/trunk/continuum-core/src/test/java/org/apache/maven/continuum/store/JdoContinuumStoreTest.java
------------------------------------------------------------------------------
    svn:keywords = Id