continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r406599 - in /maven/continuum/branches/continuum-1.0.x/continuum-core/src: main/java/org/apache/maven/continuum/execution/maven/m1/ test/java/org/apache/maven/continuum/execution/maven/m1/
Date Mon, 15 May 2006 10:16:22 GMT
Author: evenisse
Date: Mon May 15 03:16:12 2006
New Revision: 406599

URL: http://svn.apache.org/viewcvs?rev=406599&view=rev
Log:
[CONTINUUM-678] Fix duplicated notifiers

Modified:
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
    maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java?rev=406599&r1=406598&r2=406599&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/main/java/org/apache/maven/continuum/execution/maven/m1/DefaultMavenOneMetadataHelper.java
Mon May 15 03:16:12 2006
@@ -242,20 +242,10 @@
 
         Xpp3Dom build = mavenProject.getChild( "build" );
 
-        List notifiers = null;
+        List notifiers = new ArrayList();
 
-        ProjectNotifier notifier = null;
-
-        if ( build == null )
-        {
-            if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty()
)
-            {
-                notifiers = new ArrayList();
-
-                notifiers.addAll( project.getNotifiers() );
-            }
-        }
-        else
+        // Add project Notifier
+        if ( build != null )
         {
             String nagEmailAddress = getValue( build, "nagEmailAddress", null );
 
@@ -265,79 +255,28 @@
 
                 props.put( ContinuumRecipientSource.ADDRESS_FIELD, nagEmailAddress );
 
-                notifier = new ProjectNotifier();
+                ProjectNotifier notifier = new ProjectNotifier();
 
                 notifier.setConfiguration( props );
 
                 notifier.setFrom( ProjectNotifier.FROM_PROJECT );
+
+                notifiers.add( notifier );
             }
         }
 
-        if ( ( notifiers != null && !notifiers.isEmpty() ) || notifier != null )
+        // Add all user notifiers
+        if ( project.getNotifiers() != null && !project.getNotifiers().isEmpty()
)
         {
-            if ( notifiers == null )
-            {
-                notifiers = new ArrayList();
-            }
-
-            if ( notifier != null )
-            {
-                boolean containsNotifier = false;
-
-                for ( Iterator i = notifiers.iterator(); i.hasNext(); )
-                {
-                    ProjectNotifier n = (ProjectNotifier) i.next();
-                    if ( n.getConfiguration() != null )
-                    {
-                        String address = (String) n.getConfiguration().get( ContinuumRecipientSource.ADDRESS_FIELD
);
-
-                        if ( address != null )
-                        {
-                            if ( address.equals( notifier.getConfiguration().get( ContinuumRecipientSource.ADDRESS_FIELD
) ) )
-                            {
-                                containsNotifier = true;
-                            }
-                        }
-                    }
-                }
-
-                if ( !containsNotifier )
-                {
-                    notifiers.add( notifier );
-                }
-            }
-
-            // Add notifier defined by user
             for ( Iterator i = project.getNotifiers().iterator(); i.hasNext(); )
             {
                 ProjectNotifier notif = (ProjectNotifier) i.next();
 
                 if ( notif.isFromUser() )
                 {
-                    ProjectNotifier userNotifier = new ProjectNotifier();
-
-                    userNotifier.setType( notif.getType() );
-
-                    userNotifier.setEnabled( notif.isEnabled() );
-
-                    userNotifier.setConfiguration( notif.getConfiguration() );
-
-                    userNotifier.setFrom( notif.getFrom() );
-
-                    userNotifier.setRecipientType( notif.getRecipientType() );
-
-                    userNotifier.setSendOnError( notif.isSendOnError() );
-
-                    userNotifier.setSendOnFailure( notif.isSendOnFailure() );
-
-                    userNotifier.setSendOnSuccess( notif.isSendOnSuccess() );
-
-                    userNotifier.setSendOnWarning( notif.isSendOnWarning() );
-
-                    notifiers.add( userNotifier );
+                    notifiers.add( notif );
                 }
             }
-
         }
 
         // ----------------------------------------------------------------------

Modified: maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java
URL: http://svn.apache.org/viewcvs/maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java?rev=406599&r1=406598&r2=406599&view=diff
==============================================================================
--- maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java
(original)
+++ maven/continuum/branches/continuum-1.0.x/continuum-core/src/test/java/org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutorTest.java
Mon May 15 03:16:12 2006
@@ -34,19 +34,24 @@
 public class MavenOneBuildExecutorTest
     extends AbstractContinuumTest
 {
-    public void testUpdatingAProjectFromScmWithAExistingProjectAndAEmptyMaven1Pom()
+    private File checkOut;
+
+    private MavenOneBuildExecutor executor;
+
+    protected void setUp()
         throws Exception
     {
+        super.setUp();
+
         BuildExecutorManager builderManager = (BuildExecutorManager) lookup( BuildExecutorManager.ROLE
);
 
-        MavenOneBuildExecutor executor = (MavenOneBuildExecutor) builderManager.getBuildExecutor(
-            MavenOneBuildExecutor.ID );
+        executor = (MavenOneBuildExecutor) builderManager.getBuildExecutor( MavenOneBuildExecutor.ID
);
 
         // ----------------------------------------------------------------------
         // Make a checkout
         // ----------------------------------------------------------------------
 
-        File checkOut = getTestFile( "target/test-checkout" );
+        checkOut = getTestFile( "target/test-checkout" );
 
         if ( !checkOut.exists() )
         {
@@ -55,6 +60,11 @@
 
         FileUtils.cleanDirectory( checkOut );
 
+    }
+
+    public void testUpdatingAProjectFromScmWithAExistingProjectAndAEmptyMaven1Pom()
+        throws Exception
+    {
         FileUtils.fileWrite( new File( checkOut, "project.xml" ).getAbsolutePath(), "<project/>"
);
 
         // ----------------------------------------------------------------------
@@ -79,6 +89,8 @@
 
         notifier.setConfiguration( props );
 
+        notifier.setFrom( ProjectNotifier.FROM_USER );
+
         List notifiers = new ArrayList();
 
         notifiers.add( notifier );
@@ -108,5 +120,221 @@
         assertEquals( "dev@maven.apache.org", actualNotifier.getConfiguration().get( "address"
) );
 
         assertEquals( "1.1-SNAPSHOT", project.getVersion() );
+    }
+
+    public void testUpdatingAProjectWithNagEMailAddress()
+        throws Exception
+    {
+        FileUtils.fileWrite( new File( checkOut, "project.xml" ).getAbsolutePath(),
+                             "<project><build><nagEmailAddress>myuser@myhost.org</nagEmailAddress></build></project>"
);
+
+        // ----------------------------------------------------------------------
+        // Make the "existing" project
+        // ----------------------------------------------------------------------
+
+        Project project = new Project();
+
+        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/"
);
+
+        project.setVersion( "1.1-SNAPSHOT" );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertNotNull( project );
+
+        assertEquals( "Maven", project.getName() );
+
+        assertEquals( 1, project.getNotifiers().size() );
+
+        ProjectNotifier actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0
);
+
+        assertEquals( "myuser@myhost.org", actualNotifier.getConfiguration().get( "address"
) );
+
+        // ----------------------------------------------------------------------
+        // Updating a new time to prevent duplicated notifiers
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertEquals( 1, project.getNotifiers().size() );
+
+        actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+
+        assertEquals( "myuser@myhost.org", actualNotifier.getConfiguration().get( "address"
) );
+    }
+
+    public void testUpdatingAProjectWithNagEMailAddressAndOneNotifier()
+        throws Exception
+    {
+        FileUtils.fileWrite( new File( checkOut, "project.xml" ).getAbsolutePath(),
+                             "<project><build><nagEmailAddress>myuser@myhost.org</nagEmailAddress></build></project>"
);
+
+        // ----------------------------------------------------------------------
+        // Make the "existing" project
+        // ----------------------------------------------------------------------
+
+        Project project = new Project();
+
+        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/"
);
+
+        ProjectNotifier notifier = new ProjectNotifier();
+
+        Properties props = new Properties();
+
+        props.put( "address", "dev@maven.apache.org" );
+
+        notifier.setConfiguration( props );
+
+        notifier.setFrom( ProjectNotifier.FROM_USER );
+
+        List notifiers = new ArrayList();
+
+        notifiers.add( notifier );
+
+        project.setNotifiers( notifiers );
+
+        project.setVersion( "1.1-SNAPSHOT" );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertNotNull( project );
+
+        assertEquals( "Maven", project.getName() );
+
+        assertEquals( 2, project.getNotifiers().size() );
+
+        ProjectNotifier actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0
);
+
+        assertEquals( "myuser@myhost.org", actualNotifier.getConfiguration().get( "address"
) );
+
+        actualNotifier = (ProjectNotifier) project.getNotifiers().get( 1 );
+
+        assertEquals( "dev@maven.apache.org", actualNotifier.getConfiguration().get( "address"
) );
+
+        // ----------------------------------------------------------------------
+        // Updating a new time to prevent duplicated notifiers
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertEquals( 2, project.getNotifiers().size() );
+
+        actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+
+        assertEquals( "myuser@myhost.org", actualNotifier.getConfiguration().get( "address"
) );
+
+        actualNotifier = (ProjectNotifier) project.getNotifiers().get( 1 );
+
+        assertEquals( "dev@maven.apache.org", actualNotifier.getConfiguration().get( "address"
) );
+    }
+
+    public void testUpdatingAProjectWithOneNotifier()
+        throws Exception
+    {
+        FileUtils.fileWrite( new File( checkOut, "project.xml" ).getAbsolutePath(), "<project/>"
);
+
+        // ----------------------------------------------------------------------
+        // Make the "existing" project
+        // ----------------------------------------------------------------------
+
+        Project project = new Project();
+
+        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/"
);
+
+        ProjectNotifier notifier = new ProjectNotifier();
+
+        Properties props = new Properties();
+
+        props.put( "address", "dev@maven.apache.org" );
+
+        notifier.setConfiguration( props );
+
+        notifier.setFrom( ProjectNotifier.FROM_USER );
+
+        List notifiers = new ArrayList();
+
+        notifiers.add( notifier );
+
+        project.setNotifiers( notifiers );
+
+        project.setVersion( "1.1-SNAPSHOT" );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertNotNull( project );
+
+        assertEquals( "Maven", project.getName() );
+
+        assertEquals( 1, project.getNotifiers().size() );
+
+        ProjectNotifier actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0
);
+
+        assertEquals( "dev@maven.apache.org", actualNotifier.getConfiguration().get( "address"
) );
+
+        // ----------------------------------------------------------------------
+        // Updating a new time to prevent duplicated notifiers
+        // ----------------------------------------------------------------------
+
+        executor.updateProjectFromCheckOut( checkOut, project, null );
+
+        // ----------------------------------------------------------------------
+        //
+        // ----------------------------------------------------------------------
+
+        assertEquals( 1, project.getNotifiers().size() );
+
+        actualNotifier = (ProjectNotifier) project.getNotifiers().get( 0 );
+
+        assertEquals( "dev@maven.apache.org", actualNotifier.getConfiguration().get( "address"
) );
     }
 }



Mime
View raw message