001package org.apache.maven.scm.provider.jazz.command; 002 003import org.apache.maven.scm.ScmFileSet; 004import org.apache.maven.scm.provider.jazz.JazzScmTestCase; 005import org.codehaus.plexus.util.Os; 006import org.codehaus.plexus.util.cli.Commandline; 007 008/* 009 * Licensed to the Apache Software Foundation (ASF) under one 010 * or more contributor license agreements. See the NOTICE file 011 * distributed with this work for additional information 012 * regarding copyright ownership. The ASF licenses this file 013 * to you under the Apache License, Version 2.0 (the 014 * "License"); you may not use this file except in compliance 015 * with the License. You may obtain a copy of the License at 016 * 017 * http://www.apache.org/licenses/LICENSE-2.0 018 * 019 * Unless required by applicable law or agreed to in writing, 020 * software distributed under the License is distributed on an 021 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 022 * KIND, either express or implied. See the License for the 023 * specific language governing permissions and limitations 024 * under the License. 025 */ 026 027/** 028 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a> 029 */ 030public class JazzScmCommandTest 031 extends JazzScmTestCase 032{ 033 public void testFileList() 034 { 035 assertTrue( getScmFileSet().getFileList().size() > 0 ); 036 } 037 038 public void testJazzScmCommand() 039 throws Exception 040 { 041 ScmFileSet scmFileSet = new ScmFileSet( getWorkingCopy() ); 042 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), scmFileSet, null ); 043 String expected = 044 "scm list --repository-uri https://localhost:9443/jazz --username myUserName --password myPassword"; 045 046 assertCommandLine( expected, getWorkingDirectory(), listCommand.getCommandline() ); 047 048 } 049 050 public void testCryptPassword() 051 throws Exception 052 { 053 JazzScmCommand listCommand = new JazzScmCommand( "list", getScmProviderRepository(), null, null ); 054 String actual = JazzScmCommand.cryptPassword( listCommand.getCommandline() ); 055 String expected = Os.isFamily( Os.FAMILY_WINDOWS ) 056 ? "cmd.exe /X /C \"scm list --repository-uri https://localhost:9443/jazz --username myUserName --password *****\"" 057 : "/bin/sh -c scm list --repository-uri https://localhost:9443/jazz --username myUserName --password '*****'"; 058 059 System.out.println( "actual:" + actual ); 060 assertEquals( "cryptPassword failed!", expected, actual ); 061 } 062}