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.provider.tfs.TfsScmProviderRepository;
27  import org.apache.maven.scm.provider.tfs.command.consumer.FileListConsumer;
28  import org.codehaus.plexus.util.cli.Commandline;
29  
30  public class TfsChangeLogCommandTest
31      extends TfsCommandTest
32  {
33  
34      private FileListConsumer consumer;
35  
36      protected void setUp()
37          throws Exception
38      {
39          super.setUp();
40          consumer = new FileListConsumer();
41      }
42  
43      public void testCommandline()
44          throws Exception    
45      {
46          TfsScmProviderRepository repo = getScmProviderRepository();
47          File f = new File( "file" );
48          Commandline cmd = new TfsChangeLogCommand().createCommand( repo, getScmFileSet(), f ).getCommandline();
49          String expected = "tf history -login:user,password -format:detailed " + f.getName();
50          assertCommandLine( expected, getWorkingDirectory(), cmd );
51      }
52  
53      public void testCommand()
54      {
55          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
56          consumer.consumeLine( "Replacing .tpattributes" );
57          consumer.consumeLine( "Replacing .classpath" );
58          consumer.consumeLine( "Replacing .myclasspath" );
59          consumer.consumeLine( "Replacing .project" );
60          consumer.consumeLine( "" );
61          consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" );
62          consumer.consumeLine( "" );
63          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
64          consumer.consumeLine( "Replacing .tpignore" );
65          consumer.consumeLine( "Replacing about.html" );
66          consumer.consumeLine( "" );
67          consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" );
68          consumer.consumeLine( "" );
69          consumer.consumeLine( "C:\\temp\\maven\\c8:" );
70          consumer.consumeLine( "Replacing build.properties" );
71          consumer.consumeLine( "Replacing customBuildCallbacks.xml" );
72          consumer.consumeLine( "" );
73  
74          String exp1 = new File( "C:\\temp\\maven\\c8", ".classpath" ).getAbsolutePath();
75          String exp2 = new File( "C:\\temp\\maven\\c8", "build.properties" ).getAbsolutePath();
76          ScmFile expFile1 = new ScmFile( exp1, ScmFileStatus.CHECKED_OUT );
77          ScmFile expFile2 = new ScmFile( exp2, ScmFileStatus.CHECKED_OUT );
78  
79          assertNotNull( consumer.getFiles() );
80          assertEquals( 11, consumer.getFiles().size() );
81          assertTrue( consumer.getFiles().contains( expFile1 ) );
82          assertTrue( consumer.getFiles().contains( expFile2 ) );
83      }
84  
85      public void testMSCommand()
86      {
87          consumer.consumeLine( "c:\\temp\\maven:" );
88          consumer.consumeLine( "Replacing c10" );
89          consumer.consumeLine( "Replacing .classpath" );
90          consumer.consumeLine( "Replacing .myclasspath" );
91          consumer.consumeLine( "Replacing .project" );
92          consumer.consumeLine( "Replacing .settings" );
93          consumer.consumeLine( "Replacing .tpattributes" );
94          consumer.consumeLine( "Replacing .tpignore" );
95          consumer.consumeLine( "Replacing about.html" );
96          consumer.consumeLine( "Replacing bin" );
97          consumer.consumeLine( "Replacing build.properties" );
98  
99          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 }