View Javadoc

1   package org.apache.continuum.scm;
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 junit.framework.TestCase;
23  import org.apache.continuum.scm.manager.ScmManager;
24  import org.apache.maven.scm.ScmBranch;
25  import org.apache.maven.scm.ScmFileSet;
26  import org.apache.maven.scm.ScmVersion;
27  import org.apache.maven.scm.repository.ScmRepository;
28  import org.jmock.Expectations;
29  import org.jmock.Mockery;
30  import org.jmock.integration.junit3.JUnit3Mockery;
31  import org.jmock.lib.legacy.ClassImposteriser;
32  
33  import java.io.File;
34  import java.util.Date;
35  
36  public class DefaultContinuumScmTest
37      extends TestCase
38  {
39      private ScmManager scmManager;
40  
41      private DefaultContinuumScm continuumScm;
42  
43      private Mockery context;
44  
45      private ContinuumScmConfiguration config;
46  
47      @Override
48      public void setUp()
49      {
50          context = new JUnit3Mockery();
51          context.setImposteriser( ClassImposteriser.INSTANCE );
52  
53          scmManager = context.mock( ScmManager.class );
54  
55          continuumScm = new DefaultContinuumScm();
56          continuumScm.setScmManager( scmManager );
57  
58          config = getScmConfiguration();
59      }
60  
61      public void testChangeLogWithScmVersion()
62          throws Exception
63      {
64          config.setTag( "1.0-SNAPSHOT" );
65  
66          context.checking( new Expectations()
67          {
68              {
69                  one( scmManager ).makeScmRepository( config.getUrl() );
70                  one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any( ScmFileSet.class ) ), with(
71                      any( ScmVersion.class ) ), with( any( ScmVersion.class ) ) );
72              }
73          } );
74  
75          continuumScm.changeLog( config );
76  
77          context.assertIsSatisfied();
78      }
79  
80      public void testChangeLogWithNoScmVersion()
81          throws Exception
82      {
83          config.setTag( "" );
84  
85          context.checking( new Expectations()
86          {
87              {
88                  one( scmManager ).makeScmRepository( config.getUrl() );
89                  one( scmManager ).changeLog( with( any( ScmRepository.class ) ), with( any( ScmFileSet.class ) ), with(
90                      any( Date.class ) ), with( aNull( Date.class ) ), with( equal( 0 ) ), with( aNull(
91                      ScmBranch.class ) ), with( aNull( String.class ) ) );
92              }
93          } );
94  
95          continuumScm.changeLog( config );
96          context.assertIsSatisfied();
97      }
98  
99      private ContinuumScmConfiguration getScmConfiguration()
100     {
101         ContinuumScmConfiguration config = new ContinuumScmConfiguration();
102         config.setWorkingDirectory( new File( "1" ) );
103         config.setUrl( "scm:svn:http://svn.apache.org/repos/asf/maven/plugins/trunk/maven-clean-plugin" );
104 
105         return config;
106     }
107 }