1 package org.apache.maven.scm.provider.clearcase.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.ScmBranch;
23 import org.apache.maven.scm.ScmTestCase;
24 import org.apache.maven.scm.provider.clearcase.util.ClearCaseUtil;
25 import org.codehaus.plexus.util.cli.Commandline;
26
27 import java.io.File;
28 import java.util.Date;
29
30
31
32
33
34
35
36 public class ClearCaseChangeLogCommandTest
37 extends ScmTestCase
38 {
39 public void testGetCommandLine()
40 throws Exception
41 {
42 Date startDate = null;
43
44 Date endDate = null;
45
46 testCommandLine( null, startDate, endDate,
47 "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco" );
48 }
49
50 public void testGetCommandLineWithUserPattern()
51 throws Exception
52 {
53 ClearCaseUtil.setSettingsDirectory( getTestFile( "src/test/resources/clearcase/changelog" ) );
54
55 Date startDate = null;
56
57 Date endDate = null;
58
59 testCommandLine( null, startDate, endDate,
60 "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\nREVI:%Ln\\n\" -recurse -nco" );
61
62 ClearCaseUtil.setSettingsDirectory( ClearCaseUtil.DEFAULT_SETTINGS_DIRECTORY );
63 }
64
65 public void testGetCommandLineWithTag()
66 throws Exception
67 {
68 Date startDate = null;
69
70 Date endDate = null;
71
72 testCommandLine( new ScmBranch( "myBranch" ), startDate, endDate,
73 "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -branch myBranch" );
74 }
75
76 public void testGetCommandLineWithStartDate()
77 throws Exception
78 {
79 Date startDate = getDate( 2003, 8, 10 );
80
81 Date endDate = null;
82
83 testCommandLine( null, startDate, endDate,
84 "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -since 10-Sep-2003" );
85 }
86
87 public void testGetCommandLineWithTagAndStartDate()
88 throws Exception
89 {
90 Date startDate = getDate( 2003, 8, 10 );
91
92 Date endDate = null;
93
94 testCommandLine( new ScmBranch( "myBranch" ), startDate, endDate,
95 "cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%u\\nREVI:%Ln\\n\" -recurse -nco -since 10-Sep-2003 -branch myBranch" );
96 }
97
98
99
100
101
102 private void testCommandLine( ScmBranch branch, Date startDate, Date endDate, String commandLine )
103 throws Exception
104 {
105 File workingDirectory = getTestFile( "target/clearcare-changelog-command-test" );
106
107 Commandline cl = ClearCaseChangeLogCommand.createCommandLine( workingDirectory, branch, startDate );
108 assertCommandLine( commandLine, workingDirectory, cl );
109 }
110 }