]> source.dussan.org Git - archiva.git/commitdiff
MRM-1507 : api to configure ProxyConnector : use it in the webapp
authorOlivier Lamy <olamy@apache.org>
Wed, 7 Sep 2011 20:35:00 +0000 (20:35 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 7 Sep 2011 20:35:00 +0000 (20:35 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1166392 13f79535-47bb-0310-9956-ffa450edef68

21 files changed:
archiva-modules/archiva-base/archiva-repository-admin/pom.xml
archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/DefaultProxyConnectorAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/src/test/java/org/apache/archiva/admin/repository/proxyconnector/ProxyConnectorAdminTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AbstractProxyConnectorFormAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/AddProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DeleteProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/DisableProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EditProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/EnableProxyConnectorActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/ProxyConnectorsActionTest.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/admin/connectors/proxy/SortProxyConnectorsActionTest.java
archiva-modules/pom.xml
pom.xml

index 2efa25bd26e333e73182f976af1a5b8b4b8483cd..541eb7f70c07eef92f9b5489bfb2aece447fee01 100644 (file)
     <dependency>
       <groupId>net.sf.beanlib</groupId>
       <artifactId>beanlib</artifactId>
+        <exclusions>
+          <exclusion>
+            <groupId>cglib</groupId>
+            <artifactId>cglib</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+          </exclusion>
+        </exclusions>
     </dependency>
     <dependency>
       <groupId>org.springframework</groupId>
index d49e807441ef184685df6d6d27d3a6e9ed575974..c83a57766a07a42530a45b86a1f5ab54c0a70a06 100644 (file)
@@ -140,6 +140,19 @@ public class DefaultProxyConnectorAdmin
         return Boolean.TRUE;
     }
 
+    public Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+        throws RepositoryAdminException
+    {
+        Configuration configuration = getArchivaConfiguration().getConfiguration();
+        ProxyConnectorConfiguration proxyConnectorConfiguration =
+            findProxyConnector( proxyConnector.getSourceRepoId(), proxyConnector.getTargetRepoId(), configuration );
+        configuration.removeProxyConnector( proxyConnectorConfiguration );
+        configuration.addProxyConnector( getProxyConnectorConfiguration( proxyConnector ) );
+        triggerAuditEvent( proxyConnector.getSourceRepoId() + "-" + proxyConnector.getTargetRepoId(), null,
+                           AuditEvent.MODIFY_PROXY_CONNECTOR, auditInformation );
+        return Boolean.TRUE;
+    }
+
     protected List<String> unescapePatterns( List<String> patterns )
     {
         List<String> rawPatterns = new ArrayList<String>();
@@ -157,8 +170,7 @@ public class DefaultProxyConnectorAdmin
     public Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
         throws RepositoryAdminException
     {
-        java.util.Map<String, List<ProxyConnector>> proxyConnectorMap =
-            new HashMap<String, java.util.List<ProxyConnector>>();
+        Map<String, List<ProxyConnector>> proxyConnectorMap = new HashMap<String, java.util.List<ProxyConnector>>();
 
         Iterator<ProxyConnector> it = getProxyConnectors().iterator();
         while ( it.hasNext() )
@@ -166,7 +178,7 @@ public class DefaultProxyConnectorAdmin
             ProxyConnector proxyConfig = it.next();
             String key = proxyConfig.getSourceRepoId();
 
-            java.util.List<ProxyConnector> connectors = proxyConnectorMap.get( key );
+            List<ProxyConnector> connectors = proxyConnectorMap.get( key );
             if ( connectors == null )
             {
                 connectors = new ArrayList<ProxyConnector>();
@@ -221,12 +233,17 @@ public class DefaultProxyConnectorAdmin
         proxyConnectorConfiguration.setSourceRepoId( proxyConnector.getSourceRepoId() );
         proxyConnectorConfiguration.setTargetRepoId( proxyConnector.getTargetRepoId() );
         return proxyConnectorConfiguration;*/
-        return new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
+
+        return proxyConnector == null
+            ? null
+            : new BeanReplicator().replicateBean( proxyConnector, ProxyConnectorConfiguration.class );
     }
 
     protected ProxyConnector getProxyConnector( ProxyConnectorConfiguration proxyConnectorConfiguration )
     {
-        return new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
+        return proxyConnectorConfiguration == null
+            ? null
+            : new BeanReplicator().replicateBean( proxyConnectorConfiguration, ProxyConnector.class );
     }
 
     protected void validateProxyConnector( ProxyConnector proxyConnector )
@@ -246,6 +263,6 @@ public class DefaultProxyConnectorAdmin
                     + " is not a RemoteRepository" );
         }
 
-        // FIXME validate NetworkProxyConfiguration too
+        // FIXME validate NetworkProxyConfiguration too when available
     }
 }
index 2eae5da1f8fe6d0528e969876da823aad73302fe..0228f9b7300576fe84d3f94c8319f0911516243c 100644 (file)
@@ -25,7 +25,7 @@ import java.util.List;
 import java.util.Map;
 
 /**
- * No update method here as id is : sourceRepoId and targetRepoId, use delete then add.
+ * <b>No update method for changing source and target here as id is : sourceRepoId and targetRepoId, use delete then add.</b>
  *
  * @author Olivier Lamy
  * @since 1.4
@@ -44,10 +44,22 @@ public interface ProxyConnectorAdmin
     Boolean deleteProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
         throws RepositoryAdminException;
 
+    /**
+     * <b>only for enabled/disable or changing bean values except target/source</b>
+     * @param proxyConnector
+     * @param auditInformation
+     * @return
+     * @throws RepositoryAdminException
+     */
+    Boolean updateProxyConnector( ProxyConnector proxyConnector, AuditInformation auditInformation )
+            throws RepositoryAdminException;
+
+
     Map<String, List<ProxyConnector>> getProxyConnectorAsMap()
         throws RepositoryAdminException;
 
     ProxyConnector findProxyConnector( String sourceId, String targetId )
         throws RepositoryAdminException;
 
+
 }
index 97b0b12d3916fe31b821493078849879dab92215..af35ff36c3bb9cbe18f3e416f555ddc1a65aead9 100644 (file)
@@ -136,4 +136,28 @@ public class ProxyConnectorAdminTest
         assertNotNull( proxyConnector );
     }
 
+        @Test
+    public void updateProxyConnector()
+        throws Exception
+    {
+        ProxyConnector proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+        assertNotNull( proxyConnector );
+        proxyConnector.setDisabled( false );
+        proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+        proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+        assertFalse( proxyConnector.isDisabled() );
+
+
+        proxyConnector.setDisabled( true );
+        proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+        proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+        assertTrue( proxyConnector.isDisabled() );
+
+        proxyConnector.setOrder( 4 );
+        proxyConnectorAdmin.updateProxyConnector( proxyConnector, getFakeAuditInformation() );
+        proxyConnector = proxyConnectorAdmin.findProxyConnector( "internal", "central" );
+        assertEquals( 4, proxyConnector.getOrder() );
+
+    }
+
 }
index 9d295cf8885e8226bb220595843fdb622cc22fb2..40455de430333372ce92cc18a786e763cfd5b194 100644 (file)
@@ -19,8 +19,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  * under the License.
  */
 
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
@@ -36,9 +37,10 @@ public class AddProxyConnectorAction
 {
     @Override
     public void prepare()
+        throws RepositoryAdminException
     {
         super.prepare();
-        connector = new ProxyConnectorConfiguration();
+        connector = new ProxyConnector();
     }
 
     @Override
@@ -55,6 +57,7 @@ public class AddProxyConnectorAction
     }
 
     public String commit()
+        throws RepositoryAdminException
     {
         /* Too complex for webwork's ${Action}-validation.xml techniques.
          * Not appropriate for use with webwork's implements Validatable, as that validates regardless of
@@ -65,7 +68,7 @@ public class AddProxyConnectorAction
         String sourceId = connector.getSourceRepoId();
         String targetId = connector.getTargetRepoId();
 
-        ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
+        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
         if ( otherConnector != null )
         {
             addActionError(
@@ -90,6 +93,6 @@ public class AddProxyConnectorAction
         connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
 
         addProxyConnector( connector );
-        return saveConfiguration();
+        return SUCCESS;
     }
 }
index 72cc99e64fa4c630a7d13017f24fb2dbb9edfff0..d0ec3885de474aaf683728991e1fb903d017a3d6 100644 (file)
@@ -19,15 +19,16 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  * under the License.
  */
 
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
 /**
- * DeleteProxyConnectorAction 
+ * DeleteProxyConnectorAction
  *
  * @version $Id$
- *
  */
 @Controller( "deleteProxyConnectorAction" )
 @Scope( "prototype" )
@@ -38,17 +39,19 @@ public class DeleteProxyConnectorAction
 
     private String target;
 
-    private ProxyConnectorConfiguration proxyConfig;
+    private ProxyConnector proxyConfig;
 
     public String confirmDelete()
+        throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
         // Not set? Then there is nothing to delete.
         if ( this.proxyConfig == null )
         {
-            addActionError( "Unable to delete proxy configuration, configuration with source [" + source
-                + "], and target [" + target + "] does not exist." );
+            addActionError(
+                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
             return ERROR;
         }
 
@@ -56,14 +59,16 @@ public class DeleteProxyConnectorAction
     }
 
     public String delete()
+        throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
         // Not set? Then there is nothing to delete.
         if ( this.proxyConfig == null )
         {
-            addActionError( "Unable to delete proxy configuration, configuration with source [" + source
-                + "], and target [" + target + "] does not exist." );
+            addActionError(
+                "Unable to delete proxy configuration, configuration with source [" + source + "], and target ["
+                    + target + "] does not exist." );
             return ERROR;
         }
 
@@ -71,14 +76,14 @@ public class DeleteProxyConnectorAction
         {
             return ERROR;
         }
-        
-        removeProxyConnector( proxyConfig );
+
+        getProxyConnectorAdmin().deleteProxyConnector( proxyConfig, getAuditInformation() );
         addActionMessage( "Successfully removed proxy connector [" + source + " , " + target + " ]" );
 
         setSource( null );
         setTarget( null );
-        
-        return saveConfiguration();
+
+        return SUCCESS;
     }
 
     public String getSource()
@@ -101,7 +106,7 @@ public class DeleteProxyConnectorAction
         this.target = id;
     }
 
-    public ProxyConnectorConfiguration getProxyConfig()
+    public ProxyConnector getProxyConfig()
     {
         return proxyConfig;
     }
index a8c349219ee0e2b0739adfe82b3388259e264547..d8c214ca555420906fb19a229e08b9c9d6b7a84f 100644 (file)
@@ -1,6 +1,7 @@
 package org.apache.maven.archiva.web.action.admin.connectors.proxy;
 
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
@@ -25,7 +26,6 @@ import org.springframework.stereotype.Controller;
 
 /**
  * DisableProxyConnectorAction
- *
  */
 @Controller( "disableProxyConnectorAction" )
 @Scope( "prototype" )
@@ -36,9 +36,10 @@ public class DisableProxyConnectorAction
 
     private String target;
 
-    private ProxyConnectorConfiguration proxyConfig;
+    private ProxyConnector proxyConfig;
 
     public String confirmDisable()
+        throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
@@ -55,6 +56,7 @@ public class DisableProxyConnectorAction
     }
 
     public String disable()
+        throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
@@ -79,7 +81,8 @@ public class DisableProxyConnectorAction
         setSource( null );
         setTarget( null );
 
-        return saveConfiguration();
+        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
+        return SUCCESS;
     }
 
     public String getSource()
index 5d884f22176b55ecfd26adf3be8d5ee23e5206b8..21f572520c980d241d98b4af30d36aa3f21d1db2 100644 (file)
@@ -19,18 +19,18 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  * under the License.
  */
 
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
 /**
- * EditProxyConnectorAction 
+ * EditProxyConnectorAction
  *
  * @version $Id$
- *
  */
 @Controller( "editProxyConnectorAction" )
-@Scope( "prototype")
+@Scope( "prototype" )
 public class EditProxyConnectorAction
     extends AbstractProxyConnectorFormAction
 {
@@ -46,24 +46,26 @@ public class EditProxyConnectorAction
 
     @Override
     public void prepare()
+        throws RepositoryAdminException
     {
         super.prepare();
 
-        connector = findProxyConnector( source, target );        
+        connector = findProxyConnector( source, target );
     }
 
     public String input()
     {
         if ( connector == null )
         {
-            addActionError( "Unable to edit non existant proxy connector with source [" + source + "] and target ["
-                + target + "]" );
+            addActionError(
+                "Unable to edit non existant proxy connector with source [" + source + "] and target [" + target
+                    + "]" );
             return ERROR;
         }
-        
-        if( connector != null )
+
+        if ( connector != null )
         {
-         // MRM-1135
+            // MRM-1135
             connector.setBlackListPatterns( escapePatterns( connector.getBlackListPatterns() ) );
             connector.setWhiteListPatterns( escapePatterns( connector.getWhiteListPatterns() ) );
         }
@@ -72,6 +74,7 @@ public class EditProxyConnectorAction
     }
 
     public String commit()
+        throws RepositoryAdminException
     {
         validateConnector();
 
@@ -83,7 +86,7 @@ public class EditProxyConnectorAction
         String sourceId = connector.getSourceRepoId();
         String targetId = connector.getTargetRepoId();
 
-        ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
+        ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
         if ( otherConnector != null )
         {
             // Remove the previous connector.
@@ -95,12 +98,8 @@ public class EditProxyConnectorAction
             return INPUT;
         }
 
-        // MRM-1135
-        connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
-        connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
-        
         addProxyConnector( connector );
-        return saveConfiguration();
+        return SUCCESS;
     }
 
     public String getSource()
index 4dcda02a59d103552421f8e82da7e98c6537345f..c06597a3f2ba4cc7fdaaeb7a836ace1fcb57fbf5 100644 (file)
@@ -1,6 +1,7 @@
 package org.apache.maven.archiva.web.action.admin.connectors.proxy;
 
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
@@ -35,9 +36,10 @@ public class EnableProxyConnectorAction
 
     private String target;
 
-    private ProxyConnectorConfiguration proxyConfig;
+    private ProxyConnector proxyConfig;
 
     public String confirmEnable()
+        throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
@@ -53,7 +55,7 @@ public class EnableProxyConnectorAction
         return INPUT;
     }
 
-    public String enable()
+    public String enable() throws RepositoryAdminException
     {
         this.proxyConfig = findProxyConnector( source, target );
 
@@ -73,12 +75,14 @@ public class EnableProxyConnectorAction
 
         proxyConfig.setDisabled( false );
 
+        getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
+
         addActionMessage( "Successfully enabled proxy connector [" + source + " , " + target + " ]" );
 
         setSource( null );
         setTarget( null );
 
-        return saveConfiguration();
+        return SUCCESS;
     }
 
     public String getSource()
index c9b70f98f3a695148863af271c717cc109f7a2e4..90c98ee633be4e3543c23d776e9941a649579e1e 100644 (file)
@@ -20,10 +20,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  */
 
 import com.opensymphony.xwork2.Preparable;
-
-import org.apache.maven.archiva.configuration.AbstractRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
+import org.apache.archiva.admin.repository.AbstractRepository;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
@@ -35,7 +34,6 @@ import java.util.Map;
  * ProxyConnectorsAction
  *
  * @version $Id$
- *
  */
 @Controller( "proxyConnectorsAction" )
 @Scope( "prototype" )
@@ -43,42 +41,43 @@ public class ProxyConnectorsAction
     extends AbstractProxyConnectorAction
     implements Preparable
 {
-    private Map<String, AbstractRepositoryConfiguration> repoMap;
+    private Map<String, AbstractRepository> repoMap;
 
     /**
      * boolean to indicate that remote repo is present. Used for Add Link
      */
-    private boolean remoteRepoExists=false;
-    
+    private boolean remoteRepoExists = false;
+
     /**
      * Map of Proxy Connectors.
      */
-    private Map<String, List<ProxyConnectorConfiguration>> proxyConnectorMap;
+    private Map<String, List<ProxyConnector>> proxyConnectorMap;
 
     public void prepare()
+        throws RepositoryAdminException
     {
-        Configuration config = archivaConfiguration.getConfiguration();
-
-        repoMap = new HashMap<String, AbstractRepositoryConfiguration>();
-        repoMap.putAll( config.getRemoteRepositoriesAsMap() );
-        repoMap.putAll( config.getManagedRepositoriesAsMap() );
+        repoMap = new HashMap<String, AbstractRepository>();
+        repoMap.putAll( getRemoteRepositoryAdmin().getRemoteRepositoriesAsMap() );
+        // FIXME olamy : are we sure we want Managed too ???
+        repoMap.putAll( getManagedRepositoryAdmin().getManagedRepositoriesAsMap() );
 
         proxyConnectorMap = createProxyConnectorMap();
-        
-        remoteRepoExists=config.getRemoteRepositories().size()>0;
+
+        remoteRepoExists = getRemoteRepositoryAdmin().getRemoteRepositories().size() > 0;
     }
 
-    public Map<String, AbstractRepositoryConfiguration> getRepoMap()
+    public Map<String, AbstractRepository> getRepoMap()
     {
         return repoMap;
     }
 
-    public Map<String, List<ProxyConnectorConfiguration>> getProxyConnectorMap()
+    public Map<String, List<ProxyConnector>> getProxyConnectorMap()
     {
         return proxyConnectorMap;
     }
 
-       public boolean getRemoteRepoExists()
+    // FIXME olamy should be is !
+    public boolean getRemoteRepoExists()
     {
         return remoteRepoExists;
     }
index 401bb58b2162b378354a90844de3fde66b9636a7..d37894cb597b6e56e0bf18258ee8fda968a5255a 100644 (file)
@@ -19,8 +19,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  * under the License.
  */
 
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
 import org.apache.commons.lang.StringUtils;
-import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
@@ -61,8 +62,9 @@ public class SortProxyConnectorsAction
     }
 
     public String sortDown()
+        throws RepositoryAdminException
     {
-        List<ProxyConnectorConfiguration> connectors = createProxyConnectorMap().get( source );
+        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
 
         int idx = findTargetConnector( connectors, target );
 
@@ -72,12 +74,17 @@ public class SortProxyConnectorsAction
             decrementConnectorOrder( connectors, idx + 1 );
         }
 
-        return saveConfiguration();
+        for ( ProxyConnector proxyConnector : connectors )
+        {
+            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
+        }
+        return SUCCESS;
     }
 
     public String sortUp()
+        throws RepositoryAdminException
     {
-        List<ProxyConnectorConfiguration> connectors = createProxyConnectorMap().get( source );
+        List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
 
         int idx = findTargetConnector( connectors, target );
 
@@ -87,10 +94,14 @@ public class SortProxyConnectorsAction
             incrementConnectorOrder( connectors, idx - 1 );
         }
 
-        return saveConfiguration();
+        for ( ProxyConnector proxyConnector : connectors )
+        {
+            getProxyConnectorAdmin().updateProxyConnector( proxyConnector, getAuditInformation() );
+        }
+        return SUCCESS;
     }
 
-    private void decrementConnectorOrder( List<ProxyConnectorConfiguration> connectors, int idx )
+    private void decrementConnectorOrder( List<ProxyConnector> connectors, int idx )
     {
         if ( !validIndex( connectors, idx ) )
         {
@@ -102,7 +113,7 @@ public class SortProxyConnectorsAction
         connectors.get( idx ).setOrder( Math.max( 1, order - 1 ) );
     }
 
-    private int findTargetConnector( List<ProxyConnectorConfiguration> connectors, String targetRepoId )
+    private int findTargetConnector( List<ProxyConnector> connectors, String targetRepoId )
     {
         int idx = ( -1 );
 
@@ -118,7 +129,7 @@ public class SortProxyConnectorsAction
         return idx;
     }
 
-    private void incrementConnectorOrder( List<ProxyConnectorConfiguration> connectors, int idx )
+    private void incrementConnectorOrder( List<ProxyConnector> connectors, int idx )
     {
         if ( !validIndex( connectors, idx ) )
         {
@@ -130,7 +141,7 @@ public class SortProxyConnectorsAction
         connectors.get( idx ).setOrder( order + 1 );
     }
 
-    private boolean validIndex( List<ProxyConnectorConfiguration> connectors, int idx )
+    private boolean validIndex( List<ProxyConnector> connectors, int idx )
     {
         return ( idx >= 0 ) && ( idx < connectors.size() );
     }
index b1e1f3d0cfc80cc1320ea32eec1216ccb303d98e..e3b99dc32714c6780e8d4dd7199b8a3620974e05 100644 (file)
@@ -20,6 +20,10 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  */
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -61,11 +65,16 @@ public class AddProxyConnectorActionTest
         super.setUp();
 
         action = (AddProxyConnectorAction) getActionProxy( "/admin/addProxyConnector.action" ).getAction();
-        //action = (AddProxyConnectorAction) lookup( Action.class.getName(), "addProxyConnectorAction" );
 
         archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
         action.setArchivaConfiguration( archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
     }
 
     public void testAddBlackListPattern()
@@ -76,7 +85,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -107,7 +116,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -135,15 +144,17 @@ public class AddProxyConnectorActionTest
     public void testAddProxyConnectorCommit()
         throws Exception
     {
-        expectConfigurationRequests( 7 );
+        expectConfigurationRequests( 9 );
         archivaConfigurationControl.replay();
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
         // forms will use an array
-        connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } );
+        //connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } );
+        // FIXME olamy check the array mode !!!
+        connector.getProperties().put( "eat-a", "gramov-a-bits" );
 
         // Create the input screen.
         assertRequestStatus( action, Action.SUCCESS, "commit" );
@@ -171,7 +182,7 @@ public class AddProxyConnectorActionTest
         archivaConfigurationControl.replay();
 
         action.prepare();
-        ProxyConnectorConfiguration configuration = action.getConnector();
+        ProxyConnector configuration = action.getConnector();
         assertNotNull( configuration );
         assertNull( configuration.getProxyId() );
         assertNull( configuration.getSourceRepoId() );
@@ -193,7 +204,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -224,7 +235,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Add some arbitrary blacklist patterns.
@@ -270,7 +281,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Add some arbitrary properties.
@@ -316,7 +327,7 @@ public class AddProxyConnectorActionTest
 
         // Prepare Test.
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         populateProxyConnector( connector );
 
         // Add some arbitrary whitelist patterns.
@@ -401,7 +412,7 @@ public class AddProxyConnectorActionTest
     }
 
     @SuppressWarnings("unchecked")
-    private void populateProxyConnector( ProxyConnectorConfiguration connector )
+    private void populateProxyConnector( ProxyConnector connector )
     {
         connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
         connector.setSourceRepoId( "corporate" );
index 04bac9f4506a8822105c7afb1c88b21c3794a176..d5efb2576977914df9bbcef33b4ed80e79105b2f 100644 (file)
@@ -20,7 +20,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  */
 
 import com.opensymphony.xwork2.Action;
-
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -28,12 +30,12 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
 import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.easymock.MockControl;
 
 /**
- * DeleteProxyConnectorActionTest 
+ * DeleteProxyConnectorActionTest
  *
  * @version $Id$
  */
@@ -50,6 +52,24 @@ public class DeleteProxyConnectorActionTest
 
     private ArchivaConfiguration archivaConfiguration;
 
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (DeleteProxyConnectorAction) getActionProxy( "/admin/deleteProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
     public void testConfirmDelete()
         throws Exception
     {
@@ -71,7 +91,7 @@ public class DeleteProxyConnectorActionTest
         expectConfigurationRequests( 4 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm delete screen, but provide 
+        // Attempt to show the confirm delete screen, but provide
         // a bad source id or target id to actually delete
 
         preRequest( action );
@@ -105,7 +125,7 @@ public class DeleteProxyConnectorActionTest
         expectConfigurationRequests( 1 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm delete screen, but don't provide 
+        // Attempt to show the confirm delete screen, but don't provide
         // the source id or target id to actually delete
 
         preRequest( action );
@@ -209,18 +229,4 @@ public class DeleteProxyConnectorActionTest
         archivaConfiguration.save( config );
     }
 
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (DeleteProxyConnectorAction) lookup( Action.class.getName(), "deleteProxyConnectorAction" );
-
-        action = (DeleteProxyConnectorAction) getActionProxy( "/admin/deleteProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
-    }
 }
index 32178a548686bd941421ff657512ca2c090e9b82..a9c4773f1fcda50658240616ec3c35453b2e8fd5 100644 (file)
@@ -18,6 +18,9 @@
 package org.apache.maven.archiva.web.action.admin.connectors.proxy;
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -42,13 +45,30 @@ public class DisableProxyConnectorActionTest
 
     private ArchivaConfiguration archivaConfiguration;
 
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (DisableProxyConnectorAction) getActionProxy( "/admin/disableProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
+    }
+
     public void testConfirmDisableBadSourceOrTarget()
         throws Exception
     {
         expectConfigurationRequests( 4 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm disable screen, but provide 
+        // Attempt to show the confirm disable screen, but provide
         // a bad source id or target id to actually delete
 
         preRequest( action );
@@ -82,7 +102,7 @@ public class DisableProxyConnectorActionTest
         expectConfigurationRequests( 1 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm disable screen, but don't provide 
+        // Attempt to show the confirm disable screen, but don't provide
         // the source id or target id to actually delete
 
         preRequest( action );
@@ -205,18 +225,4 @@ public class DisableProxyConnectorActionTest
 
         archivaConfiguration.save( config );
     }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (DisableProxyConnectorAction) lookup( Action.class.getName(), "disableProxyConnectorAction" );
-        action = (DisableProxyConnectorAction) getActionProxy( "/admin/disableProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
-    }
 }
index b8343c0e56854d0451ab3522116b139201ab1636..6562995abd9eec97528fa5fa7d353bc56094fc5b 100644 (file)
@@ -20,6 +20,10 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  */
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.ProxyConnector;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -33,15 +37,15 @@ import org.apache.maven.archiva.policies.PropagateErrorsOnUpdateDownloadPolicy;
 import org.apache.maven.archiva.policies.ReleasesPolicy;
 import org.apache.maven.archiva.policies.SnapshotsPolicy;
 import org.apache.maven.archiva.web.action.AbstractWebworkTestCase;
-import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.easymock.MockControl;
 
 import java.util.List;
 import java.util.Map;
 
 /**
- * EditProxyConnectorActionTest 
+ * EditProxyConnectorActionTest
  *
  * @version $Id$
  */
@@ -58,6 +62,51 @@ public class EditProxyConnectorActionTest
 
     private ArchivaConfiguration archivaConfiguration;
 
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        //action = (EditProxyConnectorAction) lookup( Action.class.getName(), "editProxyConnectorAction" );
+        action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        action.setArchivaConfiguration( archivaConfiguration );
+
+        /* Configuration will be requested at least 3 times. */
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( new Configuration(), 3 );
+
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        expectConfigurationRequests( requestConfigCount, 1 );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount, int saveRequestCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+
+        for ( int i = 0; i <= saveRequestCount; i++ )
+        {
+            archivaConfiguration.save( config );
+        }
+    }
+
     public void testAddBlackListPattern()
         throws Exception
     {
@@ -68,7 +117,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -101,7 +150,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -136,7 +185,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Perform Test w/no values.
@@ -159,21 +208,23 @@ public class EditProxyConnectorActionTest
         assertEquals( 1, connector.getWhiteListPatterns().size() );
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     public void testEditProxyConnectorCommit()
         throws Exception
     {
-        expectConfigurationRequests( 7 );
+        expectConfigurationRequests( 9, 2 );
         archivaConfigurationControl.replay();
 
         // Prepare Test.
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
         // forms will use an array
-        connector.getProperties().put( "eat-a", new String[] { "gramov-a-bits" } );
+        //connector.getProperties().put( "eat-a", new String[]{ "gramov-a-bits" } );
+        // FIXME check the array mode
+        connector.getProperties().put( "eat-a", "gramov-a-bits" );
 
         // Create the input screen.
         assertRequestStatus( action, Action.SUCCESS, "commit" );
@@ -203,7 +254,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         String status = action.input();
@@ -220,7 +271,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Add some arbitrary blacklist patterns.
@@ -268,7 +319,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Add some arbitrary properties.
@@ -316,7 +367,7 @@ public class EditProxyConnectorActionTest
         action.setSource( TEST_SOURCE_ID );
         action.setTarget( TEST_TARGET_ID );
         action.prepare();
-        ProxyConnectorConfiguration connector = action.getConnector();
+        ProxyConnector connector = action.getConnector();
         assertInitialProxyConnector( connector );
 
         // Add some arbitrary whitelist patterns.
@@ -365,7 +416,7 @@ public class EditProxyConnectorActionTest
         assertEquals( 1, bundle.getAuthorizationTuples().size() );
     }
 
-    private void assertInitialProxyConnector( ProxyConnectorConfiguration connector )
+    private void assertInitialProxyConnector( ProxyConnector connector )
     {
         assertNotNull( connector );
         assertNotNull( connector.getBlackListPatterns() );
@@ -376,7 +427,7 @@ public class EditProxyConnectorActionTest
         assertEquals( TEST_TARGET_ID, connector.getTargetRepoId() );
     }
 
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings( "unchecked" )
     private Configuration createInitialConfiguration()
     {
         Configuration config = new Configuration();
@@ -397,7 +448,7 @@ public class EditProxyConnectorActionTest
         ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
         connector.setSourceRepoId( TEST_SOURCE_ID );
         connector.setTargetRepoId( TEST_TARGET_ID );
-        
+
         // TODO: Set these options programatically via list of available policies.
         Map<String, String> policies = connector.getPolicies();
         policies.put( "releases", new ReleasesPolicy().getDefaultOption() );
@@ -411,39 +462,4 @@ public class EditProxyConnectorActionTest
 
         return config;
     }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (EditProxyConnectorAction) lookup( Action.class.getName(), "editProxyConnectorAction" );
-        action = (EditProxyConnectorAction) getActionProxy( "/admin/editProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
-
-        /* Configuration will be requested at least 3 times. */
-        for ( int i = 0; i < 3; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( new Configuration() );
-        }
-    }
 }
index 0f21df77ad52992a4e27985e52a069a9aed512d9..1dfa3fce4f4273dd109677356aa5c2258169f84a 100644 (file)
@@ -18,6 +18,9 @@
 package org.apache.maven.archiva.web.action.admin.connectors.proxy;
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -29,25 +32,51 @@ import org.codehaus.plexus.registry.RegistryException;
 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
 import org.easymock.MockControl;
 
-public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
+public class EnableProxyConnectorActionTest
+    extends AbstractWebworkTestCase
 {
     private static final String TEST_TARGET_ID = "central";
 
     private static final String TEST_SOURCE_ID = "corporate";
-    
+
     private EnableProxyConnectorAction action;
-    
+
     private MockControl archivaConfigurationControl;
 
     private ArchivaConfiguration archivaConfiguration;
 
-        public void testConfirmDeleteBadSourceOrTarget()
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+        action = (EnableProxyConnectorAction) getActionProxy( "/admin/enableProxyConnector.action" ).getAction();
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+        archivaConfiguration.save( config );
+    }
+
+    public void testConfirmDeleteBadSourceOrTarget()
         throws Exception
     {
         expectConfigurationRequests( 4 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm enable screen, but provide 
+        // Attempt to show the confirm enable screen, but provide
         // a bad source id or target id to actually enable
 
         preRequest( action );
@@ -81,7 +110,7 @@ public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
         expectConfigurationRequests( 1 );
         archivaConfigurationControl.replay();
 
-        // Attempt to show the confirm enable screen, but don't provide 
+        // Attempt to show the confirm enable screen, but don't provide
         // the source id or target id to actually delete
 
         preRequest( action );
@@ -132,8 +161,9 @@ public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
 
         // Test the configuration.
         assertEquals( 1, archivaConfiguration.getConfiguration().getProxyConnectors().size() );
-        ProxyConnectorConfiguration config = (ProxyConnectorConfiguration)archivaConfiguration.getConfiguration().getProxyConnectors().get(0);
-        assertFalse(config.isDisabled());
+        ProxyConnectorConfiguration config =
+            (ProxyConnectorConfiguration) archivaConfiguration.getConfiguration().getProxyConnectors().get( 0 );
+        assertFalse( config.isDisabled() );
     }
 
     public void testSecureActionBundle()
@@ -146,7 +176,7 @@ public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
         assertTrue( bundle.requiresAuthentication() );
         assertEquals( 1, bundle.getAuthorizationTuples().size() );
     }
-    
+
     public void testConfirmEnable()
         throws Exception
     {
@@ -161,7 +191,7 @@ public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
         assertEquals( Action.INPUT, status );
         assertNoErrors( action );
     }
-    
+
     private Configuration createInitialConfiguration()
     {
         Configuration config = new Configuration();
@@ -182,38 +212,10 @@ public class EnableProxyConnectorActionTest extends AbstractWebworkTestCase
         ProxyConnectorConfiguration connector = new ProxyConnectorConfiguration();
         connector.setSourceRepoId( TEST_SOURCE_ID );
         connector.setTargetRepoId( TEST_TARGET_ID );
-        connector.setDisabled(true);
+        connector.setDisabled( true );
 
         config.addProxyConnector( connector );
 
         return config;
     }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (EnableProxyConnectorAction) lookup( Action.class.getName(), "enableProxyConnectorAction" );
-
-        action = (EnableProxyConnectorAction) getActionProxy( "/admin/enableProxyConnector.action" ).getAction();
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
-    }
 }
index a73607bb5ad1eca714a926e134474d31b80307f4..91fb44b198aa40aba9af46b343707df908cc4eac 100644 (file)
@@ -21,6 +21,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
 
 import com.opensymphony.xwork2.Action;
 
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
@@ -58,19 +61,21 @@ public class ProxyConnectorsActionTest
     {
         super.setUp();
 
-        //action = (ProxyConnectorsAction) lookup( Action.class.getName(), "proxyConnectorsAction" );
-
         action = (ProxyConnectorsAction) getActionProxy("/admin/proxyConnectors.action" ).getAction();
 
         archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
         archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration( archivaConfiguration );
     }
 
     public void testSecureActionBundle()
         throws Exception
     {
-        expectConfigurationRequests( 3 );
+        expectConfigurationRequests( 4 );
         archivaConfigurationControl.replay();
 
         action.prepare();
@@ -82,7 +87,7 @@ public class ProxyConnectorsActionTest
     public void testExecute()
         throws Exception
     {
-        expectConfigurationRequests( 3 );
+        expectConfigurationRequests( 5 );
         archivaConfigurationControl.replay();
 
         action.prepare();
index bb0d3ac0c8a0362ddb4f36e654c868273fe6e0b4..6149fd19cd6e557083f49d73e6ae7c6cad5529d9 100644 (file)
@@ -20,6 +20,9 @@ package org.apache.maven.archiva.web.action.admin.connectors.proxy;
  */
 
 import com.opensymphony.xwork2.Action;
+import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin;
+import org.apache.archiva.admin.repository.remote.DefaultRemoteRepositoryAdmin;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
@@ -58,6 +61,35 @@ public class SortProxyConnectorsActionTest
 
     private ArchivaConfiguration archivaConfiguration;
 
+    @Override
+    protected void setUp()
+        throws Exception
+    {
+        super.setUp();
+
+        action = (SortProxyConnectorsAction) getActionProxy( "/admin/sortUpProxyConnector.action" ).getAction();
+
+        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
+        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
+        ( (DefaultManagedRepositoryAdmin) action.getManagedRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultRemoteRepositoryAdmin) action.getRemoteRepositoryAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+        ( (DefaultProxyConnectorAdmin) action.getProxyConnectorAdmin() ).setArchivaConfiguration(
+            archivaConfiguration );
+    }
+
+    private void expectConfigurationRequests( int requestConfigCount )
+        throws RegistryException, IndeterminateConfigurationException
+    {
+        Configuration config = createInitialConfiguration();
+
+        archivaConfiguration.getConfiguration();
+        archivaConfigurationControl.setReturnValue( config, requestConfigCount );
+
+        archivaConfiguration.save( config );
+    }
+
     public void testSecureActionBundle()
         throws Exception
     {
@@ -221,32 +253,4 @@ public class SortProxyConnectorsActionTest
 
         return config;
     }
-
-    private void expectConfigurationRequests( int requestConfigCount )
-        throws RegistryException, IndeterminateConfigurationException
-    {
-        Configuration config = createInitialConfiguration();
-
-        for ( int i = 0; i < requestConfigCount; i++ )
-        {
-            archivaConfiguration.getConfiguration();
-            archivaConfigurationControl.setReturnValue( config );
-        }
-
-        archivaConfiguration.save( config );
-    }
-
-    @Override
-    protected void setUp()
-        throws Exception
-    {
-        super.setUp();
-
-        //action = (SortProxyConnectorsAction) lookup( Action.class.getName(), "sortProxyConnectorsAction" );
-        action = (SortProxyConnectorsAction) getActionProxy( "/admin/sortUpProxyConnector.action" ).getAction();
-
-        archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
-        action.setArchivaConfiguration( archivaConfiguration );
-    }
 }
index f38236274105fa24d5841d6043e591e478a42b42..f228472d84d32f1679061fc5ae938003a1fc9613 100644 (file)
     <module>metadata</module>
     <module>plugins</module>
   </modules>
-  <dependencyManagement>
-    <dependencies>
-      <dependency>
-        <groupId>org.mockito</groupId>
-        <artifactId>mockito-all</artifactId>
-        <version>1.8.3</version>
-        <scope>test</scope>
-      </dependency>
-    </dependencies>
-  </dependencyManagement>
 
   <reporting>
     <plugins>
diff --git a/pom.xml b/pom.xml
index 135ccf5223eda2a916625976a568fcac078ea8e9..f4327e5575f3a70a3a1abc2270d53c39e9be3ea8 100644 (file)
--- a/pom.xml
+++ b/pom.xml
         <groupId>net.sf.beanlib</groupId>
         <artifactId>beanlib</artifactId>
         <version>5.0.2beta</version>
+        <exclusions>
+          <exclusion>
+            <groupId>cglib</groupId>
+            <artifactId>cglib</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>aopalliance</groupId>
+            <artifactId>aopalliance</artifactId>
+          </exclusion>
+        </exclusions>
       </dependency>
       <dependency>
         <groupId>commons-codec</groupId>
           </exclusion>
         </exclusions>
       </dependency>
+      <dependency>
+        <groupId>jpox</groupId>
+        <artifactId>jpox-ehcache</artifactId>
+        <version>1.1.9</version>
+      </dependency>
       <dependency>
         <groupId>javax.servlet</groupId>
         <artifactId>jsp-api</artifactId>
         <scope>test</scope>
       </dependency>
       <dependency>
-        <groupId>jpox</groupId>
-        <artifactId>jpox-ehcache</artifactId>
-        <version>1.1.9</version>
+        <groupId>org.mockito</groupId>
+        <artifactId>mockito-core</artifactId>
+        <version>1.8.3</version>
+        <scope>test</scope>
       </dependency>
     </dependencies>
   </dependencyManagement>