View Javadoc

1   package org.apache.continuum.scm.manager;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.util.Properties;
23  
24  import org.apache.maven.scm.manager.NoSuchScmProviderException;
25  import org.apache.maven.scm.provider.ScmProvider;
26  import org.apache.maven.scm.provider.cvslib.cvsexe.CvsExeScmProvider;
27  import org.apache.maven.scm.provider.cvslib.cvsjava.CvsJavaScmProvider;
28  import org.codehaus.plexus.spring.PlexusClassPathXmlApplicationContext;
29  import org.slf4j.Logger;
30  import org.slf4j.LoggerFactory;
31  import org.springframework.context.ApplicationContext;
32  
33  import junit.framework.TestCase;
34  
35  /**
36   * @version $Id: ScmManagerTest.java 765340 2009-04-15 20:22:00Z evenisse $
37   * @todo replace with a spring integration test
38   */
39  public class ScmManagerTest
40      extends TestCase
41  {
42      private static final Logger log = LoggerFactory.getLogger( ScmManagerTest.class );
43  
44      private ScmManager manager;
45  
46      public void setUp()
47      {
48          ApplicationContext context = new PlexusClassPathXmlApplicationContext(
49              new String[]{"classpath*:META-INF/spring-context.xml", "classpath*:META-INF/plexus/components.xml",
50                  "classpath*:" + getClass().getName().replace( '.', '/' ) + ".xml"} );
51          manager = (ScmManager) context.getBean( "scmManager" );
52      }
53  
54      public void testScmProviders()
55          throws NoSuchScmProviderException
56      {
57          Properties backupSysProps = System.getProperties();
58  
59          try
60          {
61              manager.getScmLogger().info( "Hello, World" );
62              assertNotNull( manager.getProviderByType( "svn" ) );
63  
64              ScmProvider cvsProvider = manager.getProviderByType( "cvs" );
65              assertNotNull( cvsProvider );
66  
67              log.info( "cvs provider class " + cvsProvider.getClass().getName() );
68  
69              assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
70  
71              System.setProperty( "maven.scm.provider.cvs.implementation", "cvs_native" );
72  
73              cvsProvider = manager.getProviderByType( "cvs" );
74              assertNotNull( cvsProvider );
75  
76              log.info( "cvs provider class " + cvsProvider.getClass().getName() );
77              assertEquals( CvsExeScmProvider.class, cvsProvider.getClass() );
78              System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
79  
80              cvsProvider = manager.getProviderByType( "cvs" );
81              assertNotNull( cvsProvider );
82  
83              log.info( "cvs provider class " + cvsProvider.getClass().getName() );
84  
85              assertEquals( CvsJavaScmProvider.class, cvsProvider.getClass() );
86          }
87          finally
88          {
89              System.setProperties( backupSysProps );
90              System.setProperty( "maven.scm.provider.cvs.implementation", "cvs" );
91          }
92  
93      }
94  }