]> source.dussan.org Git - archiva.git/commitdiff
more usage of MockRepositorySessionFactory
authorOlivier Lamy <olamy@apache.org>
Thu, 1 Oct 2015 05:50:35 +0000 (15:50 +1000)
committerOlivier Lamy <olamy@apache.org>
Thu, 1 Oct 2015 05:50:35 +0000 (15:50 +1000)
archiva-modules/archiva-scheduler/archiva-scheduler-repository/pom.xml
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java [deleted file]
archiva-modules/archiva-scheduler/archiva-scheduler-repository/src/test/java/org/apache/archiva/scheduler/repository/ArchivaRepositoryScanningTaskExecutorAbstractTest.java

index e305eb0b58763581798dad176e7c62dbe809faa6..c501e3e46438baa11f64e5db19c8ed7ea1820246 100644 (file)
       <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>
           <artifactId>maven-surefire-plugin</artifactId>
           <configuration>
             <systemPropertyVariables>
-              <archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id>
+              <archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id>
             </systemPropertyVariables>
           </configuration>
         </plugin>
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 (file)
index def73a1..0000000
+++ /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;
-    }
-}
index 554287c83c504a131603e8dd20f034cf0e695d13..1698f078a8221dd656c64b937d50bfec26759bfd 100644 (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;