continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r658026 - in /continuum/trunk/continuum-base/continuum-scm: ./ src/main/java/org/apache/continuum/scm/manager/ src/main/java/org/apache/continuum/scm/manager/spring/ src/test/java/org/apache/continuum/scm/manager/ src/test/resources/
Date Mon, 19 May 2008 23:01:16 GMT
Author: olamy
Date: Mon May 19 16:01:16 2008
New Revision: 658026

URL: http://svn.apache.org/viewvc?rev=658026&view=rev
Log:
fix current trunk.
ScmProviderFactoryBean was throwing an Exception due to the two implementations of the cvs
provider (java and native).


Added:
    continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml   (with props)
Modified:
    continuum/trunk/continuum-base/continuum-scm/pom.xml
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
    continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java
    continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java

Modified: continuum/trunk/continuum-base/continuum-scm/pom.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/pom.xml?rev=658026&r1=658025&r2=658026&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/pom.xml (original)
+++ continuum/trunk/continuum-base/continuum-scm/pom.xml Mon May 19 16:01:16 2008
@@ -30,7 +30,6 @@
     <dependency>
       <groupId>org.codehaus.plexus</groupId>
       <artifactId>plexus-spring</artifactId>
-      <scope>test</scope>
     </dependency>    
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -45,6 +44,18 @@
       <scope>test</scope>
     </dependency>
     <dependency>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-provider-cvsjava</artifactId>
+      <version>${maven-scm.version}</version>
+      <scope>test</scope>      
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-provider-cvsexe</artifactId>
+      <version>${maven-scm.version}</version>
+      <scope>test</scope>      
+    </dependency>    
+    <dependency>
       <groupId>commons-io</groupId>
       <artifactId>commons-io</artifactId>
       <version>1.4</version>

Modified: continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java?rev=658026&r1=658025&r2=658026&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/ScmManager.java
Mon May 19 16:01:16 2008
@@ -23,7 +23,6 @@
 
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.manager.AbstractScmManager;
-import org.apache.maven.scm.provider.ScmProvider;
 
 /**
  * Default implementation of the SCM manager.

Modified: continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java?rev=658026&r1=658025&r2=658026&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/main/java/org/apache/continuum/scm/manager/spring/ScmProviderFactoryBean.java
Mon May 19 16:01:16 2008
@@ -4,6 +4,9 @@
 import java.util.Map;
 
 import org.apache.maven.scm.provider.ScmProvider;
+import org.codehaus.plexus.spring.PlexusToSpringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
 import org.springframework.beans.factory.BeanFactoryUtils;
 import org.springframework.beans.factory.BeanInitializationException;
@@ -26,15 +29,25 @@
     implements FactoryBean, ApplicationContextAware
 {
     private ApplicationContext applicationContext;
-
+   
+    /**
+     * FIXME : change how we find scm implementations 
+     * @see org.springframework.beans.factory.FactoryBean#getObject()
+     */
     public Object getObject()
         throws Exception
     {
         Map<String, ScmProvider> providers = new HashMap<String, ScmProvider>();
-        Map<String, ScmProvider> beans =
+        /*
+         olamy : comment the pure spring use because we have a duplicate between cvs java
and cvs native
+          
+         Map<String, ScmProvider> beans =
             BeanFactoryUtils.beansOfTypeIncludingAncestors( applicationContext, ScmProvider.class
);
+        
+       
         for ( ScmProvider provider : beans.values() )
         {
+            
             if ( providers.containsKey( provider.getScmType() ) )
             {
                 throw new BeanInitializationException(
@@ -42,8 +55,14 @@
                                                            provider.getScmType() +
                                                            ". Probably two conflicting scm
implementations are present in the classpath." );
             }
+            
+            if (log.isDebugEnabled())
+            {
+                log.debug( "put provider with type " + provider.getScmType() + " and class
" + provider.getClass().getName() );
+            }
             providers.put( provider.getScmType(), provider );
-        }
+        }*/
+        providers =  PlexusToSpringUtils.lookupMap(PlexusToSpringUtils.buildSpringId( ScmProvider.class
), applicationContext );
         return providers;
     }
 

Modified: continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java?rev=658026&r1=658025&r2=658026&view=diff
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java
(original)
+++ continuum/trunk/continuum-base/continuum-scm/src/test/java/org/apache/continuum/scm/manager/ScmManagerTest.java
Mon May 19 16:01:16 2008
@@ -19,10 +19,17 @@
  * under the License.
  */
 
+import java.util.Properties;
+
 import junit.framework.TestCase;
 
 import org.apache.maven.scm.manager.NoSuchScmProviderException;
+import org.apache.maven.scm.provider.ScmProvider;
+import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
+import org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider;
 import org.codehaus.plexus.spring.PlexusClassPathXmlApplicationContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.context.ApplicationContext;
 
 /**
@@ -34,6 +41,8 @@
     private ApplicationContext context;
 
     private ScmManager manager;
+    
+    private Logger log = LoggerFactory.getLogger( getClass() );
 
     public void setUp()
     {
@@ -47,7 +56,41 @@
     public void testScmProviders()
         throws NoSuchScmProviderException
     {
-        manager.getScmLogger().info( "Hello, World" );
-        assertNotNull( manager.getProviderByType( "svn" ) );
+        Properties backupSysProps = System.getProperties();
+
+        try
+        {
+            manager.getScmLogger().info( "Hello, World" );
+            assertNotNull( manager.getProviderByType( "svn" ) );
+
+            ScmProvider cvsProvider = manager.getProviderByType( "cvs" );
+            assertNotNull( cvsProvider );
+
+            log.info( "cvs provider class " + cvsProvider.getClass().getName() );
+
+            assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
+
+            System.setProperty( "maven.scm.provider.cvs.implementation", "cvs_native" );
+
+            cvsProvider = manager.getProviderByType( "cvs" );
+            assertNotNull( cvsProvider );
+
+            log.info( "cvs provider class " + cvsProvider.getClass().getName() );
+            assertEquals( CvsExeScmProvider.class, cvsProvider.getClass() );
+            System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
+
+            cvsProvider = manager.getProviderByType( "cvs" );
+            assertNotNull( cvsProvider );
+
+            log.info( "cvs provider class " + cvsProvider.getClass().getName() );
+
+            assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
+        }
+        finally
+        {
+            System.setProperties( backupSysProps );
+            System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
+        }
+        
     }
 }

Added: continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml?rev=658026&view=auto
==============================================================================
--- continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml (added)
+++ continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml Mon May 19 16:01:16
2008
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
+<!-- ===================================================================== -->
+<!-- Log4j Configuration -->
+<!-- ===================================================================== -->
+
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/"
+  debug="false">
+
+    <appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
+        <param name="Target" value="System.out"/>
+        <layout class="org.apache.log4j.PatternLayout">
+            <param name="ConversionPattern" value="%d{ABSOLUTE} %-5p [%c{1}.%M](%L) %m%n"/>
+        </layout>
+    </appender>
+
+    <!-- quiet spring loading :-) -->
+    <category name="org.springframework.beans.factory.xml.XmlBeanDefinitionReader">
+        <priority value="ERROR"/>
+    </category>
+    <category name="org.springframework.beans.factory.support.DefaultListableBeanFactory">
+        <priority value="ERROR"/>
+    </category>
+
+    <!-- JPOX -->
+    <category name="JPOX">
+        <priority value="WARN"/>
+    </category>
+    <category name="JPOX.RDBMS">
+        <priority value="ERROR"/>
+    </category>
+
+    <root>
+        <priority value="WARN"/>
+        <appender-ref ref="CONSOLE"/>
+    </root>
+
+</log4j:configuration>
\ No newline at end of file

Propchange: continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:executable = *

Propchange: continuum/trunk/continuum-base/continuum-scm/src/test/resources/log4j.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message