1 package org.apache.maven.scm.provider.starteam.command.add;
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.ScmTestCase;
24 import org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils;
25 import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
26 import org.apache.maven.scm.repository.ScmRepository;
27 import org.codehaus.plexus.util.cli.Commandline;
28
29 import java.io.File;
30
31
32
33
34 public class StarteamAddCommandTest
35 extends ScmTestCase
36 {
37
38 public void testGetCommandLineWithFileOnRoot()
39 throws Exception
40 {
41
42 File testFile = new File( "testfile" );
43
44 File testFileDir = testFile.getAbsoluteFile().getParentFile();
45
46 String testFileDirAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFileDir.getAbsolutePath() );
47
48 String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl" + " -fp " +
49 testFileDirAbsolutePath + " -eol on testfile";
50
51 ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
52 testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "", expectedCmd );
53 }
54
55 public void testGetCommandLineWithCR()
56 throws Exception
57 {
58 File testFile = new File( "testfile" );
59
60 File testFileDir = testFile.getAbsoluteFile().getParentFile();
61
62 String testFileDirAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFileDir.getAbsolutePath() );
63
64 String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl" + " -fp " +
65 testFileDirAbsolutePath + " -cr view_root/dummycr" + " -eol on testfile";
66
67 ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
68 testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "view_root/dummycr",
69 expectedCmd );
70
71 }
72
73 public void testGetCommandLineWithFileInSubDir()
74 throws Exception
75 {
76
77 File testFile = new File( "target/testfile" );
78
79 File testFileDir = testFile.getAbsoluteFile().getParentFile();
80
81 String testFileDirAbsolutePath =
82 StarteamCommandLineUtils.toJavaPath( testFileDir.getAbsolutePath() ) + "/target";
83
84 String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl/target" +
85 " -fp " + testFileDirAbsolutePath + " -eol on testfile";
86
87 ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
88 testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, null, expectedCmd );
89
90 }
91
92
93
94
95
96 private void testCommandLine( String scmUrl, ScmFileSet fileSet, String crPath, String commandLine )
97 throws Exception
98 {
99 ScmRepository repo = getScmManager().makeScmRepository( scmUrl );
100
101 StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
102
103 Commandline cl = StarteamAddCommand.createCommandLine( repository, fileSet, crPath );
104
105 assertCommandLine( commandLine, null, cl );
106 }
107 }