]> source.dussan.org Git - archiva.git/commitdiff
fix archiva-indexer tests
authorOlivier Lamy <olamy@apache.org>
Thu, 3 Nov 2011 00:00:09 +0000 (00:00 +0000)
committerOlivier Lamy <olamy@apache.org>
Thu, 3 Nov 2011 00:00:09 +0000 (00:00 +0000)
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-modules/archiva-base/archiva-indexer/pom.xml
archiva-modules/archiva-base/archiva-indexer/src/main/resources/META-INF/spring-context.xml
archiva-modules/archiva-base/archiva-indexer/src/test/java/org/apache/archiva/indexer/search/mock/MockRepositorySessionFactory.java [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/resources/META-INF/redback/redback-core.xml [new file with mode: 0644]
archiva-modules/archiva-base/archiva-indexer/src/test/resources/spring-context.xml
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/applicationContext.xml

index 2aafd9402b452c8ebc10a4132fa992df82bd068d..c8ce37ab97890423df9d40f5869ec9974909c3d7 100644 (file)
       <artifactId>slf4j-simple</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.apache.derby</groupId>
+      <artifactId>derby</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.redback</groupId>
+      <artifactId>redback-keys-memory</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.redback</groupId>
+      <artifactId>redback-rbac-cached</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.redback</groupId>
+      <artifactId>redback-rbac-memory</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.redback</groupId>
+      <artifactId>redback-users-memory</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   <build>
     <pluginManagement>
         </plugin>
       </plugins>
     </pluginManagement>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <systemPropertyVariables>
+            <appserver.base>${project.build.directory}/appserver-base</appserver.base>
+            <plexus.home>${project.build.directory}/appserver-base</plexus.home>
+            <derby.system.home>${project.build.directory}/appserver-base</derby.system.home>
+          </systemPropertyVariables>
+        </configuration>
+      </plugin>
+    </plugins>
   </build>
 </project>
index bf5c7ba89c69699988ccf704538e6da135323217..4beb0621cd278376573844089e6bdcdecfddd52c 100644 (file)
@@ -41,8 +41,4 @@
   </bean>
 
 
-  <task:executor id="springExecutor" pool-size="2"/>
-  <task:scheduler id="springScheduler" pool-size="2"/>
-  <task:annotation-driven executor="springExecutor" scheduler="springScheduler"/>
-
 </beans>
\ 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 (file)
index 0000000..17921ed
--- /dev/null
@@ -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<String> 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<ArtifactMetadata> getArtifactsByDateRange( String repositoryId, Date startTime,
+                                                                           Date endTime )
+                        throws MetadataRepositoryException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public Collection<String> getRepositories( )
+                        throws MetadataRepositoryException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public List<ArtifactMetadata> 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<ArtifactMetadata> 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<String> 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<ProjectVersionReference> 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<String> getRootNamespaces( String repoId )
+                        throws MetadataResolutionException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public Collection<String> getNamespaces( String repoId, String namespace )
+                        throws MetadataResolutionException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public Collection<String> getProjects( String repoId, String namespace )
+                        throws MetadataResolutionException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public Collection<String> getProjectVersions( String repoId, String namespace, String projectId )
+                        throws MetadataResolutionException
+                    {
+                        return null;  //To change body of implemented methods use File | Settings | File Templates.
+                    }
+
+                    public Collection<ArtifactMetadata> 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 (file)
index 0000000..751ac5c
--- /dev/null
@@ -0,0 +1,247 @@
+<!--
+  ~ 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.
+  -->
+
+<redback-role-model>
+  <modelVersion>1.0.0</modelVersion>
+  <applications>
+    <application>
+      <id>System</id>
+      <description>Roles that apply system-wide, across all of the applications</description>
+      <version>1.0.0</version>
+      <resources>
+        <resource>
+          <id>global</id>
+          <name>*</name>
+          <permanent>true</permanent>
+          <description>global resource implies full access for authorization</description>
+        </resource>
+        <resource>
+          <id>username</id>
+          <name>${username}</name>
+          <permanent>true</permanent>
+          <description>replaced with the username of the principal at authorization check time</description>
+        </resource>
+      </resources>
+      <operations>
+        <operation>
+          <id>configuration-edit</id>
+          <name>configuration-edit</name>
+          <description>edit configuration</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-user-create</id>
+          <name>user-management-user-create</name>
+          <description>create user</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-user-edit</id>
+          <name>user-management-user-edit</name>
+          <description>edit user</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-user-role</id>
+          <name>user-management-user-role</name>
+          <description>user roles</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-user-delete</id>
+          <name>user-management-user-delete</name>
+          <description>delete user</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-user-list</id>
+          <name>user-management-user-list</name>
+          <description>list users</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-role-grant</id>
+          <name>user-management-role-grant</name>
+          <description>grant role</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-role-drop</id>
+          <name>user-management-role-drop</name>
+          <description>drop role</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-rbac-admin</id>
+          <name>user-management-rbac-admin</name>
+          <description>administer rbac</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>guest-access</id>
+          <name>guest-access</name>
+          <description>access guest</description>
+          <permanent>true</permanent>
+        </operation>
+        <operation>
+          <id>user-management-manage-data</id>
+          <name>user-management-manage-data</name>
+          <description>manage data</description>
+          <permanent>true</permanent>
+        </operation>
+      </operations>
+      <roles>
+        <role>
+          <id>system-administrator</id>
+          <name>System Administrator</name>
+          <permanent>true</permanent>
+          <assignable>true</assignable>
+          <permissions>
+            <permission>
+              <id>edit-redback-configuration</id>
+              <name>Edit Redback Configuration</name>
+              <operation>configuration-edit</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>manage-rbac-setup</id>
+              <name>User RBAC Management</name>
+              <operation>user-management-rbac-admin</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>manage-rbac-data</id>
+              <name>RBAC Manage Data</name>
+              <operation>user-management-manage-data</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+          </permissions>
+          <childRoles>
+            <childRole>user-administrator</childRole>
+          </childRoles>
+        </role>
+        <role>
+          <id>user-administrator</id>
+          <name>User Administrator</name>
+          <permanent>true</permanent>
+          <assignable>true</assignable>
+          <permissions>
+            <permission>
+              <id>drop-roles-for-anyone</id>
+              <name>Drop Roles for Anyone</name>
+              <operation>user-management-role-drop</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>grant-roles-for-anyone</id>
+              <name>Grant Roles for Anyone</name>
+              <operation>user-management-role-grant</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>user-create</id>
+              <name>Create Users</name>
+              <operation>user-management-user-create</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>user-delete</id>
+              <name>Delete Users</name>
+              <operation>user-management-user-delete</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>user-edit</id>
+              <name>Edit Users</name>
+              <operation>user-management-user-edit</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>access-users-roles</id>
+              <name>Access Users Roles</name>
+              <operation>user-management-user-role</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+            <permission>
+              <id>access-user-list</id>
+              <name>Access User List</name>
+              <operation>user-management-user-list</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+          </permissions>
+        </role>
+        <role>
+          <id>edit-users-list</id>
+          <name>edit users list</name>
+          <permanent>true</permanent>
+          <assignable>true</assignable>
+          <permissions>
+            <permission>
+              <id>access-user-list</id>
+              <name>Access User List</name>
+              <operation>user-management-user-list</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+          </permissions>
+        </role>
+        <role>
+          <id>registered-user</id>
+          <name>Registered User</name>
+          <permanent>true</permanent>
+          <assignable>true</assignable>
+          <permissions>
+            <permission>
+              <id>edit-user-by-username</id>
+              <name>Edit User Data by Username</name>
+              <operation>user-management-user-edit</operation>
+              <resource>username</resource>
+              <permanent>true</permanent>
+            </permission>
+          </permissions>
+        </role>
+        <role>
+          <id>guest</id>
+          <name>Guest</name>
+          <permanent>true</permanent>
+          <assignable>true</assignable>
+          <permissions>
+            <permission>
+              <id>guest-permission</id>
+              <name>Guest Permission</name>
+              <operation>guest-access</operation>
+              <resource>global</resource>
+              <permanent>true</permanent>
+            </permission>
+          </permissions>
+        </role>
+      </roles>
+    </application>
+  </applications>
+</redback-role-model>
\ No newline at end of file
index d2cff166d62f48cbaf88f417e9645545a3995137..1b4d96dc68fdcb7af42fd420ddf2a882067b06a7 100644 (file)
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:task="http://www.springframework.org/schema/task"
        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">
+           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">
 
+  <context:annotation-config/>
+  <context:component-scan base-package="org.apache.archiva.indexer.search.mock"/>
 
+  <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>
 
 </beans>
\ No newline at end of file
index 11e0e092a5871fb597d3eadbda1ed311fcd8ce04..1c21658d92284bbf79ae2a0c5f2ceeeb8abfd3a1 100644 (file)
 <beans xmlns="http://www.springframework.org/schema/beans"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:context="http://www.springframework.org/schema/context"
+       xmlns:task="http://www.springframework.org/schema/task"
        xsi:schemaLocation="http://www.springframework.org/schema/beans
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/context
-           http://www.springframework.org/schema/context/spring-context-3.0.xsd">
+           http://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">
 
   <context:property-placeholder location="classpath:application.properties"/>
 
   <bean id="loggerManager" class="org.codehaus.plexus.logging.slf4j.Slf4jLoggerManager"
         init-method="initialize"/>
 
+  <!-- only here to cleanup temp indexes for groups increase number if use for something else -->
+  <task:executor id="springExecutor" pool-size="2"/>
+  <task:scheduler id="springScheduler" pool-size="2"/>
+  <task:annotation-driven executor="springExecutor" scheduler="springScheduler"/>
+
   <!--
   TODO olamy check user agent used in wagon !!
   <bean name="wagon#http" class="org.apache.maven.wagon.providers.http.LightweightHttpWagon" scope="prototype">