<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>
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>();
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() )
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>();
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 )
+ " is not a RemoteRepository" );
}
- // FIXME validate NetworkProxyConfiguration too
+ // FIXME validate NetworkProxyConfiguration too when available
}
}
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
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;
+
}
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() );
+
+ }
+
}
}
}
+ // FIXME remove
public ArchivaConfiguration getArchivaConfiguration()
{
return archivaConfiguration;
* 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;
{
@Override
public void prepare()
+ throws RepositoryAdminException
{
super.prepare();
- connector = new ProxyConnectorConfiguration();
+ connector = new ProxyConnector();
}
@Override
}
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
String sourceId = connector.getSourceRepoId();
String targetId = connector.getTargetRepoId();
- ProxyConnectorConfiguration otherConnector = findProxyConnector( sourceId, targetId );
+ ProxyConnector otherConnector = findProxyConnector( sourceId, targetId );
if ( otherConnector != null )
{
addActionError(
connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
addProxyConnector( connector );
- return saveConfiguration();
+ return SUCCESS;
}
}
* 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" )
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;
}
}
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;
}
{
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()
this.target = id;
}
- public ProxyConnectorConfiguration getProxyConfig()
+ public ProxyConnector getProxyConfig()
{
return proxyConfig;
}
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;
/**
* DisableProxyConnectorAction
- *
*/
@Controller( "disableProxyConnectorAction" )
@Scope( "prototype" )
private String target;
- private ProxyConnectorConfiguration proxyConfig;
+ private ProxyConnector proxyConfig;
public String confirmDisable()
+ throws RepositoryAdminException
{
this.proxyConfig = findProxyConnector( source, target );
}
public String disable()
+ throws RepositoryAdminException
{
this.proxyConfig = findProxyConnector( source, target );
setSource( null );
setTarget( null );
- return saveConfiguration();
+ getProxyConnectorAdmin().updateProxyConnector( proxyConfig, getAuditInformation() );
+ return SUCCESS;
}
public String getSource()
* 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
{
@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() ) );
}
}
public String commit()
+ throws RepositoryAdminException
{
validateConnector();
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.
return INPUT;
}
- // MRM-1135
- connector.setBlackListPatterns( unescapePatterns( connector.getBlackListPatterns() ) );
- connector.setWhiteListPatterns( unescapePatterns( connector.getWhiteListPatterns() ) );
-
addProxyConnector( connector );
- return saveConfiguration();
+ return SUCCESS;
}
public String getSource()
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;
private String target;
- private ProxyConnectorConfiguration proxyConfig;
+ private ProxyConnector proxyConfig;
public String confirmEnable()
+ throws RepositoryAdminException
{
this.proxyConfig = findProxyConnector( source, target );
return INPUT;
}
- public String enable()
+ public String enable() throws RepositoryAdminException
{
this.proxyConfig = findProxyConnector( source, target );
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()
*/
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;
* ProxyConnectorsAction
*
* @version $Id$
- *
*/
@Controller( "proxyConnectorsAction" )
@Scope( "prototype" )
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;
}
* 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;
}
public String sortDown()
+ throws RepositoryAdminException
{
- List<ProxyConnectorConfiguration> connectors = createProxyConnectorMap().get( source );
+ List<ProxyConnector> connectors = createProxyConnectorMap().get( source );
int idx = findTargetConnector( connectors, target );
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 );
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 ) )
{
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 );
return idx;
}
- private void incrementConnectorOrder( List<ProxyConnectorConfiguration> connectors, int idx )
+ private void incrementConnectorOrder( List<ProxyConnector> connectors, int idx )
{
if ( !validIndex( connectors, idx ) )
{
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() );
}
*/
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;
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()
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Perform Test w/no values.
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Perform Test w/no values.
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" );
archivaConfigurationControl.replay();
action.prepare();
- ProxyConnectorConfiguration configuration = action.getConnector();
+ ProxyConnector configuration = action.getConnector();
assertNotNull( configuration );
assertNull( configuration.getProxyId() );
assertNull( configuration.getSourceRepoId() );
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Perform Test w/no values.
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Add some arbitrary blacklist patterns.
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Add some arbitrary properties.
// Prepare Test.
action.prepare();
- ProxyConnectorConfiguration connector = action.getConnector();
+ ProxyConnector connector = action.getConnector();
populateProxyConnector( connector );
// Add some arbitrary whitelist patterns.
}
@SuppressWarnings("unchecked")
- private void populateProxyConnector( ProxyConnectorConfiguration connector )
+ private void populateProxyConnector( ProxyConnector connector )
{
connector.setProxyId( AbstractProxyConnectorFormAction.DIRECT_CONNECTION );
connector.setSourceRepoId( "corporate" );
*/
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;
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$
*/
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
{
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 );
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 );
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 );
- }
}
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;
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 );
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 );
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 );
- }
}
*/
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;
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$
*/
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
{
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.
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.
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.
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" );
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();
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.
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.
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.
assertEquals( 1, bundle.getAuthorizationTuples().size() );
}
- private void assertInitialProxyConnector( ProxyConnectorConfiguration connector )
+ private void assertInitialProxyConnector( ProxyConnector connector )
{
assertNotNull( connector );
assertNotNull( connector.getBlackListPatterns() );
assertEquals( TEST_TARGET_ID, connector.getTargetRepoId() );
}
- @SuppressWarnings("unchecked")
+ @SuppressWarnings( "unchecked" )
private Configuration createInitialConfiguration()
{
Configuration config = new Configuration();
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() );
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() );
- }
- }
}
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;
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 );
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 );
// 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()
assertTrue( bundle.requiresAuthentication() );
assertEquals( 1, bundle.getAuthorizationTuples().size() );
}
-
+
public void testConfirmEnable()
throws Exception
{
assertEquals( Action.INPUT, status );
assertNoErrors( action );
}
-
+
private Configuration createInitialConfiguration()
{
Configuration config = new Configuration();
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 );
- }
}
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;
{
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();
public void testExecute()
throws Exception
{
- expectConfigurationRequests( 3 );
+ expectConfigurationRequests( 5 );
archivaConfigurationControl.replay();
action.prepare();
*/
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;
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
{
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 );
- }
}
<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>
<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>