mirror of https://github.com/apache/archiva.git
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:
parent
c215c38616
commit
eeed38179f
|
@ -84,6 +84,22 @@
|
|||
<artifactId>archiva-repository-admin-default</artifactId>
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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>
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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>
|
Loading…
Reference in New Issue