String workingStream = accurevTckTestUtil.getWorkingStream();
String subStream = accurevTckTestUtil.getDepotName() + "_sub_stream";
accurev.mkstream( workingStream, subStream );
ScmRepository mainRepository = getScmRepository();
ScmProvider provider = getScmManager().getProviderByRepository( mainRepository );
// Create a workspace at the updating copy location backed by the substream
ScmBranch branch = new ScmBranch( "sub_stream" );
provider.checkOut( mainRepository, new ScmFileSet( getUpdatingCopy() ), branch );
Thread.sleep( 1000 );
ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
// Make a timestamp that we know are after initial revision but before the second
Date timeBeforeUpstreamCheckin = 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" );
ScmTestCase.makeFile( getWorkingCopy(), "/src/test/java/Test.java", "changed Test.java" );
CheckInScmResult checkInResult = provider.checkIn( mainRepository, fileSet, "upstream workspace promote" );
assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );
Thread.sleep( 2000 );
Date timeBeforeDownstreamCheckin = new Date();
Thread.sleep( 2000 );
ScmFileSet updateFileSet = new ScmFileSet( getUpdatingCopy() );
provider.update( mainRepository, updateFileSet );
ScmTestCase.makeFile( getUpdatingCopy(), "/pom.xml", "changed pom.xml" );
ScmTestCase.makeFile( getUpdatingCopy(), "/src/test/java/Test.java", "changed again Test.java" );
checkInResult = provider.checkIn( mainRepository, updateFileSet, "downstream workspace promote" );
assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );
Thread.sleep( 2000 );
Date timeBeforeDownstreamPromote = new Date();
List<File> promotedFiles = new ArrayList<File>();
accurev.promoteStream( subStream, "stream promote", promotedFiles );
Thread.sleep( 2000 );
Date timeEnd = new Date();
// Changelog beforeUpstreamCheckin to end should contain both upstream and downstream changes. upstream change
// should NOT include Test.java
ChangeLogScmResult result =
provider.changeLog( mainRepository, fileSet, timeBeforeUpstreamCheckin, timeEnd, 0, branch );
assertTrue( "changelog beforeUpstreamCheckin to end", result.isSuccess() );
List<ChangeSet> changeSets = result.getChangeLog().getChangeSets();
assertThat( changeSets.size(), is( 2 ) );
assertThat( changeSets, hasItems( changeSet( "Upstream changes", "/readme.txt" ),
changeSet( "downstream workspace promote", "/./pom.xml",
"/./src/test/java/Test.java" ) ) );
// Changelog beforeUpstreamCheckin to beforeDownstreamCheckin should include just upstream change including
// Test.java
result =
provider.changeLog( mainRepository, fileSet, timeBeforeUpstreamCheckin, timeBeforeDownstreamCheckin, 0,
branch );
assertTrue( "changelog beforeUpstreamCheckin to beforeDownstreamCheckin", result.isSuccess() );
changeSets = result.getChangeLog().getChangeSets();
assertThat( changeSets.size(), is( 1 ) );
assertThat( changeSets.get( 0 ), changeSet( "Upstream changes", "/readme.txt", "/src/test/java/Test.java" ) );
// Changelog beforeDownstreamCheckin to end should include just downstream change
result = provider.changeLog( mainRepository, fileSet, timeBeforeDownstreamCheckin, timeEnd, 0, branch );
assertTrue( "changelog beforeDownstreamCheckin to end", result.isSuccess() );
changeSets = result.getChangeLog().getChangeSets();
assertThat( changeSets.size(), is( 1 ) );
assertThat( changeSets.get( 0 ), changeSet( "downstream workspace promote", "/./pom.xml",
"/./src/test/java/Test.java" ) );
// Changelog beforeDownstreamPromote to end should be empty
result = provider.changeLog( mainRepository, fileSet, timeBeforeDownstreamPromote, timeEnd, 0, branch );
assertTrue( "changelog beforeDownstreamPromote to end", result.isSuccess() );
changeSets = result.getChangeLog().getChangeSets();
assertThat( changeSets.size(), is( 0 ) );