From 7e27cba739ff13f140e7dee20b5cf31c6475df85 Mon Sep 17 00:00:00 2001 From: dion Date: Fri, 9 Jul 2004 12:37:36 +0000 Subject: [PATCH] changelog.xml author tag in Clearcase contains developer.id. git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@115742 13f79535-47bb-0310-9956-ffa450edef68 --- .../ClearcaseChangeLogParser.java | 2 +- .../clearcaselib/clearcaselog.txt | 15 +++ .../ClearcaseChangeLogParserTest.java | 102 ++++++++++++++++++ changelog/xdocs/changes.xml | 1 + 4 files changed, 119 insertions(+), 1 deletion(-) create mode 100644 changelog/src/test-resources/clearcaselib/clearcaselog.txt create mode 100644 changelog/src/test/org/apache/maven/clearcaselib/ClearcaseChangeLogParserTest.java diff --git a/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogParser.java b/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogParser.java index 838e02de..432f3cb8 100644 --- a/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogParser.java +++ b/changelog/src/main/org/apache/maven/clearcaselib/ClearcaseChangeLogParser.java @@ -250,7 +250,7 @@ public class ClearcaseChangeLogParser implements ChangeLogParser { } else if (line.startsWith(USER_TAG)) { - getCurrentLogEntry().setAuthor(line.substring(USER_TAG.length())); + getCurrentLogEntry().setAuthor(line.substring(USER_TAG.length()).trim()); // add entry, and set state to get file addEntry(getCurrentLogEntry(), getCurrentFile()); setStatus(GET_FILE); diff --git a/changelog/src/test-resources/clearcaselib/clearcaselog.txt b/changelog/src/test-resources/clearcaselib/clearcaselog.txt new file mode 100644 index 00000000..c6efc2bc --- /dev/null +++ b/changelog/src/test-resources/clearcaselib/clearcaselog.txt @@ -0,0 +1,15 @@ +NAME:PartyManager\src\java\uk\co\mycompany\corppay\refdata\model\Submission.java +DATE:20040630.145714 +COMM:checkin - checkin - Added status constants. + - Activity: Acceptance_Tests_For_Release_to_Instruction_Processor +USER:88888888 +NAME:PartyManager\src\java\uk\co\mycompany\util\hibernate +DATE:20040630.143802 +COMM:checkin - checkin - Added storing of data. + - Activity: Acceptance_Tests_For_Release_to_Instruction_Processor +USER:55555 +NAME:PartyManager\src\java\uk\co\mycompany\corppay\refdata\model\Submission.java +DATE:20040630.143759 +COMM:checkin - checkin - Added storing of data. + - Activity: Acceptance_Tests_For_Release_to_Instruction_Processor +USER:martenss diff --git a/changelog/src/test/org/apache/maven/clearcaselib/ClearcaseChangeLogParserTest.java b/changelog/src/test/org/apache/maven/clearcaselib/ClearcaseChangeLogParserTest.java new file mode 100644 index 00000000..2088002e --- /dev/null +++ b/changelog/src/test/org/apache/maven/clearcaselib/ClearcaseChangeLogParserTest.java @@ -0,0 +1,102 @@ +package org.apache.maven.clearcaselib; + +/* ==================================================================== + * Copyright 2001-2004 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ + +import java.io.FileInputStream; +import java.util.Collection; +import java.util.Iterator; +import junit.framework.TestCase; + +import org.apache.maven.changelog.ChangeLogEntry; + +/** + */ +public class ClearcaseChangeLogParserTest extends TestCase { + + /** the {@link ClearcaseChangeLogParser}used for testing */ + private ClearcaseChangeLogParser instance; + + /** file with test results to check against */ + private String testFile; + + /** + * Create a test with the given name + * + * @param testName + * the name of the test + */ + public ClearcaseChangeLogParserTest(String testName) { + super(testName); + } + + /** + * Initialize per test data + * + * @throws Exception + * when there is an unexpected problem + */ + public void setUp() throws Exception { + String baseDir = System.getProperty("basedir"); + assertNotNull("The system property basedir was not defined.", baseDir); + testFile = baseDir + + "/src/test-resources/clearcaselib/clearcaselog.txt"; + instance = new ClearcaseChangeLogParser(); + } + + /** + * Test of parse method + * + * @throws Exception + * when there is an unexpected problem + */ + public void testParse() throws Exception { + FileInputStream fis = new FileInputStream(testFile); + Collection entries = instance.parse(fis); + assertEquals("Wrong number of entries returned", 3, entries.size()); + ChangeLogEntry entry = null; + for (Iterator i = entries.iterator(); i.hasNext();) { + entry = (ChangeLogEntry) i.next(); + assertTrue("ChangeLogEntry erroneously picked up", entry.toString() + .indexOf("ChangeLogEntry.java") == -1); + } + + } + + public void testParseCorrectUsername() throws Exception { + + // parse the test file + FileInputStream fis = new FileInputStream(testFile); + Collection entries = instance.parse(fis); + + // check 8 char usernames are parsed correctly + Iterator i = entries.iterator(); + ChangeLogEntry entry = (ChangeLogEntry) i.next(); + assertEquals("exactly 8 chars expected", "88888888", entry.getAuthor()); + + // check < 8 char usernames are parsed correctly + entry = (ChangeLogEntry) i.next(); + assertEquals("exactly 5 chars expected", "55555", entry.getAuthor()); + + + } + + // Add test methods here, they have to start with 'test' name. + // for example: + // public void testHello() {} + +} \ No newline at end of file diff --git a/changelog/xdocs/changes.xml b/changelog/xdocs/changes.xml index 76dd40e7..672bedbb 100644 --- a/changelog/xdocs/changes.xml +++ b/changelog/xdocs/changes.xml @@ -26,6 +26,7 @@ + changelog.xml author tag in Clearcase contains developer.id. Plugin does not find the password for the CVSROOT in .cvspass if the CVSROOT in .cvspass is preceded by a "/1".