aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Lamy <olamy@apache.org>2015-10-01 15:39:41 +1000
committerOlivier Lamy <olamy@apache.org>2015-10-01 15:39:41 +1000
commit87ff9f5d3dc1ca0b921764a9412dcbdc8776f466 (patch)
tree2841674f1f91cf77eed307e515de9a01dbb66642
parent56f8b575d44045d6be9960e8608946a05eaea98b (diff)
downloadarchiva-87ff9f5d3dc1ca0b921764a9412dcbdc8776f466.tar.gz
archiva-87ff9f5d3dc1ca0b921764a9412dcbdc8776f466.zip
more usage of MockRepositorySessionFactory
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml7
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java4
-rw-r--r--archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java53
-rw-r--r--archiva-modules/archiva-base/archiva-mock/src/main/java/org/apache/archiva/mock/MockRepositorySessionFactory.java15
-rw-r--r--archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java6
5 files changed, 22 insertions, 63 deletions
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
index 8c12f3fc3..44ac0a51f 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/pom.xml
@@ -150,6 +150,11 @@
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>archiva-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<build>
<pluginManagement>
@@ -165,7 +170,7 @@
<redback.jdbc.url>${redbackTestJdbcUrl}</redback.jdbc.url>
<redback.jdbc.driver.name>${redbackTestJdbcDriver}</redback.jdbc.driver.name>
<archiva.user.configFileName>${project.build.directory}/archiva.xml</archiva.user.configFileName>
- <archiva.repositorySessionFactory.id>test</archiva.repositorySessionFactory.id>
+ <archiva.repositorySessionFactory.id>mock</archiva.repositorySessionFactory.id>
</systemPropertyVariables>
</configuration>
</plugin>
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
index 30f4df99c..74e4631e3 100644
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
+++ b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/consumers/core/repository/RepositoryPurgeConsumerTest.java
@@ -30,7 +30,7 @@ import org.apache.archiva.configuration.FileType;
import org.apache.archiva.configuration.FileTypes;
import org.apache.archiva.consumers.KnownRepositoryContentConsumer;
import org.apache.archiva.consumers.functors.ConsumerWantsFilePredicate;
-import org.apache.archiva.metadata.repository.TestRepositorySessionFactory;
+import org.apache.archiva.mock.MockRepositorySessionFactory;
import org.apache.commons.io.FileUtils;
import org.custommonkey.xmlunit.XMLAssert;
import org.junit.After;
@@ -58,7 +58,7 @@ public class RepositoryPurgeConsumerTest
{
super.setUp();
- TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
+ MockRepositorySessionFactory factory = applicationContext.getBean( MockRepositorySessionFactory.class );
factory.setRepository( metadataRepository );
}
diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java
deleted file mode 100644
index 95abe0fa2..000000000
--- a/archiva-modules/archiva-base/archiva-consumers/archiva-core-consumers/src/test/java/org/apache/archiva/metadata/repository/TestRepositorySessionFactory.java
+++ /dev/null
@@ -1,53 +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 = new AbstractMetadataRepository() {};
-
- private MetadataResolver resolver;
-
- @Override
- public RepositorySession createSession()
- {
- return new RepositorySession( repository, resolver )
- {
- @Override
- public void close()
- {
- return;
- }
- };
- }
-
- public void setRepository( MetadataRepository repository )
- {
- this.repository = repository;
- }
-
- public void setResolver( MetadataResolver resolver )
- {
- this.resolver = resolver;
- }
-}
diff --git a/archiva-modules/archiva-base/archiva-mock/src/main/java/org/apache/archiva/mock/MockRepositorySessionFactory.java b/archiva-modules/archiva-base/archiva-mock/src/main/java/org/apache/archiva/mock/MockRepositorySessionFactory.java
index 303d2e08a..319942ba4 100644
--- a/archiva-modules/archiva-base/archiva-mock/src/main/java/org/apache/archiva/mock/MockRepositorySessionFactory.java
+++ b/archiva-modules/archiva-base/archiva-mock/src/main/java/org/apache/archiva/mock/MockRepositorySessionFactory.java
@@ -32,10 +32,19 @@ import org.springframework.stereotype.Service;
public class MockRepositorySessionFactory
implements RepositorySessionFactory
{
+ private MetadataRepository repository = new AbstractMetadataRepository()
+ {
+ };
+
+ public void setRepository( MetadataRepository repository )
+ {
+ this.repository = repository;
+ }
+
@Override
public RepositorySession createSession()
{
- return new RepositorySession( null, null )
+ return new RepositorySession( repository, null )
{
@Override
public void close()
@@ -52,9 +61,7 @@ public class MockRepositorySessionFactory
@Override
public MetadataRepository getRepository()
{
- return new AbstractMetadataRepository()
- {
- };
+ return repository;
}
};
}
diff --git a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java
index 5a5c4857f..3312a3cfb 100644
--- a/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java
+++ b/archiva-modules/metadata/metadata-repository-api/src/main/java/org/apache/archiva/metadata/repository/RepositorySessionFactoryBean.java
@@ -22,7 +22,6 @@ package org.apache.archiva.metadata.repository;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.config.AbstractFactoryBean;
-import org.springframework.stereotype.Service;
import java.util.Properties;
@@ -30,7 +29,6 @@ import java.util.Properties;
* @author Olivier Lamy
* @since 2.0.2
*/
-//@Service("repositorySessionFactoryBean#default")
public class RepositorySessionFactoryBean
extends AbstractFactoryBean<RepositorySessionFactory>
{
@@ -67,7 +65,9 @@ public class RepositorySessionFactoryBean
{
RepositorySessionFactory repositorySessionFactory =
getBeanFactory().getBean( "repositorySessionFactory#" + id, RepositorySessionFactory.class );
- logger.info( "create RepositorySessionFactory instance of {}", repositorySessionFactory.getClass().getName() );
+ logger.info( "create RepositorySessionFactory with id {} instance of {}", //
+ id, //
+ repositorySessionFactory.getClass().getName() );
return repositorySessionFactory;
}