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.util.List; 023import java.util.Locale; 024 025import org.apache.maven.scm.ScmFile; 026import org.apache.maven.scm.ScmFileStatus; 027import org.apache.maven.scm.log.DefaultLog; 028import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; 029import org.apache.maven.scm.provider.tfs.command.consumer.ChangedFileConsumer; 030import org.codehaus.plexus.util.cli.Commandline; 031 032public class TfsStatusCommandTest 033 extends TfsCommandTest 034{ 035 036 private ChangedFileConsumer consumer; 037 038 private Locale defaultLocale; 039 040 protected void setUp() 041 throws Exception 042 { 043 super.setUp(); 044 consumer = new ChangedFileConsumer( new DefaultLog() ); 045 defaultLocale = Locale.getDefault(); 046 } 047 048 public void testCommandline() 049 throws Exception 050 { 051 TfsScmProviderRepository repo = getScmProviderRepository(); 052 Commandline cmd = new TfsStatusCommand().createCommand( repo, getScmFileSet() ).getCommandline(); 053 String expected = 054 "tf status -login:user,password -workspace:workspace -recursive -format:detailed " + repo.getServerPath(); 055 assertCommandLine( expected, getWorkingDirectory(), cmd ); 056 } 057 058 protected void tearDown() 059 throws Exception 060 { 061 Locale.setDefault( defaultLocale ); 062 } 063 064 public void testCommand() 065 { 066 consumer.consumeLine( "$/junk/pluginp/.classpath;C1858" ); 067 consumer.consumeLine( " User: CDESG\\subhash" ); 068 consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); 069 consumer.consumeLine( " Lock: none" ); 070 consumer.consumeLine( " Change: edit" ); 071 consumer.consumeLine( " Workspace: purinaTest" ); 072 consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.classpath" ); 073 consumer.consumeLine( " File type: windows-1252" ); 074 consumer.consumeLine( "" ); 075 consumer.consumeLine( "$/junk/pluginp/.project;C1858" ); 076 consumer.consumeLine( " User: CDESG\\subhash" ); 077 consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); 078 consumer.consumeLine( " Lock: none" ); 079 consumer.consumeLine( " Change: edit" ); 080 consumer.consumeLine( " Workspace: purinaTest" ); 081 consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.project" ); 082 consumer.consumeLine( " File type: windows-1252" ); 083 consumer.consumeLine( "" ); 084 consumer.consumeLine( "$/junk/pluginp/build.properties;C1858" ); 085 consumer.consumeLine( " User: CDESG\\subhash" ); 086 consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); 087 consumer.consumeLine( " Lock: none" ); 088 consumer.consumeLine( " Change: edit" ); 089 consumer.consumeLine( " Workspace: purinaTest" ); 090 consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\build.properties" ); 091 consumer.consumeLine( " File type: windows-1252" ); 092 consumer.consumeLine( "" ); 093 consumer.consumeLine( "$/junk/pluginp/META-INF/MANIFEST.MF;C1858" ); 094 consumer.consumeLine( " User: CDESG\\subhash" ); 095 consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); 096 consumer.consumeLine( " Lock: none" ); 097 consumer.consumeLine( " Change: edit" ); 098 consumer.consumeLine( " Workspace: purinaTest" ); 099 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}