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 testCryptPassword()
51          throws Exception
52      {
53          JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), null, null );
54          String actual = JazzScmCommand.cryptPassword( listCommand.getCommandline() );
55          String expected = Os.isFamily( Os.FAMILY_WINDOWS )
56              ? "cmd.exe /X /C \"scm list --repository-uri https://localhost:9443/jazz --username myUserName --password *****\""
57              : "/bin/sh -c scm list --repository-uri https://localhost:9443/jazz --username myUserName --password '*****'";
58  
59          System.out.println( "actual:" + actual );
60          assertEquals( "cryptPassword failed!", expected, actual );
61      }
62  }