From: Olivier Lamy Date: Thu, 1 Oct 2015 05:50:35 +0000 (+1000) Subject: more usage of MockRepositorySessionFactory X-Git-Tag: archiva-2.2.1~34 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=be4c847d961cc65fdf95a85bbd8049bb879a44f2;p=archiva.git more usage of MockRepositorySessionFactory --- diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml index e305eb0b5..c501e3e46 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml @@ -110,7 +110,12 @@ archiva-test-utils ${project.version} test - + + + org.apache.archiva + archiva-mock + test + org.mockito mockito-all @@ -176,7 +181,7 @@ maven-surefire-plugin - test + mock diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java deleted file mode 100644 index def73a181..000000000 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java +++ /dev/null @@ -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; - } -} diff --git a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java index 554287c83..1698f078a 100644 --- a/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java +++ b/archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java @@ -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;