public void testChangeLogCommand()
throws Exception
{
Thread.sleep( 1000 );
ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() );
ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
//We should have one log entry for the initial repository
ChangeLogScmResult result =
provider.changeLog( getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null );
assertTrue( result.getProviderMessage(), result.isSuccess() );
assertEquals( 1, result.getChangeLog().getChangeSets().size() );
//Make a timestamp that we know are after initial revision but before the second
Date timeBeforeSecond = new Date(); //Current time
// pause a couple seconds... [SCM-244]
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 = provider.changeLog( getScmRepository(), fileSet, (ScmVersion) null, null );
assertTrue( result.getProviderMessage(), result.isSuccess() );
assertEquals( 2, result.getChangeLog().getChangeSets().size() );
//Now only retrieve the changelog after timeBeforeSecondChangeLog
Date currentTime = new Date();
result = provider
.changeLog( getScmRepository(), fileSet, timeBeforeSecond, currentTime, 0, new ScmBranch( "" ) );
//Thorough assert of the last result
assertTrue( result.getProviderMessage(), result.isSuccess() );
assertEquals( 1, result.getChangeLog().getChangeSets().size() );