001
002package org.apache.maven.scm.provider.accurev.cli;
003
004/*
005 * Licensed to the Apache Software Foundation (ASF) under one
006 * or more contributor license agreements.  See the NOTICE file
007 * distributed with this work for additional information
008 * regarding copyright ownership.  The ASF licenses this file
009 * to you under the Apache License, Version 2.0 (the
010 * "License"); you may not use this file except in compliance
011 * with the License.  You may obtain a copy of the License at
012 *
013 *   http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing,
016 * software distributed under the License is distributed on an
017 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
018 * KIND, either express or implied.  See the License for the
019 * specific language governing permissions and limitations
020 * under the License.
021 */
022
023import static org.hamcrest.Matchers.is;
024import static org.junit.Assert.assertThat;
025
026import java.util.ArrayList;
027import java.util.List;
028
029import junit.framework.Assert;
030
031import org.apache.maven.scm.ScmTestCase;
032import org.apache.maven.scm.command.blame.BlameLine;
033import org.apache.maven.scm.log.DefaultLog;
034import org.apache.maven.scm.provider.accurev.AccuRev;
035import org.junit.Test;
036
037/**
038 * @author Evgeny Mandrikov
039 * @author Grant Gardner
040 */
041public class AnnotateConsumerTest extends ScmTestCase {
042
043    @Test
044    public void testParse() throws Exception {
045
046        List<BlameLine> consumedLines = new ArrayList<BlameLine>();
047
048        AnnotateConsumer consumer = new AnnotateConsumer(consumedLines, new DefaultLog());
049
050        AccuRevJUnitUtil.consume("/annotate.txt", consumer);
051
052        Assert.assertEquals(12, consumer.getLines().size());
053
054        BlameLine line1 = (BlameLine) consumer.getLines().get(0);
055        Assert.assertEquals("2", line1.getRevision());
056        Assert.assertEquals("go.d-in", line1.getAuthor());
057        assertThat(line1.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/26 16:26:44")));
058
059        BlameLine line12 = (BlameLine) consumer.getLines().get(11);
060        Assert.assertEquals("1", line12.getRevision());
061        Assert.assertEquals("go.d-in", line12.getAuthor());
062        assertThat(line12.getDate(), is(AccuRev.ACCUREV_TIME_SPEC.parse("2008/10/17 11:41:50")));
063
064    }
065
066}