[MRM-496] start a test case

git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@575133 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brett Porter 2007-09-13 00:10:20 +00:00
parent 7b2e4063bf
commit cd957318dc
3 changed files with 145 additions and 10 deletions

View File

@ -445,11 +445,6 @@ public class ConfigureProxyConnectorAction
this.connector = connector; this.connector = connector;
} }
public void setManagedRepoIdList( List managedRepoIdList )
{
this.managedRepoIdList = managedRepoIdList;
}
public void setMode( String mode ) public void setMode( String mode )
{ {
this.mode = mode; this.mode = mode;
@ -465,11 +460,6 @@ public class ConfigureProxyConnectorAction
this.propertyValue = propertyValue; this.propertyValue = propertyValue;
} }
public void setRemoteRepoIdList( List remoteRepoIdList )
{
this.remoteRepoIdList = remoteRepoIdList;
}
public void setSource( String source ) public void setSource( String source )
{ {
this.source = source; this.source = source;
@ -578,4 +568,9 @@ public class ConfigureProxyConnectorAction
{ {
this.pattern = pattern; this.pattern = pattern;
} }
public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
{
this.archivaConfiguration = archivaConfiguration;
}
} }

View File

@ -0,0 +1,95 @@
package org.apache.maven.archiva.web.action.admin.connectors.proxy;
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import com.opensymphony.xwork.Action;
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
import org.apache.maven.archiva.configuration.Configuration;
import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
import org.easymock.MockControl;
/**
* Test the proxy connector configuration action returns the correct data.
*/
public class ConfigureProxyConnectorActionTest
extends PlexusTestCase
{
private ConfigureProxyConnectorAction action;
private MockControl archivaConfigurationControl;
private ArchivaConfiguration archivaConfiguration;
protected void setUp()
throws Exception
{
super.setUp();
// TODO: purely to quiet logging - shouldn't be needed
String appserverBase = getTestFile( "target/appserver-base" ).getAbsolutePath();
System.setProperty( "appserver.base", appserverBase );
action = (ConfigureProxyConnectorAction) lookup( Action.class.getName(), "configureProxyConnectorAction" );
archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
action.setArchivaConfiguration( archivaConfiguration );
}
public void testSecureActionBundle()
throws Exception
{
archivaConfiguration.getConfiguration();
archivaConfigurationControl.setReturnValue( new Configuration() );
archivaConfigurationControl.replay();
action.prepare();
SecureActionBundle bundle = action.getSecureActionBundle();
assertTrue( bundle.requiresAuthentication() );
assertEquals( 1, bundle.getAuthorizationTuples().size() );
}
public void testAddProxyConnectorInitialPage()
throws Exception
{
archivaConfiguration.getConfiguration();
archivaConfigurationControl.setReturnValue( new Configuration() );
archivaConfigurationControl.replay();
action.prepare();
assertNull( action.getMode() );
ProxyConnectorConfiguration configuration = action.getConnector();
assertNotNull( configuration );
assertNull( configuration.getProxyId() );
assertNull( configuration.getSourceRepoId() );
assertNull( configuration.getTargetRepoId() );
assertTrue( configuration.getPolicies().isEmpty() );
assertTrue( configuration.getProperties().isEmpty() );
assertTrue( configuration.getBlackListPatterns().isEmpty() );
assertTrue( configuration.getWhiteListPatterns().isEmpty() );
String status = action.add();
assertEquals( Action.INPUT, status );
}
// TODO: test the population of proxyIdOptions, *RepoIdList (from prepare) and policyMap (from initialize)
// TODO: test the other methods. Should review the structure of the action in the process as there is a lot of different combinations of parameters
}

View File

@ -0,0 +1,45 @@
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<plexus>
<components>
<component>
<role>org.codehaus.plexus.logging.LoggerManager</role>
<implementation>org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager</implementation>
<lifecycle-handler>basic</lifecycle-handler>
</component>
<component>
<role>com.opensymphony.xwork.Action</role>
<role-hint>configureProxyConnectorAction</role-hint>
<implementation>org.apache.maven.archiva.web.action.admin.connectors.proxy.ConfigureProxyConnectorAction
</implementation>
<instantiation-strategy>per-lookup</instantiation-strategy>
<requirements>
<requirement>
<role>org.apache.maven.archiva.policies.PreDownloadPolicy</role>
<field-name>preDownloadPolicyMap</field-name>
</requirement>
<requirement>
<role>org.apache.maven.archiva.policies.PostDownloadPolicy</role>
<field-name>postDownloadPolicyMap</field-name>
</requirement>
</requirements>
</component>
</components>
</plexus>