1 | |
package org.apache.maven.scm.tck.command.tag; |
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.ScmFileSet; |
23 | |
import org.apache.maven.scm.ScmTag; |
24 | |
import org.apache.maven.scm.ScmTckTestCase; |
25 | |
import org.apache.maven.scm.command.checkin.CheckInScmResult; |
26 | |
import org.apache.maven.scm.command.checkout.CheckOutScmResult; |
27 | |
import org.apache.maven.scm.command.tag.TagScmResult; |
28 | |
import org.codehaus.plexus.util.FileUtils; |
29 | |
import org.codehaus.plexus.util.IOUtil; |
30 | |
|
31 | |
import java.io.File; |
32 | |
import java.io.FileWriter; |
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | 0 | public abstract class TagCommandTckTest |
41 | |
extends ScmTckTestCase |
42 | |
{ |
43 | |
|
44 | |
public void testTagCommandTest() |
45 | |
throws Exception |
46 | |
{ |
47 | 0 | String tag = "test-tag"; |
48 | |
|
49 | 0 | @SuppressWarnings( "deprecation" ) TagScmResult tagResult = |
50 | |
getScmManager().getProviderByUrl( getScmUrl() ).tag( getScmRepository(), new ScmFileSet( getWorkingCopy() ), |
51 | |
tag ); |
52 | |
|
53 | 0 | assertResultIsSuccess( tagResult ); |
54 | |
|
55 | 0 | assertEquals( "check all 4 files tagged", 4, tagResult.getTaggedFiles().size() ); |
56 | |
|
57 | 0 | File readmeTxt = new File( getWorkingCopy(), "readme.txt" ); |
58 | |
|
59 | 0 | assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt ) ); |
60 | |
|
61 | 0 | changeReadmeTxt( readmeTxt ); |
62 | |
|
63 | 0 | CheckInScmResult checkinResult = |
64 | |
getScmManager().checkIn( getScmRepository(), new ScmFileSet( getWorkingCopy() ), "commit message" ); |
65 | |
|
66 | 0 | assertResultIsSuccess( checkinResult ); |
67 | |
|
68 | 0 | CheckOutScmResult checkoutResult = |
69 | |
getScmManager().checkOut( getScmRepository(), new ScmFileSet( getAssertionCopy() ) ); |
70 | |
|
71 | 0 | assertResultIsSuccess( checkoutResult ); |
72 | |
|
73 | 0 | readmeTxt = new File( getAssertionCopy(), "readme.txt" ); |
74 | |
|
75 | 0 | assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead( readmeTxt ) ); |
76 | |
|
77 | 0 | FileUtils.deleteDirectory( getAssertionCopy() ); |
78 | |
|
79 | 0 | assertFalse( "check previous assertion copy deleted", getAssertionCopy().exists() ); |
80 | |
|
81 | 0 | checkoutResult = getScmManager().getProviderByUrl( getScmUrl() ).checkOut( getScmRepository(), |
82 | |
new ScmFileSet( getAssertionCopy() ), |
83 | |
new ScmTag( tag ) ); |
84 | |
|
85 | 0 | assertResultIsSuccess( checkoutResult ); |
86 | |
|
87 | 0 | assertEquals( "check readme.txt contents is from tagged version", "/readme.txt", |
88 | |
FileUtils.fileRead( readmeTxt ) ); |
89 | 0 | } |
90 | |
|
91 | |
private void changeReadmeTxt( File readmeTxt ) |
92 | |
throws Exception |
93 | |
{ |
94 | 0 | FileWriter output = new FileWriter( readmeTxt ); |
95 | |
try |
96 | |
{ |
97 | 0 | output.write( "changed file" ); |
98 | |
} |
99 | |
finally |
100 | |
{ |
101 | 0 | IOUtil.close( output ); |
102 | 0 | } |
103 | |
|
104 | 0 | } |
105 | |
} |