001package org.apache.maven.scm.provider.cvslib.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 org.apache.maven.scm.command.changelog.ChangeLogScmResult; 023import org.apache.maven.scm.command.changelog.ChangeLogSet; 024import org.apache.maven.scm.manager.ScmManager; 025import org.apache.maven.scm.provider.cvslib.AbstractCvsScmTest; 026import org.apache.maven.scm.provider.cvslib.CvsScmTestUtils; 027 028import java.util.Date; 029 030/** 031 * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse </a> 032 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a> 033 * 034 */ 035public class CvsChangeLogCommandTest 036 extends AbstractCvsScmTest 037{ 038 /** {@inheritDoc} */ 039 protected String getModule() 040 { 041 return "test-repo/changelog"; 042 } 043 044 public void testGetCommandWithStartAndEndDate() 045 throws Exception 046 { 047 Date startDate = getDate( 2003, 1, 1 ); 048 049 Date endDate = getDate( 2004, 1, 1 ); 050 051 testChangeLog( startDate, endDate, 32, null ); 052 } 053 054 public void testGetCommandWithoutEndDate() 055 throws Exception 056 { 057 Date startDate = getDate( 2003, 1, 1 ); 058 059 Date endDate = null; 060 061 testChangeLog( startDate, endDate, 51, null ); 062 } 063 064 public void testGetCommandWithBranchOrTag() 065 throws Exception 066 { 067 Date startDate = null; 068 069 Date endDate = null; 070 071 testChangeLog( startDate, endDate, 22, "1.107.4" ); 072 } 073 074 @SuppressWarnings( "deprecation" ) 075 private void testChangeLog( Date startDate, Date endDate, int changeLogSize, String branch ) 076 throws Exception 077 { 078 if ( !isSystemCmd( CvsScmTestUtils.CVS_COMMAND_LINE ) ) 079 { 080 System.err.println( "'" + CvsScmTestUtils.CVS_COMMAND_LINE + "' is not a system command. Ignored " 081 + getName() + "." ); 082 return; 083 } 084 085 ScmManager scmManager = getScmManager(); 086 087 CvsScmTestUtils.executeCVS( getWorkingDirectory(), 088 "-f -d " + getTestFile( "src/test/repository/" ) + " co " + getModule() ); 089 090 ChangeLogScmResult changeLogResult = scmManager.getProviderByRepository( getScmRepository() ).changeLog( 091 getScmRepository(), getScmFileSet(), startDate, endDate, 0, branch ); 092 093 if ( !changeLogResult.isSuccess() ) 094 { 095 fail( changeLogResult.getProviderMessage() + "\n" + changeLogResult.getCommandOutput() ); 096 } 097 098 ChangeLogSet changeLogSet = changeLogResult.getChangeLog(); 099 100 assertNotNull( changeLogSet ); 101 102 assertEquals( changeLogSize, changeLogSet.getChangeSets().size() ); 103 } 104}