diff options
author | Olivier Lamy <olamy@apache.org> | 2011-09-26 22:49:15 +0000 |
---|---|---|
committer | Olivier Lamy <olamy@apache.org> | 2011-09-26 22:49:15 +0000 |
commit | 3c8c0b85541ad9e51fdfafdd5fac91ed47e4e524 (patch) | |
tree | 3a47a1527a37cf596abceeca4b30927716074446 | |
parent | 276eaf0b5ddabe7c48dfc9bb5df03204e9b215a4 (diff) | |
download | archiva-3c8c0b85541ad9e51fdfafdd5fac91ed47e4e524.tar.gz archiva-3c8c0b85541ad9e51fdfafdd5fac91ed47e4e524.zip |
fix unit tests
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176111 13f79535-47bb-0310-9956-ffa450edef68
11 files changed, 918 insertions, 48 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml index 495bf811b..d305e3e5d 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/pom.xml @@ -71,10 +71,19 @@ <artifactId>javax.inject</artifactId> </dependency> <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-repository-admin-api</artifactId> + </dependency> + <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-simple</artifactId> <scope>test</scope> </dependency> + <dependency> + <groupId>org.apache.archiva</groupId> + <artifactId>archiva-repository-admin-default</artifactId> + <scope>test</scope> + </dependency> </dependencies> <build> <pluginManagement> @@ -88,6 +97,17 @@ </excludes> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-surefire-plugin</artifactId> + <configuration> + <systemPropertyVariables> + <plexus.home>${project.build.outputDirectory}</plexus.home> + <appserver.base>${basedir}/target/appserver-base</appserver.base> + <java.io.tmpdir>${project.build.outputDirectory}</java.io.tmpdir> + </systemPropertyVariables> + </configuration> + </plugin> </plugins> </pluginManagement> </build> diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java new file mode 100644 index 000000000..3e367bdf6 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java @@ -0,0 +1,389 @@ +package org.apache.archiva.consumers.lucene.test; +/* + * 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 org.codehaus.plexus.redback.rbac.Operation; +import org.codehaus.plexus.redback.rbac.Permission; +import org.codehaus.plexus.redback.rbac.RBACManager; +import org.codehaus.plexus.redback.rbac.RBACManagerListener; +import org.codehaus.plexus.redback.rbac.RbacManagerException; +import org.codehaus.plexus.redback.rbac.RbacObjectInvalidException; +import org.codehaus.plexus.redback.rbac.RbacObjectNotFoundException; +import org.codehaus.plexus.redback.rbac.Resource; +import org.codehaus.plexus.redback.rbac.Role; +import org.codehaus.plexus.redback.rbac.UserAssignment; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Set; + +/** + * @author Olivier Lamy + */ +@Service("rBACManager#cached") +public class TestRBACManager implements RBACManager +{ + public void addListener( RBACManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeListener( RBACManagerListener listener ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Role createRole( String name ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean roleExists( String name ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean roleExists( Role role ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Role saveRole( Role role ) + throws RbacObjectInvalidException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void saveRoles( Collection<Role> roles ) + throws RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Role getRole( String roleName ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Map<String, Role> getRoles( Collection<String> roleNames ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void addChildRole( Role role, Role childRole ) + throws RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Map<String, Role> getChildRoles( Role role ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Map<String, Role> getParentRoles( Role role ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<Role> getAllRoles() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Set<Role> getEffectiveRoles( Role role ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeRole( Role role ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeRole( String roleName ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Permission createPermission( String name ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Permission createPermission( String name, String operationName, String resourceIdentifier ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean permissionExists( String name ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean permissionExists( Permission permission ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Permission savePermission( Permission permission ) + throws RbacObjectInvalidException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Permission getPermission( String permissionName ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<Permission> getAllPermissions() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removePermission( Permission permission ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removePermission( String permissionName ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Operation createOperation( String name ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean operationExists( String name ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean operationExists( Operation operation ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Operation saveOperation( Operation operation ) + throws RbacObjectInvalidException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Operation getOperation( String operationName ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<Operation> getAllOperations() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeOperation( Operation operation ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeOperation( String operationName ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Resource createResource( String identifier ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean resourceExists( String identifier ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean resourceExists( Resource resource ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Resource saveResource( Resource resource ) + throws RbacObjectInvalidException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Resource getResource( String resourceIdentifier ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<Resource> getAllResources() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeResource( Resource resource ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeResource( String resourceIdentifier ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public UserAssignment createUserAssignment( String principal ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean userAssignmentExists( String principal ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean userAssignmentExists( UserAssignment assignment ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public UserAssignment saveUserAssignment( UserAssignment userAssignment ) + throws RbacObjectInvalidException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public UserAssignment getUserAssignment( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<UserAssignment> getAllUserAssignments() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<UserAssignment> getUserAssignmentsForRoles( Collection<String> roleNames ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeUserAssignment( UserAssignment userAssignment ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeUserAssignment( String principal ) + throws RbacObjectNotFoundException, RbacObjectInvalidException, RbacManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<Role> getAssignedRoles( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<Role> getAssignedRoles( UserAssignment userAssignment ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<Role> getEffectivelyUnassignedRoles( String principal ) + throws RbacManagerException, RbacObjectNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<Role> getEffectivelyAssignedRoles( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection<Role> getUnassignedRoles( String principal ) + throws RbacManagerException, RbacObjectNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Set<Permission> getAssignedPermissions( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Map<String, List<Permission>> getAssignedPermissionMap( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List<Role> getAllAssignableRoles() + throws RbacManagerException, RbacObjectNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Resource getGlobalResource() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void eraseDatabase() + { + //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java new file mode 100644 index 000000000..100150691 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java @@ -0,0 +1,261 @@ +package org.apache.archiva.consumers.lucene.test; + +import org.apache.archiva.metadata.model.ArtifactMetadata; +import org.apache.archiva.metadata.model.MetadataFacet; +import org.apache.archiva.metadata.model.ProjectMetadata; +import org.apache.archiva.metadata.model.ProjectVersionMetadata; +import org.apache.archiva.metadata.model.ProjectVersionReference; +import org.apache.archiva.metadata.repository.MetadataRepository; +import org.apache.archiva.metadata.repository.MetadataRepositoryException; +import org.apache.archiva.metadata.repository.MetadataResolutionException; +import org.apache.archiva.metadata.repository.MetadataResolver; +import org.apache.archiva.metadata.repository.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.easymock.MockControl; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Date; +import java.util.List; + +/* +* 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. +*/ +@Service( "repositorySessionFactory#test" ) +public class TestRepositorySessionFactory + implements RepositorySessionFactory +{ + private MetadataRepository repository; + + private MetadataResolver resolver; + + public RepositorySession createSession() + { + return new RepositorySession( null, null ) + { + @Override + public MetadataResolver getResolver() + { + return (MetadataResolver) MockControl.createControl( MetadataResolver.class ); + } + + @Override + public void close() + { + + } + + @Override + public MetadataRepository getRepository() + { + return new MetadataRepository() + { + public void updateProject( String repositoryId, ProjectMetadata project ) + throws MetadataRepositoryException + { + // + } + + public void updateArtifact( String repositoryId, String namespace, String projectId, + String projectVersion, ArtifactMetadata artifactMeta ) + throws MetadataRepositoryException + { + // + } + + public void updateProjectVersion( String repositoryId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) + throws MetadataRepositoryException + { + // + } + + public void updateNamespace( String repositoryId, String namespace ) + throws MetadataRepositoryException + { + // + } + + public List<String> getMetadataFacets( String repositoryId, String facetId ) + throws MetadataRepositoryException + { + return null; // + } + + public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name ) + throws MetadataRepositoryException + { + return null; // + } + + public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet ) + throws MetadataRepositoryException + { + // + } + + public void removeMetadataFacets( String repositoryId, String facetId ) + throws MetadataRepositoryException + { + // + } + + public void removeMetadataFacet( String repositoryId, String facetId, String name ) + throws MetadataRepositoryException + { + // + } + + public List<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime, + Date endTime ) + throws MetadataRepositoryException + { + return null; // + } + + public Collection<String> getRepositories() + throws MetadataRepositoryException + { + return null; // + } + + public List<ArtifactMetadata> getArtifactsByChecksum( String repositoryId, String checksum ) + throws MetadataRepositoryException + { + return null; // + } + + public void removeArtifact( String repositoryId, String namespace, String project, String version, + String id ) + throws MetadataRepositoryException + { + // + } + + public void removeRepository( String repositoryId ) + throws MetadataRepositoryException + { + // + } + + public List<ArtifactMetadata> getArtifacts( String repositoryId ) + throws MetadataRepositoryException + { + return null; // + } + + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; // + } + + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<String> getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<ProjectVersionReference> getProjectReferences( String repoId, String namespace, + String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<String> getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<String> getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<String> getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<String> getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; // + } + + public Collection<ArtifactMetadata> getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public void save() + throws MetadataRepositoryException + { + // + } + + public void close() + { + // + } + + public void revert() + throws MetadataRepositoryException + { + // + } + + public boolean canObtainAccess( Class<?> aClass ) + { + return false; // + } + + public Object obtainAccess( Class<?> aClass ) + { + return null; // + } + }; + } + }; + } + + public void setRepository( MetadataRepository repository ) + { + this.repository = repository; + } + + public void setResolver( MetadataResolver resolver ) + { + this.resolver = resolver; + } +} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java new file mode 100644 index 000000000..e5f47d3e8 --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java @@ -0,0 +1,116 @@ +package org.apache.archiva.consumers.lucene.test; +/* + * 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 org.codehaus.plexus.redback.role.RoleManager; +import org.codehaus.plexus.redback.role.RoleManagerException; +import org.codehaus.plexus.redback.role.model.RedbackRoleModel; +import org.springframework.stereotype.Service; + +import java.net.URL; + +/** + * @author Olivier Lamy + */ +@Service( "roleManager#test" ) +public class TestRoleManager implements RoleManager +{ + public void loadRoleModel( URL resourceLocation ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void loadRoleModel( RedbackRoleModel model ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void createTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeTemplatedRole( String templateId, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateRole( String templateId, String oldResource, String newResource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void assignTemplatedRole( String templateId, String resource, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRole( String roleId, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void unassignRoleByName( String roleName, String principal ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean roleExists( String roleId ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean templatedRoleExists( String templateId, String resource ) + throws RoleManagerException + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public RedbackRoleModel getModel() + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void verifyTemplatedRole( String templateID, String resource ) + throws RoleManagerException + { + //To change body of implemented methods use File | Settings | File Templates. + } +} diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml new file mode 100644 index 000000000..837d1e27a --- /dev/null +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml @@ -0,0 +1,61 @@ +<?xml version="1.0"?> + +<!-- + ~ 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. + --> +<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" + 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" + default-lazy-init="true"> + <context:annotation-config/> + <context:component-scan base-package="org.apache.archiva.consumers.lucene.test"/> + + <bean name="commons-configuration" class="org.codehaus.redback.components.registry.commons.CommonsConfigurationRegistry"> + <property name="properties"> + <value> + <![CDATA[ + <configuration> + <system/> + <xml fileName="${appserver.base}/conf/archiva.xml" config-forceCreate="true" + config-optional="true" + config-name="org.apache.maven.archiva.base" config-at="org.apache.maven.archiva"/> + </configuration> + ]]> + </value> + </property> + </bean> + + <bean name="scheduler" class="org.codehaus.redback.components.scheduler.DefaultScheduler"> + <property name="properties"> + <props> + <prop key="org.quartz.scheduler.instanceName">scheduler1</prop> + <prop key="org.quartz.threadPool.class">org.quartz.simpl.SimpleThreadPool</prop> + <prop key="org.quartz.threadPool.threadCount">2</prop> + <prop key="org.quartz.threadPool.threadPriority">4</prop> + <prop key="org.quartz.jobStore.class">org.quartz.simpl.RAMJobStore</prop> + </props> + </property> + </bean> + + <alias name="roleManager#test" alias="roleManager"/> + +</beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java index e330f2953..fa34784db 100644 --- a/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-converter/src/test/java/org/apache/archiva/converter/mock/MockArchivaAdministration.java @@ -24,6 +24,7 @@ import org.apache.archiva.admin.model.admin.ArchivaAdministration; import org.apache.archiva.admin.model.beans.FileType; import org.apache.archiva.admin.model.beans.LegacyArtifactPath; import org.apache.archiva.admin.model.beans.OrganisationInformation; +import org.apache.archiva.admin.model.beans.UiConfiguration; import java.util.List; @@ -145,5 +146,18 @@ public class MockArchivaAdministration throws RepositoryAdminException { + + } + + public UiConfiguration getUiConfiguration() + throws RepositoryAdminException + { + return null; + } + + public void updateUiConfiguration( UiConfiguration uiConfiguration ) + throws RepositoryAdminException + { + } } diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java index c59531aa1..d9e1415e1 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/AbstractNexusRepositorySearch.java @@ -21,14 +21,15 @@ package org.apache.archiva.indexer.search; import junit.framework.TestCase; import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin; +import org.apache.archiva.admin.repository.proxyconnector.DefaultProxyConnectorAdmin; import org.apache.archiva.common.plexusbridge.MavenIndexerUtils; import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.SystemUtils; import org.apache.archiva.common.utils.FileUtil; import org.apache.archiva.configuration.ArchivaConfiguration; import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.SystemUtils; import org.apache.maven.index.ArtifactContext; import org.apache.maven.index.ArtifactContextProducer; import org.apache.maven.index.ArtifactScanningListener; @@ -100,7 +101,11 @@ public abstract class AbstractNexusRepositorySearch DefaultManagedRepositoryAdmin defaultManagedRepositoryAdmin = new DefaultManagedRepositoryAdmin(); defaultManagedRepositoryAdmin.setArchivaConfiguration( archivaConfig ); - search = new NexusRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils ); + DefaultProxyConnectorAdmin defaultProxyConnectorAdmin = new DefaultProxyConnectorAdmin(); + defaultProxyConnectorAdmin.setArchivaConfiguration( archivaConfig ); + + search = new NexusRepositorySearch( plexusSisuBridge, defaultManagedRepositoryAdmin, mavenIndexerUtils, + defaultProxyConnectorAdmin ); nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java index f38638249..9cc6763f9 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchOSGITest.java @@ -43,7 +43,7 @@ public class NexusRepositorySearchOSGITest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); // search artifactId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); archivaConfigControl.replay(); diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java index 77f8e19c0..f57200ccb 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/NexusRepositorySearchTest.java @@ -97,7 +97,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); // search artifactId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1, 2 ); archivaConfigControl.replay(); @@ -117,7 +117,7 @@ public class NexusRepositorySearchTest archivaConfigControl.reset(); // search groupId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2); archivaConfigControl.replay(); @@ -140,7 +140,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = Arrays.asList( TEST_REPO_1 ); // search artifactId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -160,7 +160,7 @@ public class NexusRepositorySearchTest archivaConfigControl.reset(); // search groupId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -184,7 +184,7 @@ public class NexusRepositorySearchTest selectedRepos.add( TEST_REPO_1 ); // search artifactId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -214,7 +214,7 @@ public class NexusRepositorySearchTest selectedRepos.add( TEST_REPO_1 ); // search artifactId - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -250,7 +250,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); SearchResults results = search.search( "user", selectedRepos, "archiva search", null, null ); @@ -274,7 +274,7 @@ public class NexusRepositorySearchTest SearchResultLimits limits = new SearchResultLimits( 0 ); limits.setPageSize( 1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -294,7 +294,7 @@ public class NexusRepositorySearchTest limits = new SearchResultLimits( 1 ); limits.setPageSize( 1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -329,7 +329,7 @@ public class NexusRepositorySearchTest config.addManagedRepository( createRepositoryConfig( TEST_REPO_2 ) ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 5 ); archivaConfigControl.replay(); @@ -364,7 +364,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -383,7 +383,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( TEST_REPO_1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -401,7 +401,7 @@ public class NexusRepositorySearchTest List<String> selectedRepos = new ArrayList<String>(); selectedRepos.add( "non-existing-repo" ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -424,7 +424,7 @@ public class NexusRepositorySearchTest List<String> previousSearchTerms = new ArrayList<String>(); previousSearchTerms.add( "archiva-test" ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -462,7 +462,7 @@ public class NexusRepositorySearchTest searchFields.setVersion( "1.0" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -497,7 +497,7 @@ public class NexusRepositorySearchTest SearchResultLimits limits = new SearchResultLimits( 0 ); limits.setPageSize( 1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -515,7 +515,7 @@ public class NexusRepositorySearchTest limits = new SearchResultLimits( 1 ); limits.setPageSize( 1 ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -547,7 +547,7 @@ public class NexusRepositorySearchTest searchFields.setArtifactId( "artifactid-numeric" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1 ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -590,7 +590,7 @@ public class NexusRepositorySearchTest try { - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1 ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -624,7 +624,7 @@ public class NexusRepositorySearchTest try { - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 1 ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -657,7 +657,7 @@ public class NexusRepositorySearchTest searchFields.setClassName( "org.apache.archiva.test.App" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndDefaultReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -688,7 +688,7 @@ public class NexusRepositorySearchTest searchFields.setPackaging( "jar" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -739,7 +739,7 @@ public class NexusRepositorySearchTest searchFields.setClassName( "com.classname.search.App" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -767,7 +767,7 @@ public class NexusRepositorySearchTest searchFields.setGroupId( "org.apache.archiva" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); @@ -791,7 +791,7 @@ public class NexusRepositorySearchTest searchFields.setClassName( "SomeClass" ); searchFields.setRepositories( selectedRepos ); - archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config ); + archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config , 1 , 2 ); archivaConfigControl.replay(); diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java index 29b883592..f87f1b7f9 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/mock/MockArchivaAdministration.java @@ -41,67 +41,67 @@ public class MockArchivaAdministration public List<LegacyArtifactPath> getLegacyArtifactPaths() throws RepositoryAdminException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public void addLegacyArtifactPath( LegacyArtifactPath legacyArtifactPath, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void deleteLegacyArtifactPath( String path, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void addFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void removeFileTypePattern( String fileTypeId, String pattern, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public List<FileType> getFileTypes() throws RepositoryAdminException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public FileType getFileType( String fileTypeId ) throws RepositoryAdminException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public void addFileType( FileType fileType, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void removeFileType( String fileTypeId, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void addKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void setKnownContentConsumers( List<String> knownContentConsumers, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public List<String> getKnownContentConsumers() @@ -114,19 +114,19 @@ public class MockArchivaAdministration public void removeKnownContentConsumer( String knownContentConsumer, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void addInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public void setInvalidContentConsumers( List<String> invalidContentConsumers, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public List<String> getInvalidContentConsumers() @@ -139,19 +139,19 @@ public class MockArchivaAdministration public void removeInvalidContentConsumer( String invalidContentConsumer, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public OrganisationInformation getOrganisationInformation() throws RepositoryAdminException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public void setOrganisationInformation( OrganisationInformation organisationInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public ArchivaConfiguration getArchivaConfiguration() @@ -167,12 +167,12 @@ public class MockArchivaAdministration public UiConfiguration getUiConfiguration() throws RepositoryAdminException { - return null; //To change body of implemented methods use File | Settings | File Templates. + return null; } public void updateUiConfiguration( UiConfiguration uiConfiguration ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } } diff --git a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java index fb1d8218c..4bad96e5f 100644 --- a/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java +++ b/archiva-modules/plugins/repository-statistics/src/main/java/org/apache/archiva/metadata/repository/stats/DefaultRepositoryStatisticsManager.java @@ -63,6 +63,10 @@ public class DefaultRepositoryStatisticsManager { // TODO: consider a more efficient implementation that directly gets the last one from the content repository List<String> scans = metadataRepository.getMetadataFacets( repositoryId, RepositoryStatistics.FACET_ID ); + if (scans == null) + { + return null; + } Collections.sort( scans ); if ( !scans.isEmpty() ) { |