710N/A/*
710N/A * CDDL HEADER START
710N/A *
710N/A * The contents of this file are subject to the terms of the
710N/A * Common Development and Distribution License (the "License").
710N/A * You may not use this file except in compliance with the License.
710N/A *
710N/A * See LICENSE.txt included in this distribution for the specific
710N/A * language governing permissions and limitations under the License.
710N/A *
710N/A * When distributing Covered Code, include this CDDL HEADER in each
710N/A * file and include the License file at LICENSE.txt.
710N/A * If applicable, add the following below this CDDL HEADER, with the
710N/A * fields enclosed by brackets "[]" replaced with your own identifying
710N/A * information: Portions Copyright [yyyy] [name of copyright owner]
710N/A *
710N/A * CDDL HEADER END
710N/A */
710N/A
710N/A/*
710N/A * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
710N/A * Use is subject to license terms.
710N/A */
710N/Apackage org.opensolaris.opengrok.history;
710N/A
710N/Aimport java.io.Reader;
710N/Aimport java.io.StringReader;
710N/Aimport org.junit.After;
710N/Aimport org.junit.AfterClass;
710N/Aimport org.junit.Before;
710N/Aimport org.junit.BeforeClass;
710N/Aimport org.junit.Test;
710N/Aimport static org.junit.Assert.*;
710N/A
710N/A/**
710N/A *
710N/A * @author austvik
710N/A */
710N/Apublic class CVSRepositoryTest {
710N/A
710N/A CVSRepository instance;
710N/A
710N/A public CVSRepositoryTest() {
710N/A }
710N/A
710N/A @BeforeClass
710N/A public static void setUpClass() throws Exception {
710N/A }
710N/A
710N/A @AfterClass
710N/A public static void tearDownClass() throws Exception {
710N/A }
710N/A
710N/A @Before
710N/A public void setUp() {
710N/A instance = new CVSRepository();
710N/A }
710N/A
710N/A @After
710N/A public void tearDown() {
710N/A instance = null;
710N/A }
710N/A
710N/A /**
710N/A * Test of fileHasAnnotation method, of class CVSRepository.
710N/A */
710N/A @Test
710N/A public void testFileHasAnnotation() {
710N/A boolean result = instance.fileHasAnnotation(null);
710N/A assertTrue(result);
710N/A }
710N/A
710N/A /**
710N/A * Test of fileHasHistory method, of class CVSRepository.
710N/A */
710N/A @Test
710N/A public void testFileHasHistory() {
710N/A boolean result = instance.fileHasHistory(null);
710N/A assertTrue(result);
710N/A }
710N/A
710N/A /**
710N/A * Test of parseAnnotation method, of class CVSRepository.
710N/A */
710N/A @Test
710N/A public void testParseAnnotation() throws Exception {
710N/A String revId1 = "1.1";
710N/A String revId2 = "1.2.3";
710N/A String revId3 = "1.0";
710N/A String author1 = "author1";
710N/A String author2 = "author_long2";
710N/A String author3 = "author3";
710N/A String output = "just jibberish in output\n\n" + revId1 + " (" + author1 + " 01-Mar-07) \n" +
710N/A revId2 + " (" + author2 + " 02-Mar-08) if (some code)\n" +
710N/A revId3 + " (" + author3 + " 30-Apr-07) call_function(i);\n";
710N/A Reader input = new StringReader(output);
710N/A String fileName = "something.ext";
710N/A Annotation result = instance.parseAnnotation(input, fileName);
710N/A assertNotNull(result);
710N/A assertEquals(3, result.size());
710N/A assertEquals(revId1, result.getRevision(1));
710N/A assertEquals(revId2, result.getRevision(2));
710N/A assertEquals(revId3, result.getRevision(3));
710N/A assertEquals(author1, result.getAuthor(1));
710N/A assertEquals(author2, result.getAuthor(2));
710N/A assertEquals(author3, result.getAuthor(3));
710N/A assertEquals(author2.length(), result.getWidestAuthor());
710N/A assertEquals(revId2.length(), result.getWidestRevision());
710N/A assertEquals(fileName, result.getFilename());
710N/A }
710N/A
710N/A}