001package org.apache.maven.scm.provider.jazz.command.blame; 002 003import org.apache.maven.scm.log.DefaultLog; 004import org.apache.maven.scm.provider.jazz.JazzScmTestCase; 005import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository; 006import org.codehaus.plexus.util.cli.Commandline; 007 008import java.util.Locale; 009 010/* 011 * Licensed to the Apache Software Foundation (ASF) under one 012 * or more contributor license agreements. See the NOTICE file 013 * distributed with this work for additional information 014 * regarding copyright ownership. The ASF licenses this file 015 * to you under the Apache License, Version 2.0 (the 016 * "License"); you may not use this file except in compliance 017 * with the License. You may obtain a copy of the License at 018 * 019 * http://www.apache.org/licenses/LICENSE-2.0 020 * 021 * Unless required by applicable law or agreed to in writing, 022 * software distributed under the License is distributed on an 023 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 024 * KIND, either express or implied. See the License for the 025 * specific language governing permissions and limitations 026 * under the License. 027 */ 028 029/** 030 * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a> 031 */ 032public class JazzBlameCommandTest 033 extends JazzScmTestCase 034{ 035 private JazzScmProviderRepository repo; 036 037 private JazzBlameConsumer blameConsumer; 038 039 private Locale defaultLocale; 040 041 protected void setUp() 042 throws Exception 043 { 044 super.setUp(); 045 repo = getScmProviderRepository(); 046 blameConsumer = new JazzBlameConsumer( repo, new DefaultLog() ); 047 defaultLocale = Locale.getDefault(); 048 } 049 050 protected void tearDown() 051 throws Exception 052 { 053 Locale.setDefault( defaultLocale ); 054 } 055 056 public void testCreateBlameCommand() 057 throws Exception 058 { 059 Commandline cmd = 060 new JazzBlameCommand().createBlameCommand( repo, getScmFileSet(), "test.txt" ).getCommandline(); 061 String expected = "scm annotate --username myUserName --password myPassword test.txt"; 062 assertCommandLine( expected, getWorkingDirectory(), cmd ); 063 } 064 065 public void testConsumer() 066 { 067// C:\tmp\maven\BogusTest>scm annotate --username Deb --password Deb test.txt 068// 1 Deb (1008) 2011-12-14 Test.txt 069// 2 Deb (1005) 2011-12-14 59 My commit comment. 070 071 blameConsumer.consumeLine( "1 Deb (1008) 2011-12-14 Test.txt" ); 072 blameConsumer.consumeLine( "2 Deb (1005) 2011-12-14 59 My commit comment." ); 073 074 assertEquals( "Wrong number of lines parsed!", 2, blameConsumer.getLines().size() ); 075 } 076 077}