1 | |
package org.apache.maven.plugin.surefire.booterclient; |
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.plugin.surefire.booterclient.output.OutputConsumer; |
23 | |
import org.apache.maven.surefire.report.ForkingConsoleReporter; |
24 | |
import org.codehaus.plexus.util.cli.StreamConsumer; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class ForkingStreamConsumer |
35 | |
implements StreamConsumer |
36 | |
{ |
37 | 0 | private static final int STANDARD_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_STANDARD.length(); |
38 | |
|
39 | 0 | private static final int HEADING_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_HEADING.length(); |
40 | |
|
41 | 0 | private static final int FOOTER_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_FOOTER.length(); |
42 | |
|
43 | |
private final OutputConsumer outputConsumer; |
44 | |
|
45 | |
public ForkingStreamConsumer( OutputConsumer outputConsumer ) |
46 | 0 | { |
47 | 0 | this.outputConsumer = outputConsumer; |
48 | 0 | } |
49 | |
|
50 | |
public void consumeLine( String line ) |
51 | |
{ |
52 | 0 | if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_HEADING ) ) |
53 | |
{ |
54 | 0 | outputConsumer.consumeHeaderLine( line.substring( HEADING_PREFIX_LENGTH ) ); |
55 | |
} |
56 | 0 | else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_STANDARD ) ) |
57 | |
{ |
58 | 0 | String message = line.substring( STANDARD_PREFIX_LENGTH ); |
59 | 0 | if ( ForkingConsoleReporter.isTestSetStartingMessage( message ) ) |
60 | |
{ |
61 | 0 | outputConsumer.testSetStarting( ForkingConsoleReporter.parseTestSetStartingMessage( message ) ); |
62 | |
} |
63 | 0 | else if ( ForkingConsoleReporter.isTestSetCompletedMessage( message ) ) |
64 | |
{ |
65 | 0 | outputConsumer.testSetCompleted(); |
66 | |
} |
67 | 0 | outputConsumer.consumeMessageLine( message ); |
68 | 0 | } |
69 | 0 | else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_FOOTER ) ) |
70 | |
{ |
71 | 0 | outputConsumer.consumeFooterLine( line.substring( FOOTER_PREFIX_LENGTH ) ); |
72 | |
} |
73 | |
else |
74 | |
{ |
75 | 0 | outputConsumer.consumeOutputLine( line ); |
76 | |
} |
77 | 0 | } |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
public OutputConsumer getOutputConsumer() |
85 | |
{ |
86 | 0 | return this.outputConsumer; |
87 | |
} |
88 | |
|
89 | |
} |