1 package org.apache.maven.scm.provider.perforce.command.unedit;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.io.File;
23 import java.util.List;
24
25 import org.apache.maven.scm.ScmFile;
26 import org.apache.maven.scm.ScmTestCase;
27 import org.apache.maven.scm.util.ConsumerUtils;
28
29
30
31
32 public class PerforceUnEditConsumerTest
33 extends ScmTestCase
34 {
35 public void testGoodParse()
36 throws Exception
37 {
38 File testFile = getTestFile( "src/test/resources/perforce/unedit_good.txt" );
39
40 PerforceUnEditConsumer consumer = new PerforceUnEditConsumer();
41
42 ConsumerUtils.consumeFile( testFile, consumer );
43
44 assertTrue( consumer.isSuccess() );
45 List<ScmFile> edits = consumer.getEdits();
46 assertEquals( "Wrong number of entries returned", 2, edits.size() );
47 String entry = edits.get( 0 ).getPath();
48 assertTrue( entry.startsWith( "//" ) );
49 assertTrue( entry.endsWith( ".classpath" ) );
50 }
51
52 public void testBadParse()
53 throws Exception
54 {
55 File testFile = getTestFile( "src/test/resources/perforce/unedit_bad.txt" );
56
57 PerforceUnEditConsumer consumer = new PerforceUnEditConsumer();
58
59 ConsumerUtils.consumeFile( testFile, consumer );
60
61 assertFalse( consumer.isSuccess() );
62 assertTrue( consumer.getOutput().indexOf( ".classpath - file(s) not opened on this client." ) == 0 );
63 assertTrue( consumer.getOutput().indexOf( ".project - file(s) not opened on this client." ) > 0 );
64 }
65 }