Return-Path: Delivered-To: apmail-maven-continuum-commits-archive@www.apache.org Received: (qmail 89325 invoked from network); 15 May 2006 10:16:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 15 May 2006 10:16:57 -0000 Received: (qmail 21102 invoked by uid 500); 15 May 2006 10:16:56 -0000 Delivered-To: apmail-maven-continuum-commits-archive@maven.apache.org Received: (qmail 21074 invoked by uid 500); 15 May 2006 10:16:56 -0000 Mailing-List: contact continuum-commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: continuum-dev@maven.apache.org Delivered-To: mailing list continuum-commits@maven.apache.org Received: (qmail 21063 invoked by uid 99); 15 May 2006 10:16:56 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 May 2006 03:16:56 -0700 X-ASF-Spam-Status: No, hits=-9.4 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; Mon, 15 May 2006 03:16:54 -0700 Received: (qmail 89069 invoked by uid 65534); 15 May 2006 10:16:28 -0000 Message-ID: <20060515101627.88998.qmail@minotaur.apache.org> Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: continuum-commits@maven.apache.org From: evenisse@apache.org X-Mailer: svnmailer-1.0.8 X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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(), "" ); // ---------------------------------------------------------------------- @@ -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(), + "myuser@myhost.org" ); + + // ---------------------------------------------------------------------- + // 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(), + "myuser@myhost.org" ); + + // ---------------------------------------------------------------------- + // 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(), "" ); + + // ---------------------------------------------------------------------- + // 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" ) ); } }