001package org.apache.maven.scm.provider.bazaar.command.changelog; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import java.io.BufferedReader; 023import java.io.File; 024import java.io.FileInputStream; 025import java.io.IOException; 026import java.io.InputStreamReader; 027import java.util.List; 028 029import org.apache.maven.scm.ChangeFile; 030import org.apache.maven.scm.ChangeSet; 031import org.apache.maven.scm.ScmFileStatus; 032import org.apache.maven.scm.ScmTestCase; 033import org.apache.maven.scm.log.DefaultLog; 034import org.junit.Assert; 035 036public class BazaarChangeLogConsumerTest 037 extends ScmTestCase 038{ 039 public void testChanglogWithMergeEntries() 040 throws IOException 041 { 042 File testFile = getTestFile( "src/test/resources/bazaar/changeLogWithMerge.txt" ); 043 044 BazaarChangeLogConsumer consumer = new BazaarChangeLogConsumer( new DefaultLog(), null ); 045 046 FileInputStream fis = new FileInputStream( testFile ); 047 BufferedReader in = new BufferedReader( new InputStreamReader( fis ) ); 048 String s = in.readLine(); 049 while ( s != null ) 050 { 051 consumer.consumeLine( s ); 052 s = in.readLine(); 053 } 054 055 List<ChangeSet> mods = consumer.getModifications(); 056 assertEquals( 4, mods.size() ); 057 058 final ChangeSet ch2 = mods.get( 2 ); 059 Assert.assertEquals( "Unexpected committer", "tsmoergrav@slb.com", ch2.getAuthor() ); 060 Assert.assertEquals( "Unexpected comment", "Second", ch2.getComment() ); 061 Assert.assertEquals( "File count", 2, ch2.getFiles().size() ); 062 063 final ChangeFile ch2f1 = ch2.getFiles().get( 0 ); 064 Assert.assertEquals( "Invalid action", ScmFileStatus.MODIFIED, ch2f1.getAction() ); 065 Assert.assertEquals( "Invalid file name", "changeLogWithMerge.txt", ch2f1.getName() ); 066 Assert.assertNull( "Unexpected originalName", ch2f1.getOriginalName() ); 067 068 final ChangeFile ch2f2 = ch2.getFiles().get( 1 ); 069 Assert.assertEquals( "Invalid action", ScmFileStatus.RENAMED, ch2f2.getAction() ); 070 Assert.assertEquals( "Invalid file name", "blablabla.txt", ch2f2.getName() ); 071 Assert.assertEquals( "Invalid original name", "a", ch2f2.getOriginalName() ); 072 } 073}