aboutsummaryrefslogtreecommitdiffstats
path: root/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2011-11-03 14:30:36 +0000
committerOlivier Lamy <olamy@apache.org>2011-11-03 14:30:36 +0000
commiteeed38179f8c0743156a9447449f696c572490d7 (patch)
treed80da428cfe93328e4703f627b9f38b30a1a5db7 /archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src
parentc215c386165bc32df81033508598a56032cf90aa (diff)
downloadarchiva-eeed38179f8c0743156a9447449f696c572490d7.tar.gz
archiva-eeed38179f8c0743156a9447449f696c572490d7.zip
fix tests in archiva-lucene-consumers
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1197141 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src')
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java11
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml19
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java14
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java261
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml9
5 files changed, 34 insertions, 280 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
index 787c42519..06d4cfd04 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumer.java
@@ -46,6 +46,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import javax.inject.Named;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
@@ -81,12 +82,13 @@ public class NexusIndexerConsumer
private List<? extends IndexCreator> allIndexCreators;
- @Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
- public NexusIndexerConsumer( ArchivaTaskScheduler<ArtifactIndexingTask> scheduler,
- ArchivaConfiguration configuration, FileTypes filetypes,
- PlexusSisuBridge plexusSisuBridge, MavenIndexerUtils mavenIndexerUtils )
+ @Inject
+ public NexusIndexerConsumer(
+ @Named( value = "archivaTaskScheduler#indexing" ) ArchivaTaskScheduler<ArtifactIndexingTask> scheduler,
+ @Named(value = "archivaConfiguration") ArchivaConfiguration configuration, FileTypes filetypes, PlexusSisuBridge plexusSisuBridge,
+ MavenIndexerUtils mavenIndexerUtils, ManagedRepositoryAdmin managedRepositoryAdmin )
throws PlexusSisuBridgeException
{
this.configuration = configuration;
@@ -94,6 +96,7 @@ public class NexusIndexerConsumer
this.scheduler = scheduler;
this.nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
this.allIndexCreators = mavenIndexerUtils.getAllIndexCreators();
+ this.managedRepositoryAdmin = managedRepositoryAdmin;
}
public String getDescription()
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
index 53f71aa72..a93c21a43 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/main/resources/META-INF/spring-context.xml
@@ -27,15 +27,14 @@
http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true">
- <bean id="indexerConsumer" class="org.apache.archiva.consumers.lucene.NexusIndexerConsumer" lazy-init="true">
- <constructor-arg ref="archivaTaskScheduler#indexing"/>
- <constructor-arg ref="archivaConfiguration"/>
- <constructor-arg ref="fileTypes"/>
- <constructor-arg ref="plexusSisuBridge"/>
- <constructor-arg ref="mavenIndexerUtils"/>
- </bean>
+ <context:annotation-config/>
+ <context:component-scan base-package="org.apache.archiva.consumers.lucene"/>
- <bean id="logger" class="org.apache.archiva.common.utils.Slf4JPlexusLogger">
- <constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg>
- </bean>
+ <alias name="knownRepositoryContentConsumer#index-content" alias="indexerConsumer"/>
+
+ <bean id="logger" class="org.apache.archiva.common.utils.Slf4JPlexusLogger">
+ <constructor-arg type="java.lang.Class">
+ <value>org.apache.maven.index.DefaultNexusIndexer</value>
+ </constructor-arg>
+ </bean>
</beans> \ No newline at end of file
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
index 86b5410e2..ac93794f7 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/NexusIndexerConsumerTest.java
@@ -21,14 +21,14 @@ package org.apache.archiva.consumers.lucene;
import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
import org.apache.archiva.common.plexusbridge.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
+import org.apache.archiva.configuration.ArchivaConfiguration;
+import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.commons.io.FileUtils;
-import org.apache.archiva.configuration.ArchivaConfiguration;
-import org.apache.archiva.configuration.FileTypes;
-import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.codehaus.plexus.taskqueue.TaskQueueException;
import org.junit.After;
import org.junit.Before;
@@ -85,7 +85,7 @@ public class NexusIndexerConsumerTest
}
}
- private KnownRepositoryContentConsumer nexusIndexerConsumer;
+ private NexusIndexerConsumer nexusIndexerConsumer;
private ManagedRepository repositoryConfig;
@@ -100,6 +100,9 @@ public class NexusIndexerConsumerTest
@Inject
private MavenIndexerUtils mavenIndexerUtils;
+ @Inject
+ private ManagedRepositoryAdmin managedRepositoryAdmin;
+
@Override
@Before
@@ -115,7 +118,8 @@ public class NexusIndexerConsumerTest
FileTypes filetypes = applicationContext.getBean( FileTypes.class );
nexusIndexerConsumer =
- new NexusIndexerConsumer( scheduler, configuration, filetypes, plexusSisuBridge, mavenIndexerUtils );
+ new NexusIndexerConsumer( scheduler, configuration, filetypes, plexusSisuBridge, mavenIndexerUtils,
+ managedRepositoryAdmin );
// initialize to set the file types to be processed
( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize();
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
deleted file mode 100644
index 100150691..000000000
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/java/org/apache/archiva/consumers/lucene/test/TestRepositorySessionFactory.java
+++ /dev/null
@@ -1,261 +0,0 @@
-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/resources/spring-context.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-lucene-consumers/src/test/resources/spring-context.xml
index 5a1ef90a2..ffaf75ffa 100644
--- 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
@@ -59,4 +59,13 @@
<alias name="roleManager#test" alias="roleManager"/>
+ <bean id="jcr-config" class="org.apache.archiva.metadata.repository.jcr.ArchivaJcrRepositoryConfig" factory-method="create">
+ <constructor-arg value="${appserver.base}/conf/repository.xml"/>
+ <constructor-arg value="${appserver.base}/data/jcr"/>
+ </bean>
+
+ <bean id="jcr-repository" class="org.apache.jackrabbit.core.RepositoryImpl" destroy-method="shutdown" lazy-init="true">
+ <constructor-arg ref="jcr-config"/>
+ </bean>
+
</beans> \ No newline at end of file