1 package org.apache.maven.scm.provider.jazz.command;
2
3 import org.apache.maven.scm.ScmFileSet;
4 import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
5 import org.codehaus.plexus.util.Os;
6 import org.codehaus.plexus.util.cli.Commandline;
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class JazzScmCommandTest
31 extends JazzScmTestCase
32 {
33 public void testFileList()
34 {
35 assertTrue( getScmFileSet().getFileList().size() > 0 );
36 }
37
38 public void testJazzScmCommand()
39 throws Exception
40 {
41 ScmFileSet scmFileSet = new ScmFileSet( getWorkingCopy() );
42 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), scmFileSet, null );
43 String expected =
44 "scm list --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword";
45
46 assertCommandLine( expected, getWorkingDirectory(), listCommand.getCommandline() );
47
48 }
49
50 public void testJazzScmCommandWithExtraArg()
51 throws Exception
52 {
53 ScmFileSet scmFileSet = new ScmFileSet( getWorkingCopy() );
54 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), scmFileSet, null );
55 listCommand.addArgument( "ExtraArg" );
56 String expected =
57 "scm list --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword ExtraArg";
58
59 assertCommandLine( expected, getWorkingDirectory(), listCommand.getCommandline() );
60
61 }
62
63 public void testCryptPassword()
64 throws Exception
65 {
66 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), null, null );
67 String actual = JazzScmCommand.cryptPassword( listCommand.getCommandline() );
68 String expected = Os.isFamily( Os.FAMILY_WINDOWS )
69 ? "cmd.exe /X /C \"scm list --repository-uri https://localhost:9443/jazz --username myUserName --password *****\""
70 : "/bin/sh -c scm list --repository-uri https://localhost:9443/jazz --username myUserName --password '*****'";
71
72 assertEquals( "cryptPassword failed!", expected, actual );
73 }
74
75 public void testCryptPasswordWithExtraArg()
76 throws Exception
77 {
78 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), null, null );
79 listCommand.addArgument( "ExtraArg" );
80 String actual = JazzScmCommand.cryptPassword( listCommand.getCommandline() );
81 String expected = Os.isFamily( Os.FAMILY_WINDOWS )
82 ? "cmd.exe /X /C \"scm list --repository-uri https://localhost:9443/jazz --username myUserName --password ***** ExtraArg\""
83 : "/bin/sh -c scm list --repository-uri https://localhost:9443/jazz --username myUserName --password '*****' ExtraArg";
84
85 assertEquals( "cryptPassword failed!", expected, actual );
86 }
87 }