more usage of MockRepositorySessionFactory

This commit is contained in:
Olivier Lamy 2015-10-01 15:50:35 +10:00
parent 87ff9f5d3d
commit be4c847d96
3 changed files with 13 additions and 56 deletions

View File

@ -110,7 +110,12 @@
<artifactId>archiva-test-utils</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
<artifactId>archiva-mock</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
@ -176,7 +181,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id>
<archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id>
</systemPropertyVariables>
</configuration>
</plugin>

View File

@ -1,46 +0,0 @@
package org.apache.archiva.metadata.repository;
import org.springframework.stereotype.Service;
/*
* 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;
@Override
public RepositorySession createSession()
{
return new RepositorySession( repository, resolver );
}
public void setRepository( MetadataRepository repository )
{
this.repository = repository;
}
public void setResolver( MetadataResolver resolver )
{
this.resolver = resolver;
}
}

View File

@ -23,13 +23,15 @@ import junit.framework.TestCase;
import org.apache.archiva.configuration.ArchivaConfiguration;
import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
import org.apache.archiva.metadata.repository.MetadataRepository;
import org.apache.archiva.metadata.repository.TestRepositorySessionFactory;
import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
import org.apache.archiva.mock.MockRepositorySessionFactory;
import org.apache.archiva.redback.components.taskqueue.execution.TaskExecutor;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import org.codehaus.plexus.util.FileUtils;
import org.junit.After;
import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import javax.inject.Inject;
@ -37,19 +39,15 @@ import javax.inject.Named;
import java.io.File;
import java.util.Calendar;
import java.util.List;
import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner;
import static org.mockito.Mockito.mock;
import org.springframework.test.annotation.DirtiesContext;
/**
* ArchivaRepositoryScanningTaskExecutorPhase1Test
*
*
*/
@RunWith( ArchivaSpringJUnit4ClassRunner.class )
@ContextConfiguration( locations = { "classpath*:/META-INF/spring-context.xml", "classpath:/spring-context.xml" } )
@DirtiesContext( classMode= DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
@DirtiesContext( classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD )
public abstract class ArchivaRepositoryScanningTaskExecutorAbstractTest
extends TestCase
{
@ -70,8 +68,8 @@ public abstract class ArchivaRepositoryScanningTaskExecutorAbstractTest
protected TestConsumer testConsumer;
@Inject
@Named( value = "repositorySessionFactory#test" )
private TestRepositorySessionFactory factory;
@Named( value = "repositorySessionFactory#mock" )
private MockRepositorySessionFactory factory;
protected File repoDir;