archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r574771 - in /maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src: main/java/org/apache/maven/archiva/web/action/admin/repositories/ test/java/org/apache/maven/archiva/web/action/admin/repositories/
Date Wed, 12 Sep 2007 02:58:43 GMT
Author: brett
Date: Tue Sep 11 19:58:42 2007
New Revision: 574771

URL: http://svn.apache.org/viewvc?rev=574771&view=rev
Log:
[MRM-462] test deletion

Modified:
    maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java
    maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryActionTest.java

Modified: maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java?rev=574771&r1=574770&r2=574771&view=diff
==============================================================================
--- maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java
(original)
+++ maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryAction.java
Tue Sep 11 19:58:42 2007
@@ -80,6 +80,7 @@
         return INPUT;
     }
 
+    // TODO: rename to confirmDelete
     public String confirm()
     {
         return INPUT;
@@ -101,8 +102,9 @@
 
             try
             {
-                removeRepository( repoid, archivaConfiguration.getConfiguration() );
-                result = saveConfiguration( archivaConfiguration.getConfiguration() );
+                Configuration configuration = archivaConfiguration.getConfiguration();
+                removeRepository( repoid, configuration );
+                result = saveConfiguration( configuration );
 
                 if ( result.equals( SUCCESS ) )
                 {

Modified: maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryActionTest.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryActionTest.java?rev=574771&r1=574770&r2=574771&view=diff
==============================================================================
--- maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryActionTest.java
(original)
+++ maven/archiva/branches/MRM-462/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/repositories/ConfigureRepositoryActionTest.java
Tue Sep 11 19:58:42 2007
@@ -23,11 +23,13 @@
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
+import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.codehaus.plexus.PlexusTestCase;
 import org.codehaus.plexus.redback.role.RoleManager;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
+import org.codehaus.plexus.registry.RegistryException;
 import org.easymock.MockControl;
 
 import java.io.File;
@@ -133,7 +135,7 @@
         assertEquals( Action.SUCCESS, status );
         assertTrue( location.exists() );
 
-        assertEquals( configuration.getManagedRepositories(), Collections.singletonList(
repository ) );
+        assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories()
);
 
         roleManagerControl.verify();
         archivaConfigurationControl.verify();
@@ -142,7 +144,7 @@
     public void testEditRepositoryInitialPage()
         throws Exception
     {
-        Configuration configuration = createConfigurationForEditing();
+        Configuration configuration = createConfigurationForEditing( createRepository() );
 
         archivaConfiguration.getConfiguration();
         archivaConfigurationControl.setReturnValue( configuration );
@@ -180,11 +182,10 @@
         assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
     }
 
-    private Configuration createConfigurationForEditing()
+    private Configuration createConfigurationForEditing( ManagedRepositoryConfiguration repositoryConfiguration
)
     {
         Configuration configuration = new Configuration();
-        ManagedRepositoryConfiguration r = createRepository();
-        configuration.addManagedRepository( r );
+        configuration.addManagedRepository( repositoryConfiguration );
         return configuration;
     }
 
@@ -205,7 +206,7 @@
 
         roleManagerControl.replay();
 
-        Configuration configuration = createConfigurationForEditing();
+        Configuration configuration = createConfigurationForEditing( createRepository() );
         archivaConfiguration.getConfiguration();
         archivaConfigurationControl.setReturnValue( configuration );
         archivaConfiguration.getConfiguration();
@@ -227,10 +228,99 @@
         ManagedRepositoryConfiguration newRepository = createRepository();
         newRepository.setName( "new repo name" );
         assertRepositoryEquals( repository, newRepository );
-        assertEquals( configuration.getManagedRepositories(), Collections.singletonList(
repository ) );
+        assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories()
);
 
         roleManagerControl.verify();
         archivaConfigurationControl.verify();
+    }
+
+    public void testDeleteRepositoryConfirmation()
+    {
+        ManagedRepositoryConfiguration originalRepository = createRepository();
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        assertNull( action.getMode() );
+        AdminRepositoryConfiguration repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        String status = action.confirm();
+        assertEquals( Action.INPUT, status );
+        repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories()
);
+    }
+
+    public void testDeleteRepositoryKeepContent()
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration configuration = executeDeletionTest( "delete-entry", createRepository()
);
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+
+        assertTrue( location.exists() );
+    }
+
+    public void testDeleteRepositoryDeleteContent()
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration configuration = executeDeletionTest( "delete-contents", createRepository()
);
+
+        assertTrue( configuration.getManagedRepositories().isEmpty() );
+
+        assertFalse( location.exists() );
+    }
+
+    public void testDeleteRepositoryCancelled()
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        ManagedRepositoryConfiguration originalRepository = createRepository();
+        Configuration configuration = executeDeletionTest( "unmodified", originalRepository
);
+
+        AdminRepositoryConfiguration repository = action.getRepository();
+        assertRepositoryEquals( repository, createRepository() );
+        assertEquals( Collections.singletonList( originalRepository ), configuration.getManagedRepositories()
);
+
+        assertTrue( location.exists() );
+    }
+
+    private Configuration executeDeletionTest( String mode, ManagedRepositoryConfiguration
originalRepository )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        location.mkdirs();
+
+        Configuration configuration = createConfigurationForEditing( originalRepository );
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( configuration );
+
+        archivaConfiguration.save( configuration );
+        archivaConfigurationControl.replay();
+
+        action.setRepoid( REPO_ID );
+        action.setMode( mode );
+
+        action.prepare();
+        assertEquals( REPO_ID, action.getRepoid() );
+        assertEquals( mode, action.getMode() );
+        AdminRepositoryConfiguration repository = action.getRepository();
+        assertNotNull( repository );
+        assertRepositoryEquals( repository, createRepository() );
+
+        assertTrue( location.exists() );
+        String status = action.delete();
+        assertEquals( Action.SUCCESS, status );
+        return configuration;
     }
 
     private void populateRepository( ManagedRepositoryConfiguration repository )



Mime
View raw message