1 package org.apache.maven.scm.provider.cvslib.command.changelog;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.ScmTestCase;
23 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
24 import org.apache.maven.scm.command.changelog.ChangeLogSet;
25 import org.apache.maven.scm.manager.ScmManager;
26 import org.apache.maven.scm.provider.cvslib.AbstractCvsScmTest;
27 import org.apache.maven.scm.provider.cvslib.CvsScmTestUtils;
28
29 import java.util.Date;
30
31
32
33
34
35
36 public class CvsChangeLogCommandTest
37 extends AbstractCvsScmTest
38 {
39
40 protected String getModule()
41 {
42 return "test-repo/changelog";
43 }
44
45 public void testGetCommandWithStartAndEndDate()
46 throws Exception
47 {
48 Date startDate = getDate( 2003, 1, 1 );
49
50 Date endDate = getDate( 2004, 1, 1 );
51
52 testChangeLog( startDate, endDate, 32, null );
53 }
54
55 public void testGetCommandWithoutEndDate()
56 throws Exception
57 {
58 Date startDate = getDate( 2003, 1, 1 );
59
60 Date endDate = null;
61
62 testChangeLog( startDate, endDate, 51, null );
63 }
64
65 public void testGetCommandWithBranchOrTag()
66 throws Exception
67 {
68 Date startDate = null;
69
70 Date endDate = null;
71
72 testChangeLog( startDate, endDate, 22, "1.107.4" );
73 }
74
75 @SuppressWarnings( "deprecation" )
76 private void testChangeLog( Date startDate, Date endDate, int changeLogSize, String branch )
77 throws Exception
78 {
79 if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) )
80 {
81 ScmTestCase.printSystemCmdUnavail( CvsScmTestUtils.CVS_COMMAND_LINE, getName() );
82 return;
83 }
84
85 ScmManager scmManager = getScmManager();
86
87 CvsScmTestUtils.executeCVS( getWorkingDirectory(),
88 "-f -d " + getTestFile( "src/test/repository/" ) + " co " + getModule() );
89
90 ChangeLogScmResult changeLogResult = scmManager.getProviderByRepository( getScmRepository() ).changeLog(
91 getScmRepository(), getScmFileSet(), startDate, endDate, 0, branch );
92
93 if ( !changeLogResult.isSuccess() )
94 {
95 fail( changeLogResult.getProviderMessage() + "\n" + changeLogResult.getCommandOutput() );
96 }
97
98 ChangeLogSet changeLogSet = changeLogResult.getChangeLog();
99
100 assertNotNull( changeLogSet );
101
102 assertEquals( changeLogSize, changeLogSet.getChangeSets().size() );
103 }
104 }