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