1 package org.apache.continuum.scm;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }