fix tests in archiva-lucene-consumers

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1197141 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-11-03 14:30:36 +00:00
parent c215c38616
commit eeed38179f
6 changed files with 50 additions and 280 deletions

View File

@ -84,6 +84,22 @@
<artifactId>archiva-repository-admin-default</artifactId> <artifactId>archiva-repository-admin-default</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>metadata-store-jcr</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.jackrabbit</groupId>
<artifactId>jackrabbit-core</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies> </dependencies>
<build> <build>
<pluginManagement> <pluginManagement>

View File

@ -46,6 +46,7 @@ import org.springframework.stereotype.Service;
import javax.annotation.PostConstruct; import javax.annotation.PostConstruct;
import javax.inject.Inject; import javax.inject.Inject;
import javax.inject.Named;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -81,12 +82,13 @@ public class NexusIndexerConsumer
private List<? extends IndexCreator> allIndexCreators; private List<? extends IndexCreator> allIndexCreators;
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin; private ManagedRepositoryAdmin managedRepositoryAdmin;
public NexusIndexerConsumer( ArchivaTaskScheduler<ArtifactIndexingTask> scheduler, @Inject
ArchivaConfiguration configuration, FileTypes filetypes, public NexusIndexerConsumer(
PlexusSisuBridge plexusSisuBridge, MavenIndexerUtils mavenIndexerUtils ) @Named( value = "archivaTaskScheduler#indexing" ) ArchivaTaskScheduler<ArtifactIndexingTask> scheduler,
@Named(value = "archivaConfiguration") ArchivaConfiguration configuration, FileTypes filetypes, PlexusSisuBridge plexusSisuBridge,
MavenIndexerUtils mavenIndexerUtils, ManagedRepositoryAdmin managedRepositoryAdmin )
throws PlexusSisuBridgeException throws PlexusSisuBridgeException
{ {
this.configuration = configuration; this.configuration = configuration;
@ -94,6 +96,7 @@ public class NexusIndexerConsumer
this.scheduler = scheduler; this.scheduler = scheduler;
this.nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class ); this.nexusIndexer = plexusSisuBridge.lookup( NexusIndexer.class );
this.allIndexCreators = mavenIndexerUtils.getAllIndexCreators(); this.allIndexCreators = mavenIndexerUtils.getAllIndexCreators();
this.managedRepositoryAdmin = managedRepositoryAdmin;
} }
public String getDescription() public String getDescription()

View File

@ -27,15 +27,14 @@
http://www.springframework.org/schema/context/spring-context-3.0.xsd" http://www.springframework.org/schema/context/spring-context-3.0.xsd"
default-lazy-init="true"> default-lazy-init="true">
<bean id="indexerConsumer" class="org.apache.archiva.consumers.lucene.NexusIndexerConsumer" lazy-init="true"> <context:annotation-config/>
<constructor-arg ref="archivaTaskScheduler#indexing"/> <context:component-scan base-package="org.apache.archiva.consumers.lucene"/>
<constructor-arg ref="archivaConfiguration"/>
<constructor-arg ref="fileTypes"/>
<constructor-arg ref="plexusSisuBridge"/>
<constructor-arg ref="mavenIndexerUtils"/>
</bean>
<bean id="logger" class="org.apache.archiva.common.utils.Slf4JPlexusLogger"> <alias name="knownRepositoryContentConsumer#index-content" alias="indexerConsumer"/>
<constructor-arg type="java.lang.Class"><value>org.sonatype.nexus.index.DefaultNexusIndexer</value></constructor-arg>
</bean> <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> </beans>

View File

@ -21,14 +21,14 @@ package org.apache.archiva.consumers.lucene;
import junit.framework.TestCase; import junit.framework.TestCase;
import org.apache.archiva.admin.model.beans.ManagedRepository; 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.MavenIndexerUtils;
import org.apache.archiva.common.plexusbridge.PlexusSisuBridge; 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.ArchivaTaskScheduler;
import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask; import org.apache.archiva.scheduler.indexing.ArtifactIndexingTask;
import org.apache.commons.io.FileUtils; 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.codehaus.plexus.taskqueue.TaskQueueException;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
@ -85,7 +85,7 @@ public class NexusIndexerConsumerTest
} }
} }
private KnownRepositoryContentConsumer nexusIndexerConsumer; private NexusIndexerConsumer nexusIndexerConsumer;
private ManagedRepository repositoryConfig; private ManagedRepository repositoryConfig;
@ -100,6 +100,9 @@ public class NexusIndexerConsumerTest
@Inject @Inject
private MavenIndexerUtils mavenIndexerUtils; private MavenIndexerUtils mavenIndexerUtils;
@Inject
private ManagedRepositoryAdmin managedRepositoryAdmin;
@Override @Override
@Before @Before
@ -115,7 +118,8 @@ public class NexusIndexerConsumerTest
FileTypes filetypes = applicationContext.getBean( FileTypes.class ); FileTypes filetypes = applicationContext.getBean( FileTypes.class );
nexusIndexerConsumer = 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 // initialize to set the file types to be processed
( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize(); ( (NexusIndexerConsumer) nexusIndexerConsumer ).initialize();

View File

@ -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;
}
}

View File

@ -59,4 +59,13 @@
<alias name="roleManager#test" alias="roleManager"/> <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> </beans>