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.ScmRevision;
027import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository;
028import org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer;
029import org.codehaus.plexus.util.cli.Commandline;
030
031public class TfsCheckOutCommandTest
032    extends TfsCommandTest
033{
034
035    private FileListConsumer consumer;
036
037    protected void setUp()
038        throws Exception
039    {
040        super.setUp();
041        consumer = new FileListConsumer();
042    }
043
044    public void testCommandline()
045        throws Exception    
046    {
047        TfsScmProviderRepository repo = getScmProviderRepository();
048        ScmRevision rev = new ScmRevision( "revision" );
049        String path = getScmFileSet().getBasedir().getAbsolutePath();
050        Commandline cmd = new TfsCheckOutCommand().createGetCommand( repo, getScmFileSet(), rev, true ).getCommandline();
051        String expected = "tf get -login:user,password -recursive -force -version:Crevision " + path;
052        assertCommandLine( expected, getWorkingDirectory(), cmd );
053    }
054
055    public void testCommand()
056    {
057        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
058        consumer.consumeLine( "Replacing .tpattributes" );
059        consumer.consumeLine( "Replacing .classpath" );
060        consumer.consumeLine( "Replacing .myclasspath" );
061        consumer.consumeLine( "Replacing .project" );
062        consumer.consumeLine( "" );
063        consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" );
064        consumer.consumeLine( "" );
065        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
066        consumer.consumeLine( "Replacing .tpignore" );
067        consumer.consumeLine( "Replacing about.html" );
068        consumer.consumeLine( "" );
069        consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" );
070        consumer.consumeLine( "" );
071        consumer.consumeLine( "C:\\temp\\maven\\c8:" );
072        consumer.consumeLine( "Replacing build.properties" );
073        consumer.consumeLine( "Replacing customBuildCallbacks.xml" );
074        consumer.consumeLine( "" );
075
076        String exp1 = new File( "C:\\temp\\maven\\c8", ".classpath" ).getAbsolutePath();
077        String exp2 = new File( "C:\\temp\\maven\\c8", "build.properties" ).getAbsolutePath();
078        ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
079        ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
080        assertNotNull( consumer.getFiles() );
081        assertEquals( 11, consumer.getFiles().size() );
082        assertTrue( consumer.getFiles().contains( expFile1 ) );
083        assertTrue( consumer.getFiles().contains( expFile2 ) );
084    }
085
086    public void testMSCommand()
087    {
088        consumer.consumeLine( "c:\\temp\\maven:" );
089        consumer.consumeLine( "Replacing c10" );
090        consumer.consumeLine( "Replacing .classpath" );
091        consumer.consumeLine( "Replacing .myclasspath" );
092        consumer.consumeLine( "Replacing .project" );
093        consumer.consumeLine( "Replacing .settings" );
094        consumer.consumeLine( "Replacing .tpattributes" );
095        consumer.consumeLine( "Replacing .tpignore" );
096        consumer.consumeLine( "Replacing about.html" );
097        consumer.consumeLine( "Replacing bin" );
098        consumer.consumeLine( "Replacing build.properties" );
099
100        assertNotNull( consumer.getFiles() );
101        
102        String exp1 = new File( "c:\\temp\\maven", ".classpath" ).getAbsolutePath();
103        String exp2 = new File( "c:\\temp\\maven", ".project" ).getAbsolutePath();
104        ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
105        ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
106        assertEquals( 11, consumer.getFiles().size() );
107        assertTrue( consumer.getFiles().contains( expFile1 ) );
108        assertTrue( consumer.getFiles().contains(expFile2) );
109    }
110
111}