View Javadoc
1   package org.apache.maven.scm.provider.jazz.command.blame;
2   
3   import org.apache.maven.scm.log.DefaultLog;
4   import org.apache.maven.scm.provider.jazz.JazzScmTestCase;
5   import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
6   import org.codehaus.plexus.util.cli.Commandline;
7   
8   import java.util.Locale;
9   
10  /*
11   * Licensed to the Apache Software Foundation (ASF) under one
12   * or more contributor license agreements.  See the NOTICE file
13   * distributed with this work for additional information
14   * regarding copyright ownership.  The ASF licenses this file
15   * to you under the Apache License, Version 2.0 (the
16   * "License"); you may not use this file except in compliance
17   * with the License.  You may obtain a copy of the License at
18   *
19   * http://www.apache.org/licenses/LICENSE-2.0
20   *
21   * Unless required by applicable law or agreed to in writing,
22   * software distributed under the License is distributed on an
23   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24   * KIND, either express or implied.  See the License for the
25   * specific language governing permissions and limitations
26   * under the License.
27   */
28  
29  /**
30   * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
31   */
32  public class JazzBlameCommandTest
33      extends JazzScmTestCase
34  {
35      private JazzScmProviderRepository repo;
36  
37      private JazzBlameConsumer blameConsumer;
38  
39      private Locale defaultLocale;
40  
41      protected void setUp()
42          throws Exception
43      {
44          super.setUp();
45          repo = getScmProviderRepository();
46          blameConsumer = new JazzBlameConsumer( repo, new DefaultLog() );
47          defaultLocale = Locale.getDefault();
48      }
49  
50      protected void tearDown()
51          throws Exception
52      {
53          Locale.setDefault( defaultLocale );
54      }
55  
56      public void testCreateBlameCommand()
57          throws Exception
58      {
59          Commandline cmd =
60              new JazzBlameCommand().createBlameCommand( repo, getScmFileSet(), "test.txt" ).getCommandline();
61          String expected = "scm annotate --username myUserName --password myPassword test.txt";
62          assertCommandLine( expected, getWorkingDirectory(), cmd );
63      }
64  
65      public void testConsumer()
66      {
67  //      C:\tmp\maven\BogusTest>scm annotate --username Deb --password Deb test.txt
68  //      1 Deb (1008) 2011-12-14                       Test.txt
69  //      2 Deb (1005) 2011-12-14 59 My commit comment.
70  
71          blameConsumer.consumeLine( "1 Deb (1008) 2011-12-14                       Test.txt" );
72          blameConsumer.consumeLine( "2 Deb (1005) 2011-12-14 59 My commit comment." );
73  
74          assertEquals( "Wrong number of lines parsed!", 2, blameConsumer.getLines().size() );
75      }
76  
77  }