1 package org.apache.maven.scm.provider.starteam.command.checkin;
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.ScmFileSet;
23 import org.apache.maven.scm.ScmRevision;
24 import org.apache.maven.scm.ScmTestCase;
25 import org.apache.maven.scm.ScmVersion;
26 import org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils;
27 import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
28 import org.apache.maven.scm.repository.ScmRepository;
29 import org.codehaus.plexus.util.cli.Commandline;
30
31 import java.io.File;
32
33
34
35
36 public class StarteamCheckInCommandTest
37 extends ScmTestCase
38 {
39
40 public void testGetCommandLineWithWorkingDirectory()
41 throws Exception
42 {
43 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
44
45 String workingCopy = StarteamCommandLineUtils.toJavaPath( getWorkingCopy().getPath() );
46
47 String starteamUrl = "user:password@host:1234/project/view";
48 String mavenUrl = "scm:starteam:" + starteamUrl;
49
50 String expectedCmd =
51 "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + " -fp " + workingCopy + " -is -f NCI -eol on";
52
53 testCommandLine( mavenUrl, fileSet, "", new ScmRevision( "" ), "", "", expectedCmd );
54
55 }
56
57 public void testGetCommandLineWithFileOnRoot()
58 throws Exception
59 {
60 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( "test.txt" ) );
61
62 String workingCopy = StarteamCommandLineUtils.toJavaPath( getWorkingCopy().getPath() );
63
64 String starteamUrl = "user:password@host:1234/project/view";
65 String mavenUrl = "scm:starteam:" + starteamUrl;
66
67 String expectedCmd =
68 "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + " -fp " + workingCopy + " -eol on test.txt";
69
70 testCommandLine( mavenUrl, fileSet, "", new ScmRevision( "" ), "", "", expectedCmd );
71
72 }
73
74 public void testGetCommandLineWithFileInSubDir()
75 throws Exception
76 {
77 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( "src/test.txt" ) );
78
79 String workingCopy = StarteamCommandLineUtils.toJavaPath( getWorkingCopy().getPath() );
80
81 String starteamUrl = "user:password@host:1234/project/view";
82 String mavenUrl = "scm:starteam:" + starteamUrl;
83
84 String expectedCmd = "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + "/src" + " -fp " + workingCopy +
85 "/src" + " -eol on test.txt";
86
87 testCommandLine( mavenUrl, fileSet, "", new ScmRevision( "" ), "", "", expectedCmd );
88
89 }
90
91 public void testGetCommandLineWithDirInWorkingDirectory()
92 throws Exception
93 {
94
95 new File( getWorkingCopy(), "src" ).mkdirs();
96
97 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( "src" ) );
98
99 String workingCopy = StarteamCommandLineUtils.toJavaPath( getWorkingCopy().getPath() );
100
101 String starteamUrl = "user:password@host:1234/project/view";
102 String mavenUrl = "scm:starteam:" + starteamUrl;
103
104 String expectedCmd = "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + "/src" + " -fp " + workingCopy +
105 "/src" + " -is -f NCI -eol on";
106
107 testCommandLine( mavenUrl, fileSet, "", new ScmRevision( "" ), "", "", expectedCmd );
108
109 }
110
111 public void testGetCommandLineWithEmptyIssueValue()
112 throws Exception
113 {
114 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy(), new File( "test.txt" ) );
115
116 String workingCopy = StarteamCommandLineUtils.toJavaPath( getWorkingCopy().getPath() );
117
118 String starteamUrl = "user:password@host:1234/project/view";
119 String mavenUrl = "scm:starteam:" + starteamUrl;
120
121 String expectedCmd =
122 "stcmd ci -x -nologo -stop" + " -p " + starteamUrl + " -fp " + workingCopy + " -active -eol on test.txt";
123
124 testCommandLine( mavenUrl, fileSet, null, new ScmRevision( "" ), "active", " ", expectedCmd );
125 }
126
127
128
129
130 private void testCommandLine( String scmUrl, ScmFileSet fileSet, String message, ScmVersion version,
131 String issueType, String issueValue, String commandLine )
132 throws Exception
133 {
134 ScmRepository repo = getScmManager().makeScmRepository( scmUrl );
135
136 StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
137
138 Commandline cl =
139 StarteamCheckInCommand.createCommandLine( repository, fileSet, message, version, issueType, issueValue );
140
141 assertCommandLine( commandLine, null, cl );
142 }
143
144
145 }