View Javadoc
1   
2   package org.apache.maven.scm.provider.accurev.cli;
3   
4   /*
5    * Licensed to the Apache Software Foundation (ASF) under one
6    * or more contributor license agreements.  See the NOTICE file
7    * distributed with this work for additional information
8    * regarding copyright ownership.  The ASF licenses this file
9    * to you under the Apache License, Version 2.0 (the
10   * "License"); you may not use this file except in compliance
11   * with the License.  You may obtain a copy of the License at
12   *
13   *   http://www.apache.org/licenses/LICENSE-2.0
14   *
15   * Unless required by applicable law or agreed to in writing,
16   * software distributed under the License is distributed on an
17   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
18   * KIND, either express or implied.  See the License for the
19   * specific language governing permissions and limitations
20   * under the License.
21   */
22  
23  import static org.hamcrest.Matchers.is;
24  import static org.junit.Assert.assertThat;
25  
26  import java.util.ArrayList;
27  import java.util.List;
28  
29  import junit.framework.Assert;
30  
31  import org.apache.maven.scm.ScmTestCase;
32  import org.apache.maven.scm.command.blame.BlameLine;
33  import org.apache.maven.scm.log.DefaultLog;
34  import org.apache.maven.scm.provider.accurev.AccuRev;
35  import org.junit.Test;
36  
37  /**
38   * @author Evgeny Mandrikov
39   * @author Grant Gardner
40   */
41  public class AnnotateConsumerTest extends ScmTestCase {
42  
43      @Test
44      public void testParse() throws Exception {
45  
46          List<BlameLine> consumedLines = new ArrayList<BlameLine>();
47  
48          AnnotateConsumer consumer = new AnnotateConsumer(consumedLines, new DefaultLog());
49  
50          AccuRevJUnitUtil.consume("/annotate.txt", consumer);
51  
52          Assert.assertEquals(12, consumer.getLines().size());
53  
54          BlameLine line1 = (BlameLine) consumer.getLines().get(0);
55          Assert.assertEquals("2", line1.getRevision());
56          Assert.assertEquals("go.d-in", line1.getAuthor());
57          assertThat(line1.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/26 16:26:44")));
58  
59          BlameLine line12 = (BlameLine) consumer.getLines().get(11);
60          Assert.assertEquals("1", line12.getRevision());
61          Assert.assertEquals("go.d-in", line12.getAuthor());
62          assertThat(line12.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/17 11:41:50")));
63  
64      }
65  
66  }