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