continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r930283 - in /continuum/trunk: continuum-commons/src/main/java/org/apache/continuum/profile/ continuum-commons/src/test/java/org/apache/continuum/profile/ continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/
Date Fri, 02 Apr 2010 14:41:31 GMT
Author: jzurbano
Date: Fri Apr  2 14:41:30 2010
New Revision: 930283

URL: http://svn.apache.org/viewvc?rev=930283&view=rev
Log:
[CONTINUUM-2395] - Build Environment accepts duplicate name during edit
Submitted by: Garry Baal
* call alreadyExistsProfileName in updateProfile()
* updated unit test
* added Selenium test when editing build environment in parallel builds

additional changes made:
* also compare ids in alreadyExistsProfileName()       
* added Selenium test when editing build environment in distributed builds


Modified:
    continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
    continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java

Modified: continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java?rev=930283&r1=930282&r2=930283&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
(original)
+++ continuum/trunk/continuum-commons/src/main/java/org/apache/continuum/profile/DefaultProfileService.java
Fri Apr  2 14:41:30 2010
@@ -55,14 +55,12 @@ public class DefaultProfileService
     public void updateProfile( Profile profile )
         throws ProfileException, AlreadyExistsProfileException
     {
-
         // already exists check should be done in the same transaction
         // but we assume we don't have a huge load and a lot of concurrent access ;-)
-        /*if ( alreadyExistsProfileName( profile ) )
+        if ( alreadyExistsProfileName( profile ) )
         {
             throw new AlreadyExistsProfileException( "profile with name " + profile.getName()
+ " already exists" );
         }
-        */
 
         try
         {
@@ -314,7 +312,8 @@ public class DefaultProfileService
     public boolean alreadyExistsProfileName( Profile profile )
         throws ProfileException
     {
-        return getProfileWithName( profile.getName() ) != null;
+        Profile storedProfile = getProfileWithName( profile.getName() );
+        return ( storedProfile != null && storedProfile.getId() != profile.getId()
);
     }
 
 }

Modified: continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java?rev=930283&r1=930282&r2=930283&view=diff
==============================================================================
--- continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
(original)
+++ continuum/trunk/continuum-commons/src/test/java/org/apache/continuum/profile/DefaultProfileServiceTest.java
Fri Apr  2 14:41:30 2010
@@ -216,23 +216,24 @@ public class DefaultProfileServiceTest
     public void testupdateProfileDuplicateName()
         throws Exception
     {
-        Profile profile = getProfileService().getProfile( jdk1mvn205.getId() );
+        int profileId = jdk1mvn205.getId();
+        Profile profile = getProfileService().getProfile( profileId );
         assertEquals( jdk1mvn205Name, profile.getName() );
         profile.setName( jdk2mvn206Name );
 
         try
         {
             getProfileService().updateProfile( profile );
-            //commented
-            //fail( "no AlreadyExistsProfileException with duplicate name" );
+            
+            fail( "no AlreadyExistsProfileException with duplicate name" );
         }
         catch ( AlreadyExistsProfileException e )
         {
             // we must be here
         }
-        Profile getted = getProfileService().getProfile( jdk1mvn205.getId() );
+        Profile getted = getProfileService().getProfile( profileId );
         assertNotNull( getted );
-        assertEquals( jdk2mvn206Name, getted.getName() );
+        assertEquals( jdk1mvn205Name, getted.getName() );
     }
 
     public void testsetJdkInProfile()

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java?rev=930283&r1=930282&r2=930283&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
Fri Apr  2 14:41:30 2010
@@ -99,4 +99,36 @@ public class BuildEnvironmentTest
             disableDistributedBuilds();
         }
     }
+    
+    @Test( dependsOnMethods = { "testAddBuildEnvironmentWithBuildAgentGroup" } )
+    public void testEditDuplicatedBuildEnvironmentParallelBuilds()
+    {
+        String BUILD_ENV_NAME = getProperty( "BUIL_ENV_NAME" );
+        String newName = "NEW_BUILD_ENV";
+        goToAddBuildEnvironment();
+        addBuildEnvironment( newName, new String[] {}, true );
+        goToEditBuildEnvironment( newName );
+        editBuildEnvironment( BUILD_ENV_NAME, new String[] {}, false );
+        assertTextPresent( "A Build Environment with the same name already exists" );
+    }
+    
+    @Test( dependsOnMethods = { "testEditDuplicatedBuildEnvironmentParallelBuilds" } )
+    public void testEditDuplicatedBuildEnvironmentDistributedBuilds()
+    {
+    try
+        {
+            enableDistributedBuilds();
+
+            String BUILD_ENV_NAME = getProperty( "BUIL_ENV_NAME" );
+            String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
+            String newName = "NEW_BUILD_ENV";
+            goToEditBuildEnvironment( newName );
+            editBuildEnvironmentWithBuildAgentGroup( BUILD_ENV_NAME, new String[] {}, BUILD_AGENT_GROUPNAME,
false );
+            assertTextPresent( "A Build Environment with the same name already exists" );
+        }
+        finally
+        {
+            disableDistributedBuilds();
+        }
+    }
 }



Mime
View raw message