1 package org.apache.maven.scm.tck.command.changelog;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import org.apache.maven.scm.ChangeSet;
23 import org.apache.maven.scm.ScmBranch;
24 import org.apache.maven.scm.ScmFileSet;
25 import org.apache.maven.scm.ScmTckTestCase;
26 import org.apache.maven.scm.ScmTestCase;
27 import org.apache.maven.scm.ScmVersion;
28 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
29 import org.apache.maven.scm.command.checkin.CheckInScmResult;
30 import org.apache.maven.scm.provider.ScmProvider;
31
32 import java.util.Date;
33
34
35
36
37
38
39
40
41
42
43
44 public abstract class ChangeLogCommandTckTest
45 extends ScmTckTestCase
46 {
47 private static final String COMMIT_MSG = "Second changelog";
48
49 public void testChangeLogCommand()
50 throws Exception
51 {
52 Thread.sleep( 1000 );
53 ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() );
54 ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
55
56 ChangeLogScmResult firstResult =
57 provider.changeLog( getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null );
58 assertTrue( firstResult.getProviderMessage() + ": " + firstResult.getCommandLine() + "\n"
59 + firstResult.getCommandOutput(), firstResult.isSuccess() );
60
61
62 int firstLogSize = firstResult.getChangeLog().getChangeSets().size();
63 assertTrue( "Unexpected initial log size", firstLogSize >= 1 );
64
65
66 Date timeBeforeSecond = new Date();
67
68
69 Thread.sleep( 2000 );
70
71
72 this.edit( getWorkingCopy(), "readme.txt", null, getScmRepository() );
73 ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
74 CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG );
75 assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );
76
77 ChangeLogScmResult secondResult = provider.changeLog( getScmRepository(), fileSet, (ScmVersion) null, null );
78 assertTrue( secondResult.getProviderMessage(), secondResult.isSuccess() );
79 assertEquals( firstLogSize + 1, secondResult.getChangeLog().getChangeSets().size() );
80
81
82 Date currentTime = new Date();
83 ChangeLogScmResult thirdResult = provider
84 .changeLog( getScmRepository(), fileSet, timeBeforeSecond, currentTime, 0, new ScmBranch( "" ) );
85
86
87 assertTrue( thirdResult.getProviderMessage(), thirdResult.isSuccess() );
88 assertEquals( 1, thirdResult.getChangeLog().getChangeSets().size() );
89 ChangeSet changeset = thirdResult.getChangeLog().getChangeSets().get( 0 );
90 assertTrue( changeset.getDate().after( timeBeforeSecond ) );
91
92
93 assertEquals( COMMIT_MSG, changeset.getComment() );
94 }
95 }