fix unit tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1418123 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-06 23:01:51 +00:00
parent 2c11134559
commit 052eb24e53
5 changed files with 26 additions and 13 deletions

View File

@ -24,6 +24,7 @@ import org.apache.archiva.admin.model.beans.ArchivaLdapConfiguration;
import org.apache.archiva.admin.model.beans.ArchivaRuntimeConfiguration;
import org.apache.archiva.admin.model.runtime.ArchivaRuntimeConfigurationAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.IndeterminateConfigurationException;
import org.apache.archiva.configuration.RedbackRuntimeConfiguration;
@ -32,6 +33,8 @@ import org.apache.archiva.redback.configuration.UserConfiguration;
import org.apache.archiva.redback.configuration.UserConfigurationException;
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
@ -45,10 +48,14 @@ import java.util.List;
*/
@Service( "userConfiguration#archiva" )
public class DefaultArchivaRuntimeConfigurationAdmin
extends AbstractRepositoryAdmin
implements ArchivaRuntimeConfigurationAdmin, UserConfiguration
{
protected Logger log = LoggerFactory.getLogger( getClass() );
@Inject
private ArchivaConfiguration archivaConfiguration;
@Inject
@Named( value = "userConfiguration#redback" )
UserConfiguration userConfiguration;
@ -110,18 +117,18 @@ public class DefaultArchivaRuntimeConfigurationAdmin
public ArchivaRuntimeConfiguration getArchivaRuntimeConfiguration()
{
return build( getArchivaConfiguration().getConfiguration().getRedbackRuntimeConfiguration() );
return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );
}
public void updateArchivaRuntimeConfiguration( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )
throws RepositoryAdminException
{
RedbackRuntimeConfiguration runtimeConfiguration = build( archivaRuntimeConfiguration );
Configuration configuration = getArchivaConfiguration().getConfiguration();
Configuration configuration = archivaConfiguration.getConfiguration();
configuration.setRedbackRuntimeConfiguration( runtimeConfiguration );
try
{
getArchivaConfiguration().save( configuration );
archivaConfiguration.save( configuration );
}
catch ( RegistryException e )
{
@ -135,7 +142,15 @@ public class DefaultArchivaRuntimeConfigurationAdmin
private ArchivaRuntimeConfiguration build( RedbackRuntimeConfiguration runtimeConfiguration )
{
return new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
ArchivaRuntimeConfiguration archivaRuntimeConfiguration = new BeanReplicator().replicateBean( runtimeConfiguration, ArchivaRuntimeConfiguration.class );
if (archivaRuntimeConfiguration.getArchivaLdapConfiguration() == null)
{
// prevent NPE
archivaRuntimeConfiguration.setArchivaLdapConfiguration( new ArchivaLdapConfiguration() );
}
return archivaRuntimeConfiguration;
}
private RedbackRuntimeConfiguration build( ArchivaRuntimeConfiguration archivaRuntimeConfiguration )

View File

@ -52,5 +52,5 @@
</bean>
<bean name="repositorySessionFactory" class="org.apache.archiva.webtest.memory.TestRepositorySessionFactory"/>
<alias name="userConfiguration#archiva" alias="userConfiguration#default"/>
</beans>

View File

@ -65,5 +65,5 @@
</bean>
<bean name="RoleManagerStub" class="org.apache.archiva.web.rss.RoleManagerStub"/>
<alias name="userConfiguration#archiva" alias="userConfiguration#default"/>
</beans>

View File

@ -21,13 +21,11 @@
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jaxrs="http://cxf.apache.org/jaxrs"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://cxf.apache.org/jaxrs
http://cxf.apache.org/schemas/jaxrs.xsd" default-lazy-init="true">
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">
<context:annotation-config/>
<context:component-scan
@ -83,5 +81,5 @@
</bean>
<alias name="repositorySessionFactory#jcr" alias="repositorySessionFactory"/>
<alias name="userConfiguration#archiva" alias="userConfiguration#default"/>
</beans>

View File

@ -49,5 +49,5 @@
</props>
</property>
</bean>
<alias name="userConfiguration#archiva" alias="userConfiguration#default"/>
</beans>