From e278aa78c5fd394fcaf1b79666714f2cd20a4b7e Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Mon, 31 Mar 2014 01:30:34 +0000 Subject: [PATCH] more unit tests fixes git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1583230 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-consumer-archetype/pom.xml | 4 +- .../archetype-resources/pom.xml | 6 +-- .../archiva-web/archiva-web-common/pom.xml | 1 + .../TestRepositorySessionFactoryBean.java | 42 +++++++++++++++++++ .../memory/TestRepositorySessionFactory.java | 15 +++++++ .../resources/spring-context-rss-servlet.xml | 6 +++ .../resources/spring-context-with-jcr.xml | 6 +++ .../RepositorySessionFactoryBean.java | 2 + pom.xml | 2 +- 9 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/TestRepositorySessionFactoryBean.java diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml index b22d435e1..149249cbc 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/pom.xml @@ -84,8 +84,8 @@ - src/test/resources - true + src/test/resources + true diff --git a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml index 7cbec0b59..fcaa4b370 100644 --- a/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml +++ b/archiva-modules/archiva-base/archiva-consumers/archiva-consumer-archetype/src/main/resourcesstatic/archetype-resources/pom.xml @@ -71,13 +71,13 @@ org.easymock easymock - 2.5.2 + 3.2 test junit junit - 4.9 + 4.11 test @@ -218,7 +218,7 @@ xerces xercesImpl - 2.8.1 + 2.11.0 org.apache.derby diff --git a/archiva-modules/archiva-web/archiva-web-common/pom.xml b/archiva-modules/archiva-web/archiva-web-common/pom.xml index fc8b47303..fbedf6192 100644 --- a/archiva-modules/archiva-web/archiva-web-common/pom.xml +++ b/archiva-modules/archiva-web/archiva-web-common/pom.xml @@ -526,6 +526,7 @@ ${project.version} true true + test diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/TestRepositorySessionFactoryBean.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/TestRepositorySessionFactoryBean.java new file mode 100644 index 000000000..eecb8e2af --- /dev/null +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/TestRepositorySessionFactoryBean.java @@ -0,0 +1,42 @@ +package org.apache.archiva; + +import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.apache.archiva.metadata.repository.RepositorySessionFactoryBean; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Properties; + +/** + * @author Olivier Lamy + */ +public class TestRepositorySessionFactoryBean + extends RepositorySessionFactoryBean +{ + + private Logger logger = LoggerFactory.getLogger( getClass() ); + + private String beanId; + + public TestRepositorySessionFactoryBean( String beanId ) + { + super( new Properties( ) ); + this.beanId = beanId; + } + + @Override + public Class getObjectType() + { + return RepositorySessionFactory.class; + } + + @Override + protected RepositorySessionFactory createInstance() + throws Exception + { + RepositorySessionFactory repositorySessionFactory = + getBeanFactory().getBean( "repositorySessionFactory#" + this.beanId, RepositorySessionFactory.class ); + logger.info( "create RepositorySessionFactory instance of {}", repositorySessionFactory.getClass().getName() ); + return repositorySessionFactory; + } +} diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java index f311d97d3..ff159f47c 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/java/org/apache/archiva/webtest/memory/TestRepositorySessionFactory.java @@ -21,10 +21,12 @@ package org.apache.archiva.webtest.memory; import org.apache.archiva.metadata.repository.RepositorySession; import org.apache.archiva.metadata.repository.RepositorySessionFactory; +import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.stereotype.Service; @Service("repositorySessionFactory#test") public class TestRepositorySessionFactory + extends AbstractFactoryBean implements RepositorySessionFactory { private RepositorySession repositorySession; @@ -39,4 +41,17 @@ public class TestRepositorySessionFactory return repositorySession != null ? repositorySession : new RepositorySession( new TestMetadataRepository(), new TestMetadataResolver() ); } + + @Override + public Class getObjectType() + { + return RepositorySessionFactory.class; + } + + @Override + protected RepositorySessionFactory createInstance() + throws Exception + { + return this; + } } diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml index 594a727f2..5f9f77153 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-rss-servlet.xml @@ -49,6 +49,12 @@ + + + jcr + + + diff --git a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml index 975b0dcca..c9ff7946c 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml +++ b/archiva-modules/archiva-web/archiva-web-common/src/test/resources/spring-context-with-jcr.xml @@ -38,6 +38,12 @@ + + + jcr + + + 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 e182104f1..5a5c4857f 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,6 +22,7 @@ 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; @@ -29,6 +30,7 @@ import java.util.Properties; * @author Olivier Lamy * @since 2.0.2 */ +//@Service("repositorySessionFactoryBean#default") public class RepositorySessionFactoryBean extends AbstractFactoryBean { diff --git a/pom.xml b/pom.xml index d44691747..1634899dd 100644 --- a/pom.xml +++ b/pom.xml @@ -76,7 +76,7 @@ 1.7.5 2.0-rc1 - 4.0.2.RELEASE + 4.0.3.RELEASE 2.0 UTF-8 -- 2.39.5