From 9991433b42b87b02c39872ec3fe313fbb7ccfa7a Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Thu, 3 Nov 2011 00:00:09 +0000 Subject: [PATCH] fix archiva-indexer tests declare task spring annotations only for webapp git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1196875 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-base/archiva-indexer/pom.xml | 38 +++ .../resources/META-INF/spring-context.xml | 4 - .../mock/MockRepositorySessionFactory.java | 249 ++++++++++++++++++ .../META-INF/redback/redback-core.xml | 247 +++++++++++++++++ .../src/test/resources/spring-context.xml | 22 +- .../webapp/WEB-INF/applicationContext.xml | 10 +- 6 files changed, 562 insertions(+), 8 deletions(-) create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java create mode 100644 archiva-modules/archiva-base/archiva-indexer/src/test/resources/META-INF/redback/redback-core.xml diff --git a/archiva-modules/archiva-base/archiva-indexer/pom.xml b/archiva-modules/archiva-base/archiva-indexer/pom.xml index 2aafd9402..c8ce37ab9 100644 --- a/archiva-modules/archiva-base/archiva-indexer/pom.xml +++ b/archiva-modules/archiva-base/archiva-indexer/pom.xml @@ -116,6 +116,31 @@ slf4j-simple test + + org.apache.derby + derby + test + + + org.codehaus.redback + redback-keys-memory + test + + + org.codehaus.redback + redback-rbac-cached + test + + + org.codehaus.redback + redback-rbac-memory + test + + + org.codehaus.redback + redback-users-memory + test + @@ -131,5 +156,18 @@ + + + org.apache.maven.plugins + maven-surefire-plugin + + + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + ${project.build.directory}/appserver-base + + + + diff --git a/archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml index bf5c7ba89..4beb0621c 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml @@ -41,8 +41,4 @@ - - - - \ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java new file mode 100644 index 000000000..17921ed0a --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java @@ -0,0 +1,249 @@ +package org.apache.archiva.indexer.search.mock; +/* + * 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.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.RepositorySession; +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Collections; +import java.util.Date; +import java.util.List; + +/** + * @author Olivier Lamy + */ +@Service( "RepositorySessionFactory#mock" ) +public class MockRepositorySessionFactory + implements RepositorySessionFactory +{ + public RepositorySession createSession( ) + { + return new RepositorySession( null, null ) + { + @Override + public void close( ) + { + return; + } + + @Override + public void save( ) + { + // no op + } + + @Override + public MetadataRepository getRepository( ) + { + return new MetadataRepository( ) + { + public void updateProject( String repositoryId, ProjectMetadata project ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateArtifact( String repositoryId, String namespace, String projectId, + String projectVersion, ArtifactMetadata artifactMeta ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateProjectVersion( String repositoryId, String namespace, String projectId, + ProjectVersionMetadata versionMetadata ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void updateNamespace( String repositoryId, String namespace ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getMetadataFacets( String repositoryId, String facetId ) + throws MetadataRepositoryException + { + return Collections.emptyList( ); + } + + public MetadataFacet getMetadataFacet( String repositoryId, String facetId, String name ) + throws MetadataRepositoryException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void addMetadataFacet( String repositoryId, MetadataFacet metadataFacet ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeMetadataFacets( String repositoryId, String facetId ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeMetadataFacet( String repositoryId, String facetId, String name ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getArtifactsByDateRange( String repositoryId, Date startTime, + Date endTime ) + throws MetadataRepositoryException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getRepositories( ) + throws MetadataRepositoryException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public List getArtifactsByChecksum( String repositoryId, String checksum ) + throws MetadataRepositoryException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeArtifact( String repositoryId, String namespace, String project, String version, + String id ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void removeRepository( String repositoryId ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public List getArtifacts( String repositoryId ) + throws MetadataRepositoryException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public ProjectMetadata getProject( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public ProjectVersionMetadata getProjectVersion( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getArtifactVersions( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjectReferences( String repoId, String namespace, + String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getRootNamespaces( String repoId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getNamespaces( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjects( String repoId, String namespace ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getProjectVersions( String repoId, String namespace, String projectId ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public Collection getArtifacts( String repoId, String namespace, String projectId, + String projectVersion ) + throws MetadataResolutionException + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + + public void save( ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void close( ) + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public void revert( ) + throws MetadataRepositoryException + { + //To change body of implemented methods use File | Settings | File Templates. + } + + public boolean canObtainAccess( Class aClass ) + { + return false; //To change body of implemented methods use File | Settings | File Templates. + } + + public Object obtainAccess( Class aClass ) + { + return null; //To change body of implemented methods use File | Settings | File Templates. + } + }; + } + }; + } +} diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/META-INF/redback/redback-core.xml b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/META-INF/redback/redback-core.xml new file mode 100644 index 000000000..751ac5c8e --- /dev/null +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/META-INF/redback/redback-core.xml @@ -0,0 +1,247 @@ + + + + 1.0.0 + + + System + Roles that apply system-wide, across all of the applications + 1.0.0 + + + global + * + true + global resource implies full access for authorization + + + username + ${username} + true + replaced with the username of the principal at authorization check time + + + + + configuration-edit + configuration-edit + edit configuration + true + + + user-management-user-create + user-management-user-create + create user + true + + + user-management-user-edit + user-management-user-edit + edit user + true + + + user-management-user-role + user-management-user-role + user roles + true + + + user-management-user-delete + user-management-user-delete + delete user + true + + + user-management-user-list + user-management-user-list + list users + true + + + user-management-role-grant + user-management-role-grant + grant role + true + + + user-management-role-drop + user-management-role-drop + drop role + true + + + user-management-rbac-admin + user-management-rbac-admin + administer rbac + true + + + guest-access + guest-access + access guest + true + + + user-management-manage-data + user-management-manage-data + manage data + true + + + + + system-administrator + System Administrator + true + true + + + edit-redback-configuration + Edit Redback Configuration + configuration-edit + global + true + + + manage-rbac-setup + User RBAC Management + user-management-rbac-admin + global + true + + + manage-rbac-data + RBAC Manage Data + user-management-manage-data + global + true + + + + user-administrator + + + + user-administrator + User Administrator + true + true + + + drop-roles-for-anyone + Drop Roles for Anyone + user-management-role-drop + global + true + + + grant-roles-for-anyone + Grant Roles for Anyone + user-management-role-grant + global + true + + + user-create + Create Users + user-management-user-create + global + true + + + user-delete + Delete Users + user-management-user-delete + global + true + + + user-edit + Edit Users + user-management-user-edit + global + true + + + access-users-roles + Access Users Roles + user-management-user-role + global + true + + + access-user-list + Access User List + user-management-user-list + global + true + + + + + edit-users-list + edit users list + true + true + + + access-user-list + Access User List + user-management-user-list + global + true + + + + + registered-user + Registered User + true + true + + + edit-user-by-username + Edit User Data by Username + user-management-user-edit + username + true + + + + + guest + Guest + true + true + + + guest-permission + Guest Permission + guest-access + global + true + + + + + + + \ No newline at end of file diff --git a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml index d2cff166d..1b4d96dc6 100644 --- a/archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml +++ b/archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml @@ -21,12 +21,28 @@ + http://www.springframework.org/schema/context + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/task + http://www.springframework.org/schema/task/spring-task-3.0.xsd" + default-lazy-init="false"> + + + + + + scheduler1 + org.quartz.simpl.SimpleThreadPool + 2 + 4 + org.quartz.simpl.RAMJobStore + + + \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml index 11e0e092a..1c21658d9 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml @@ -20,16 +20,24 @@ + http://www.springframework.org/schema/context/spring-context-3.0.xsd + http://www.springframework.org/schema/task + http://www.springframework.org/schema/task/spring-task-3.0.xsd"> + + + + +