001package org.apache.maven.scm.provider.tfs.command;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one
005 * or more contributor license agreements.  See the NOTICE file
006 * distributed with this work for additional information
007 * regarding copyright ownership.  The ASF licenses this file
008 * to you under the Apache License, Version 2.0 (the
009 * "License"); you may not use this file except in compliance
010 * with the License.  You may obtain a copy of the License at
011 *
012 * http://www.apache.org/licenses/LICENSE-2.0
013 *
014 * Unless required by applicable law or agreed to in writing,
015 * software distributed under the License is distributed on an
016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017 * KIND, either express or implied.  See the License for the
018 * specific language governing permissions and limitations
019 * under the License.
020 */
021
022import java.io.File;
023
024import org.apache.maven.scm.ScmFile;
025import org.apache.maven.scm.ScmFileStatus;
026import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository;
027import org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer;
028import org.codehaus.plexus.util.cli.Commandline;
029
030public class TfsChangeLogCommandTest
031    extends TfsCommandTest
032{
033
034    private FileListConsumer consumer;
035
036    protected void setUp()
037        throws Exception
038    {
039        super.setUp();
040        consumer = new FileListConsumer();
041    }
042
043    public void testCommandline()
044        throws Exception    
045    {
046        TfsScmProviderRepository repo = getScmProviderRepository();
047        File f = new File( "file" );
048        Commandline cmd = new TfsChangeLogCommand().createCommand( repo, getScmFileSet(), f ).getCommandline();
049        String expected = "tf history -login:user,password -format:detailed " + f.getName();
050        assertCommandLine( expected, getWorkingDirectory(), cmd );
051    }
052
053    public void testCommand()
054    {
055        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
056        consumer.consumeLine( "Replacing .tpattributes" );
057        consumer.consumeLine( "Replacing .classpath" );
058        consumer.consumeLine( "Replacing .myclasspath" );
059        consumer.consumeLine( "Replacing .project" );
060        consumer.consumeLine( "" );
061        consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" );
062        consumer.consumeLine( "" );
063        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
064        consumer.consumeLine( "Replacing .tpignore" );
065        consumer.consumeLine( "Replacing about.html" );
066        consumer.consumeLine( "" );
067        consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" );
068        consumer.consumeLine( "" );
069        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
070        consumer.consumeLine( "Replacing build.properties" );
071        consumer.consumeLine( "Replacing customBuildCallbacks.xml" );
072        consumer.consumeLine( "" );
073
074        String exp1 = new File( "C:\\temp\\maven\\c8", ".classpath" ).getAbsolutePath();
075        String exp2 = new File( "C:\\temp\\maven\\c8", "build.properties" ).getAbsolutePath();
076        ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
077        ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
078
079        assertNotNull( consumer.getFiles() );
080        assertEquals( 11, consumer.getFiles().size() );
081        assertTrue( consumer.getFiles().contains( expFile1 ) );
082        assertTrue( consumer.getFiles().contains( expFile2 ) );
083    }
084
085    public void testMSCommand()
086    {
087        consumer.consumeLine( "c:\\temp\\maven:" );
088        consumer.consumeLine( "Replacing c10" );
089        consumer.consumeLine( "Replacing .classpath" );
090        consumer.consumeLine( "Replacing .myclasspath" );
091        consumer.consumeLine( "Replacing .project" );
092        consumer.consumeLine( "Replacing .settings" );
093        consumer.consumeLine( "Replacing .tpattributes" );
094        consumer.consumeLine( "Replacing .tpignore" );
095        consumer.consumeLine( "Replacing about.html" );
096        consumer.consumeLine( "Replacing bin" );
097        consumer.consumeLine( "Replacing build.properties" );
098
099        String exp1 = new File( "c:\\temp\\maven", ".classpath" ).getAbsolutePath();
100        String exp2 = new File( "c:\\temp\\maven", ".project" ).getAbsolutePath();
101        ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
102        ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
103
104        assertNotNull( consumer.getFiles() );
105        assertEquals( 11, consumer.getFiles().size() );
106        assertTrue( consumer.getFiles().contains( expFile1 ) );
107        assertTrue( consumer.getFiles().contains( expFile2 ) );
108    }
109
110}