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.util.List;
23  import java.util.Locale;
24  
25  import org.apache.maven.scm.ScmFile;
26  import org.apache.maven.scm.ScmFileStatus;
27  import org.apache.maven.scm.log.DefaultLog;
28  import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository;
29  import org.apache.maven.scm.provider.tfs.command.consumer.ChangedFileConsumer;
30  import org.codehaus.plexus.util.cli.Commandline;
31  
32  public class TfsStatusCommandTest
33      extends TfsCommandTest
34  {
35  
36      private ChangedFileConsumer consumer;
37  
38      private Locale defaultLocale;
39  
40      protected void setUp()
41          throws Exception
42      {
43          super.setUp();
44          consumer = new ChangedFileConsumer( new DefaultLog() );
45          defaultLocale = Locale.getDefault();
46      }
47  
48      public void testCommandline()
49          throws Exception    
50      {
51          TfsScmProviderRepository repo = getScmProviderRepository();
52          Commandline cmd = new TfsStatusCommand().createCommand( repo, getScmFileSet() ).getCommandline();
53          String expected =
54              "tf status -login:user,password -workspace:workspace -recursive -format:detailed " + repo.getServerPath();
55          assertCommandLine( expected, getWorkingDirectory(), cmd );
56      }
57  
58      protected void tearDown()
59          throws Exception
60      {
61          Locale.setDefault( defaultLocale );
62      }
63  
64      public void testCommand()
65      {
66          consumer.consumeLine( "$/junk/pluginp/.classpath;C1858" );
67          consumer.consumeLine( "  User:       CDESG\\subhash" );
68          consumer.consumeLine( "  Date:       Mar 12, 2009 2:18:31 AM" );
69          consumer.consumeLine( "  Lock:       none" );
70          consumer.consumeLine( "  Change:     edit" );
71          consumer.consumeLine( "  Workspace:  purinaTest" );
72          consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.classpath" );
73          consumer.consumeLine( "  File type:  windows-1252" );
74          consumer.consumeLine( "" );
75          consumer.consumeLine( "$/junk/pluginp/.project;C1858" );
76          consumer.consumeLine( "  User:       CDESG\\subhash" );
77          consumer.consumeLine( "  Date:       Mar 12, 2009 2:18:31 AM" );
78          consumer.consumeLine( "  Lock:       none" );
79          consumer.consumeLine( "  Change:     edit" );
80          consumer.consumeLine( "  Workspace:  purinaTest" );
81          consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.project" );
82          consumer.consumeLine( "  File type:  windows-1252" );
83          consumer.consumeLine( "" );
84          consumer.consumeLine( "$/junk/pluginp/build.properties;C1858" );
85          consumer.consumeLine( "  User:       CDESG\\subhash" );
86          consumer.consumeLine( "  Date:       Mar 12, 2009 2:18:31 AM" );
87          consumer.consumeLine( "  Lock:       none" );
88          consumer.consumeLine( "  Change:     edit" );
89          consumer.consumeLine( "  Workspace:  purinaTest" );
90          consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\build.properties" );
91          consumer.consumeLine( "  File type:  windows-1252" );
92          consumer.consumeLine( "" );
93          consumer.consumeLine( "$/junk/pluginp/META-INF/MANIFEST.MF;C1858" );
94          consumer.consumeLine( "  User:       CDESG\\subhash" );
95          consumer.consumeLine( "  Date:       Mar 12, 2009 2:18:31 AM" );
96          consumer.consumeLine( "  Lock:       none" );
97          consumer.consumeLine( "  Change:     edit" );
98          consumer.consumeLine( "  Workspace:  purinaTest" );
99          consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\META-INF\\MANIFEST.MF" );
100         consumer.consumeLine( "  File type:  windows-1252" );
101         consumer.consumeLine( "" );
102 
103         List<ScmFile> changedFiles = consumer.getChangedFiles();
104         assertNotNull( changedFiles );
105         assertEquals( 4, changedFiles.size() );
106         assertTrue( changedFiles.contains( new ScmFile( "C:\\temp\\maven\\c4\\.classpath", ScmFileStatus.MODIFIED ) ) );
107         assertTrue( changedFiles.contains( new ScmFile( "C:\\temp\\maven\\c4\\META-INF\\MANIFEST.MF",
108                                                         ScmFileStatus.MODIFIED ) ) );
109     }
110 
111     public void testLocale()
112     {
113         Locale.setDefault( Locale.GERMAN );
114         String date = "12.03.2009 02:18:31";
115         consumer.consumeLine( "$/junk/pluginp/.classpath;C1858" );
116         consumer.consumeLine( "  User:       CDESG\\subhash" );
117         consumer.consumeLine( "  Date:       " + date );
118         consumer.consumeLine( "  Lock:       none" );
119         consumer.consumeLine( "  Change:     edit" );
120         consumer.consumeLine( "  Workspace:  purinaTest" );
121         consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.classpath" );
122         consumer.consumeLine( "  File type:  windows-1252" );
123         consumer.consumeLine( "" );
124         consumer.consumeLine( "$/junk/pluginp/.project;C1858" );
125         consumer.consumeLine( "  User:       CDESG\\subhash" );
126         consumer.consumeLine( "  Date:       " + date );
127         consumer.consumeLine( "  Lock:       none" );
128         consumer.consumeLine( "  Change:     edit" );
129         consumer.consumeLine( "  Workspace:  purinaTest" );
130         consumer.consumeLine( "  Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.project" );
131         consumer.consumeLine( "  File type:  windows-1252" );
132         consumer.consumeLine( "" );
133         List<ScmFile> changedFiles = consumer.getChangedFiles();
134         assertNotNull( changedFiles );
135         assertEquals( 2, changedFiles.size() );
136     }
137 }