1 package org.apache.maven.surefire.booter;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.Map;
23 import java.util.concurrent.ConcurrentHashMap;
24
25 import static java.util.Collections.unmodifiableMap;
26
27
28
29
30
31
32
33 public enum ForkedProcessEvent
34 {
35 BOOTERCODE_SYSPROPS( "sys-prop" ),
36
37 BOOTERCODE_TESTSET_STARTING( "testset-starting" ),
38 BOOTERCODE_TESTSET_COMPLETED( "testset-completed" ),
39 BOOTERCODE_TEST_STARTING( "test-starting" ),
40 BOOTERCODE_TEST_SUCCEEDED( "test-succeeded" ),
41 BOOTERCODE_TEST_FAILED( "test-failed" ),
42 BOOTERCODE_TEST_SKIPPED( "test-skipped" ),
43 BOOTERCODE_TEST_ERROR( "test-error" ),
44 BOOTERCODE_TEST_ASSUMPTIONFAILURE( "test-assumption-failure" ),
45
46 BOOTERCODE_STDOUT( "std-out-stream" ),
47 BOOTERCODE_STDOUT_NEW_LINE( "std-out-stream-new-line" ),
48 BOOTERCODE_STDERR( "std-err-stream" ),
49 BOOTERCODE_STDERR_NEW_LINE( "std-err-stream-new-line" ),
50
51 BOOTERCODE_CONSOLE_INFO( "console-info-log" ),
52 BOOTERCODE_CONSOLE_DEBUG( "console-debug-log" ),
53 BOOTERCODE_CONSOLE_WARNING( "console-warning-log" ),
54 BOOTERCODE_CONSOLE_ERROR( "console-error-log" ),
55
56 BOOTERCODE_BYE( "bye" ),
57 BOOTERCODE_STOP_ON_NEXT_TEST( "stop-on-next-test" ),
58 BOOTERCODE_NEXT_TEST( "next-test" ),
59
60 BOOTERCODE_JVM_EXIT_ERROR( "jvm-exit-error" );
61
62 public static final String MAGIC_NUMBER = ":maven:surefire:std:out:";
63
64 public static final Map<String, ForkedProcessEvent> EVENTS = events();
65
66 private static Map<String, ForkedProcessEvent> events()
67 {
68 Map<String, ForkedProcessEvent> events = new ConcurrentHashMap<>();
69 for ( ForkedProcessEvent event : values() )
70 {
71 events.put( event.getOpcode(), event );
72 }
73 return unmodifiableMap( events );
74 }
75
76 private final String opcode;
77
78 ForkedProcessEvent( String opcode )
79 {
80 this.opcode = opcode;
81 }
82
83 public String getOpcode()
84 {
85 return opcode;
86 }
87
88 public boolean isSysPropCategory()
89 {
90 return this == BOOTERCODE_SYSPROPS;
91 }
92
93 public boolean isTestCategory()
94 {
95 return this == BOOTERCODE_TESTSET_STARTING
96 || this == BOOTERCODE_TESTSET_COMPLETED
97 || this == BOOTERCODE_TEST_STARTING
98 || this == BOOTERCODE_TEST_SUCCEEDED
99 || this == BOOTERCODE_TEST_FAILED
100 || this == BOOTERCODE_TEST_SKIPPED
101 || this == BOOTERCODE_TEST_ERROR
102 || this == BOOTERCODE_TEST_ASSUMPTIONFAILURE;
103 }
104
105 public boolean isStandardStreamCategory()
106 {
107 return this == BOOTERCODE_STDOUT || this == BOOTERCODE_STDOUT_NEW_LINE
108 || this == BOOTERCODE_STDERR || this == BOOTERCODE_STDERR_NEW_LINE;
109 }
110
111 public boolean isConsoleCategory()
112 {
113 return this == BOOTERCODE_CONSOLE_INFO
114 || this == BOOTERCODE_CONSOLE_DEBUG
115 || this == BOOTERCODE_CONSOLE_WARNING;
116 }
117
118 public boolean isConsoleErrorCategory()
119 {
120 return this == BOOTERCODE_CONSOLE_ERROR;
121 }
122
123 public boolean isControlCategory()
124 {
125 return this == BOOTERCODE_BYE || this == BOOTERCODE_STOP_ON_NEXT_TEST || this == BOOTERCODE_NEXT_TEST;
126 }
127
128 public boolean isJvmExitError()
129 {
130 return this == BOOTERCODE_JVM_EXIT_ERROR;
131 }
132 }