public void testBlameCommand()
throws Exception
{
ScmRepository repository = getScmRepository();
ScmManager manager = getScmManager();
ScmProvider provider = manager.getProviderByRepository( getScmRepository() );
ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
BlameScmResult result;
BlameLine line;
// === readme.txt ===
result = manager.blame( repository, fileSet, "readme.txt" );
assertNotNull( "The command returned a null result.", result );
assertResultIsSuccess( result );
assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
line = result.getLines().get( 0 );
String initialRevision = line.getRevision();
//Make a timestamp that we know are after initial revision but before the second
Date timeBeforeSecond = new Date(); // Current time
// pause a couple seconds...
Thread.sleep( 2000 );
//Make a change to the readme.txt and commit the change
ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG );
assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );
result = manager.blame( repository, fileSet, "readme.txt" );
// pause a couple seconds...
Thread.sleep( 2000 );
Date timeAfterSecond = new Date(); // Current time
assertNotNull( "The command returned a null result.", result );
assertResultIsSuccess( result );
assertEquals( "Expected 1 line in blame", 1, result.getLines().size() );
line = result.getLines().get( 0 );
assertNotNull( "Expected not null author", line.getAuthor() );
assertNotNull( "Expected not null revision", line.getRevision() );
assertNotNull( "Expected not null date", line.getDate() );
assertTrue( "Expected another revision", !initialRevision.equals( line.getRevision() ) );
if ( isTestDateTime() )
{
assertDateBetween( timeBeforeSecond, timeAfterSecond, line.getDate() );
}
// === pom.xml ===
result = manager.blame( repository, fileSet, "pom.xml" );
assertNotNull( "The command returned a null result.", result );
assertResultIsSuccess( result );