From 3c8c0b85541ad9e51fdfafdd5fac91ed47e4e524 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 26 Sep 2011 22:49:15 +0000 Subject: [PATCH] fix unit tests git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1176111 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-lucene-consumers/pom.xml | 20 + .../lucene/test/TestRBACManager.java | 389 ++++++++++++++++++ .../test/TestRepositorySessionFactory.java | 261 ++++++++++++ .../lucene/test/TestRoleManager.java | 116 ++++++ .../src/test/resources/spring-context.xml | 61 +++ .../mock/MockArchivaAdministration.java | 14 + .../search/AbstractNexusRepositorySearch.java | 11 +- .../search/NexusRepositorySearchOSGITest.java | 2 +- .../search/NexusRepositorySearchTest.java | 50 +-- .../mock/MockArchivaAdministration.java | 38 +- .../DefaultRepositoryStatisticsManager.java | 4 + 11 files changed, 918 insertions(+), 48 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRBACManager.java create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRoleManager.java create mode 100644 archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml 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 @@ -70,11 +70,20 @@ javax.inject javax.inject + + org.apache.archiva + archiva-repository-admin-api + org.slf4j slf4j-simple test + + org.apache.archiva + archiva-repository-admin-default + test + @@ -88,6 +97,17 @@ + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.outputDirectory} + ${basedir}/target/appserver-base + ${project.build.outputDirectory} + + + 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 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 getRoles( Collection 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 getChildRoles( Role role ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Map getParentRoles( Role role ) + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getAllRoles() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Set 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 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 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 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 getAllUserAssignments() + throws RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getUserAssignmentsForRoles( Collection 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 getAssignedRoles( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getAssignedRoles( UserAssignment userAssignment ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getEffectivelyUnassignedRoles( String principal ) + throws RbacManagerException, RbacObjectNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getEffectivelyAssignedRoles( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getUnassignedRoles( String principal ) + throws RbacManagerException, RbacObjectNotFoundException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Set getAssignedPermissions( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Map> getAssignedPermissionMap( String principal ) + throws RbacObjectNotFoundException, RbacManagerException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List 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 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 getArtifactsByDateRange( String repositoryId, Date startTime, + Date endTime ) + throws MetadataRepositoryException + { + return null; // + } + + public Collection getRepositories() + throws MetadataRepositoryException + { + return null; // + } + + public List 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 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 getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public Collection getProjectReferences( String repoId, String namespace, + String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; // + } + + public Collection getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; // + } + + public Collection getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; // + } + + public Collection getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; // + } + + public Collection getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; // + } + + public Collection 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 @@ + + + + + + + + + + + + + + + ]]> + + + + + + + + scheduler1 + org.quartz.simpl.SimpleThreadPool + 2 + 4 + org.quartz.simpl.RAMJobStore + + + + + + + \ 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 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 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 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 selectedRepos = new ArrayList(); 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 selectedRepos = new ArrayList(); 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 selectedRepos = new ArrayList(); 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 selectedRepos = new ArrayList(); 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 previousSearchTerms = new ArrayList(); 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 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 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 knownContentConsumers, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public List 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 invalidContentConsumers, AuditInformation auditInformation ) throws RepositoryAdminException { - //To change body of implemented methods use File | Settings | File Templates. + } public List 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 scans = metadataRepository.getMetadataFacets( repositoryId, RepositoryStatistics.FACET_ID ); + if (scans == null) + { + return null; + } Collections.sort( scans ); if ( !scans.isEmpty() ) {