View Javadoc
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    * Licensed to the Apache Software Foundation (ASF) under one
10   * or more contributor license agreements.  See the NOTICE file
11   * distributed with this work for additional information
12   * regarding copyright ownership.  The ASF licenses this file
13   * to you under the Apache License, Version 2.0 (the
14   * "License"); you may not use this file except in compliance
15   * with the License.  You may obtain a copy of the License at
16   *
17   * http://www.apache.org/licenses/LICENSE-2.0
18   *
19   * Unless required by applicable law or agreed to in writing,
20   * software distributed under the License is distributed on an
21   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22   * KIND, either express or implied.  See the License for the
23   * specific language governing permissions and limitations
24   * under the License.
25   */
26  
27  /**
28   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
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  }