View Javadoc
1   package org.apache.maven.scm.provider.tfs.command;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   * http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import java.io.File;
23  
24  import org.apache.maven.scm.ScmFile;
25  import org.apache.maven.scm.ScmFileStatus;
26  import org.apache.maven.scm.ScmRevision;
27  import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository;
28  import org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer;
29  import org.codehaus.plexus.util.cli.Commandline;
30  
31  public class TfsCheckOutCommandTest
32      extends TfsCommandTest
33  {
34  
35      private FileListConsumer consumer;
36  
37      protected void setUp()
38          throws Exception
39      {
40          super.setUp();
41          consumer = new FileListConsumer();
42      }
43  
44      public void testCommandline()
45          throws Exception    
46      {
47          TfsScmProviderRepository repo = getScmProviderRepository();
48          ScmRevision rev = new ScmRevision( "revision" );
49          String path = getScmFileSet().getBasedir().getAbsolutePath();
50          Commandline cmd = new TfsCheckOutCommand().createGetCommand( repo, getScmFileSet(), rev, true ).getCommandline();
51          String expected = "tf get -login:user,password -recursive -force -version:Crevision " + path;
52          assertCommandLine( expected, getWorkingDirectory(), cmd );
53      }
54  
55      public void testCommand()
56      {
57          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
58          consumer.consumeLine( "Replacing .tpattributes" );
59          consumer.consumeLine( "Replacing .classpath" );
60          consumer.consumeLine( "Replacing .myclasspath" );
61          consumer.consumeLine( "Replacing .project" );
62          consumer.consumeLine( "" );
63          consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" );
64          consumer.consumeLine( "" );
65          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
66          consumer.consumeLine( "Replacing .tpignore" );
67          consumer.consumeLine( "Replacing about.html" );
68          consumer.consumeLine( "" );
69          consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" );
70          consumer.consumeLine( "" );
71          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
72          consumer.consumeLine( "Replacing build.properties" );
73          consumer.consumeLine( "Replacing customBuildCallbacks.xml" );
74          consumer.consumeLine( "" );
75  
76          String exp1 = new File( "C:\\temp\\maven\\c8", ".classpath" ).getAbsolutePath();
77          String exp2 = new File( "C:\\temp\\maven\\c8", "build.properties" ).getAbsolutePath();
78          ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
79          ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
80          assertNotNull( consumer.getFiles() );
81          assertEquals( 11, consumer.getFiles().size() );
82          assertTrue( consumer.getFiles().contains( expFile1 ) );
83          assertTrue( consumer.getFiles().contains( expFile2 ) );
84      }
85  
86      public void testMSCommand()
87      {
88          consumer.consumeLine( "c:\\temp\\maven:" );
89          consumer.consumeLine( "Replacing c10" );
90          consumer.consumeLine( "Replacing .classpath" );
91          consumer.consumeLine( "Replacing .myclasspath" );
92          consumer.consumeLine( "Replacing .project" );
93          consumer.consumeLine( "Replacing .settings" );
94          consumer.consumeLine( "Replacing .tpattributes" );
95          consumer.consumeLine( "Replacing .tpignore" );
96          consumer.consumeLine( "Replacing about.html" );
97          consumer.consumeLine( "Replacing bin" );
98          consumer.consumeLine( "Replacing build.properties" );
99  
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 }