View Javadoc
1   package org.apache.maven.surefire.api.booter;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *     http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import static java.nio.charset.StandardCharsets.US_ASCII;
23  
24  /**
25   * Events sent back to the plugin process.
26   *
27   * @author <a href="mailto:tibordigana@apache.org">Tibor Digana (tibor17)</a>
28   * @since 3.0.0-M4
29   */
30  @SuppressWarnings( "checkstyle:linelength" )
31  public enum ForkedProcessEventType
32  {
33      /**
34       * This is the opcode "sys-prop". The frame is composed of segments and the separator characters ':'
35       * <pre>
36       * :maven-surefire-event:sys-prop:RunMode:0x0000000100000000:5:UTF-8:0xFFFFFFFF:key:0xFFFFFFFF:value:
37       * </pre>
38       * The constructor with one argument:
39       * <ul>
40       *     <li>the opcode is "sys-prop"
41       * </ul>
42       */
43      BOOTERCODE_SYSPROPS( "sys-prop"  ),
44  
45      /**
46       * This is the opcode "testset-starting". The frame is composed of segments and the separator characters ':'
47       * <pre>
48       * :maven-surefire-event:testset-starting:RunMode:0x0000000100000000:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
49       * </pre>
50       * The constructor with one argument:
51       * <ul>
52       *     <li>the opcode is "testset-starting"
53       * </ul>
54       */
55      BOOTERCODE_TESTSET_STARTING( "testset-starting" ),
56  
57      /**
58       * This is the opcode "testset-completed". The frame is composed of segments and the separator characters ':'
59       * <pre>
60       * :maven-surefire-event:testset-completed:RunMode:0x0000000100000000:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
61       * </pre>
62       * The constructor with one argument:
63       * <ul>
64       *     <li>the opcode is "testset-completed"
65       * </ul>
66       */
67      BOOTERCODE_TESTSET_COMPLETED( "testset-completed" ),
68  
69      /**
70       * This is the opcode "test-starting". The frame is composed of segments and the separator characters ':'
71       * <pre>
72       * :maven-surefire-event:test-starting:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
73       * </pre>
74       * The constructor with one argument:
75       * <ul>
76       *     <li>the opcode is "test-starting"
77       * </ul>
78       */
79      BOOTERCODE_TEST_STARTING( "test-starting" ),
80  
81      /**
82       * This is the opcode "test-succeeded". The frame is composed of segments and the separator characters ':'
83       * <pre>
84       * :maven-surefire-event:test-succeeded:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
85       * </pre>
86       * The constructor with one argument:
87       * <ul>
88       *     <li>the opcode is "test-succeeded"
89       * </ul>
90       */
91      BOOTERCODE_TEST_SUCCEEDED( "test-succeeded" ),
92  
93      /**
94       * This is the opcode "test-failed". The frame is composed of segments and the separator characters ':'
95       * <pre>
96       * :maven-surefire-event:test-failed:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
97       * </pre>
98       * The constructor with one argument:
99       * <ul>
100      *     <li>the opcode is "test-failed"
101      * </ul>
102      */
103     BOOTERCODE_TEST_FAILED( "test-failed" ),
104 
105     /**
106      * This is the opcode "test-skipped". The frame is composed of segments and the separator characters ':'
107      * <pre>
108      * :maven-surefire-event:test-skipped:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
109      * </pre>
110      * The constructor with one argument:
111      * <ul>
112      *     <li>the opcode is "test-skipped"
113      * </ul>
114      */
115     BOOTERCODE_TEST_SKIPPED( "test-skipped" ),
116 
117     /**
118      * This is the opcode "test-error". The frame is composed of segments and the separator characters ':'
119      * <pre>
120      * :maven-surefire-event:test-error:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
121      * </pre>
122      * The constructor with one argument:
123      * <ul>
124      *     <li>the opcode is "test-error"
125      * </ul>
126      */
127     BOOTERCODE_TEST_ERROR( "test-error" ),
128 
129     /**
130      * This is the opcode "test-assumption-failure". The frame is composed of segments and the separator characters ':'
131      * <pre>
132      * :maven-surefire-event:test-assumption-failure:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:SourceName:0xFFFFFFFF:SourceText:0xFFFFFFFF:Name:0xFFFFFFFF:NameText:0xFFFFFFFF:Group:0xFFFFFFFF:Message:ElapsedTime (binary int):0xFFFFFFFF:LocalizedMessage:0xFFFFFFFF:SmartTrimmedStackTrace:0xFFFFFFFF:toStackTrace( stw, trimStackTraces ):
133      * </pre>
134      * The constructor with one argument:
135      * <ul>
136      *     <li>the opcode is "test-assumption-failure"
137      * </ul>
138      */
139     BOOTERCODE_TEST_ASSUMPTIONFAILURE( "test-assumption-failure" ),
140 
141     /**
142      * This is the opcode "std-out-stream". The frame is composed of segments and the separator characters ':'
143      * <pre>
144      * :maven-surefire-event:std-out-stream:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:line:
145      * </pre>
146      * The constructor with one argument:
147      * <ul>
148      *     <li>the opcode is "std-out-stream"
149      * </ul>
150      */
151     BOOTERCODE_STDOUT( "std-out-stream" ),
152 
153     /**
154      * This is the opcode "std-out-stream-new-line". The frame is composed of segments and the separator characters ':'
155      * <pre>
156      * :maven-surefire-event:std-out-stream-new-line:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:line:
157      * </pre>
158      * The constructor with one argument:
159      * <ul>
160      *     <li>the opcode is "std-out-stream-new-line"
161      * </ul>
162      */
163     BOOTERCODE_STDOUT_NEW_LINE( "std-out-stream-new-line" ),
164 
165     /**
166      * This is the opcode "std-err-stream". The frame is composed of segments and the separator characters ':'
167      * <pre>
168      * :maven-surefire-event:std-err-stream:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:line:
169      * </pre>
170      * The constructor with one argument:
171      * <ul>
172      *     <li>the opcode is "std-err-stream"
173      * </ul>
174      */
175     BOOTERCODE_STDERR( "std-err-stream" ),
176 
177     /**
178      * This is the opcode "std-err-stream-new-line". The frame is composed of segments and the separator characters ':'
179      * <pre>
180      * :maven-surefire-event:std-err-stream-new-line:RunMode:0x0000000100000001:5:UTF-8:0xFFFFFFFF:line:
181      * </pre>
182      * The constructor with one argument:
183      * <ul>
184      *     <li>the opcode is "std-err-stream-new-line"
185      * </ul>
186      */
187     BOOTERCODE_STDERR_NEW_LINE( "std-err-stream-new-line" ),
188 
189     /**
190      * This is the opcode "console-info-log". The frame is composed of segments and the separator characters ':'
191      * <pre>
192      * :maven-surefire-event:console-info-log:RunMode:5:UTF-8:0xFFFFFFFF:line:
193      * </pre>
194      * The constructor with one argument:
195      * <ul>
196      *     <li>the opcode is "console-info-log"
197      * </ul>
198      */
199     BOOTERCODE_CONSOLE_INFO( "console-info-log" ),
200 
201     /**
202      * This is the opcode "console-debug-log". The frame is composed of segments and the separator characters ':'
203      * <pre>
204      * :maven-surefire-event:console-debug-log:RunMode:5:UTF-8:0xFFFFFFFF:line:
205      * </pre>
206      * The constructor with one argument:
207      * <ul>
208      *     <li>the opcode is "console-debug-log"
209      * </ul>
210      */
211     BOOTERCODE_CONSOLE_DEBUG( "console-debug-log" ),
212 
213     /**
214      * This is the opcode "console-warning-log". The frame is composed of segments and the separator characters ':'
215      * <pre>
216      * :maven-surefire-event:console-warning-log:RunMode:5:UTF-8:0xFFFFFFFF:line:
217      * </pre>
218      * The constructor with one argument:
219      * <ul>
220      *     <li>the opcode is "console-warning-log"
221      * </ul>
222      */
223     BOOTERCODE_CONSOLE_WARNING( "console-warning-log" ),
224 
225     /**
226      * This is the opcode "console-error-log". The frame is composed of segments and the separator characters ':'
227      * <pre>
228      * :maven-surefire-event:console-error-log:RunMode:5:UTF-8:0xFFFFFFFF:line:
229      * </pre>
230      * The constructor with one argument:
231      * <ul>
232      *     <li>the opcode is "console-error-log"
233      * </ul>
234      */
235     BOOTERCODE_CONSOLE_ERROR( "console-error-log" ),
236 
237     /**
238      * This is the opcode "bye". The frame is composed of segments and the separator characters ':'
239      * <pre>
240      * :maven-surefire-event:bye:
241      * </pre>
242      * The constructor with one argument:
243      * <ul>
244      *     <li>the opcode is "bye"
245      * </ul>
246      */
247     BOOTERCODE_BYE( "bye" ),
248 
249     /**
250      * This is the opcode "stop-on-next-test". The frame is composed of segments and the separator characters ':'
251      * <pre>
252      * :maven-surefire-event:stop-on-next-test:
253      * </pre>
254      * The constructor with one argument:
255      * <ul>
256      *     <li>the opcode is "stop-on-next-test"
257      * </ul>
258      */
259     BOOTERCODE_STOP_ON_NEXT_TEST( "stop-on-next-test" ),
260 
261     /**
262      * This is the opcode "next-test". The frame is composed of segments and the separator characters ':'
263      * <pre>
264      * :maven-surefire-event:next-test:
265      * </pre>
266      * The constructor with one argument:
267      * <ul>
268      *     <li>the opcode is "next-test"
269      * </ul>
270      */
271     BOOTERCODE_NEXT_TEST( "next-test" ),
272 
273     /**
274      * This is the opcode "jvm-exit-error". The frame is composed of segments and the separator characters ':'
275      * <pre>
276      * :maven-surefire-event:jvm-exit-error:
277      * </pre>
278      * The constructor with one argument:
279      * <ul>
280      *     <li>the opcode is "jvm-exit-error"
281      * </ul>
282      */
283     BOOTERCODE_JVM_EXIT_ERROR( "jvm-exit-error" );
284 
285     private final String opcode;
286     private final byte[] opcodeBinary;
287 
288     ForkedProcessEventType( String opcode )
289     {
290         this.opcode = opcode;
291         opcodeBinary = opcode.getBytes( US_ASCII );
292     }
293 
294     public String getOpcode()
295     {
296         return opcode;
297     }
298 
299     public byte[] getOpcodeBinary()
300     {
301         return opcodeBinary;
302     }
303 
304     public boolean isSysPropCategory()
305     {
306         return this == BOOTERCODE_SYSPROPS;
307     }
308 
309     public boolean isTestCategory()
310     {
311         return this == BOOTERCODE_TESTSET_STARTING
312                 || this == BOOTERCODE_TESTSET_COMPLETED
313                 || this == BOOTERCODE_TEST_STARTING
314                 || this == BOOTERCODE_TEST_SUCCEEDED
315                 || this == BOOTERCODE_TEST_FAILED
316                 || this == BOOTERCODE_TEST_SKIPPED
317                 || this == BOOTERCODE_TEST_ERROR
318                 || this == BOOTERCODE_TEST_ASSUMPTIONFAILURE;
319     }
320 
321     public boolean isStandardStreamCategory()
322     {
323         return this == BOOTERCODE_STDOUT || this == BOOTERCODE_STDOUT_NEW_LINE
324                 || this == BOOTERCODE_STDERR || this == BOOTERCODE_STDERR_NEW_LINE;
325     }
326 
327     public boolean isConsoleCategory()
328     {
329         return this == BOOTERCODE_CONSOLE_INFO
330                 || this == BOOTERCODE_CONSOLE_DEBUG
331                 || this == BOOTERCODE_CONSOLE_WARNING;
332     }
333 
334     public boolean isConsoleErrorCategory()
335     {
336         return this == BOOTERCODE_CONSOLE_ERROR;
337     }
338 
339     public boolean isControlCategory()
340     {
341         return this == BOOTERCODE_BYE || this == BOOTERCODE_STOP_ON_NEXT_TEST || this == BOOTERCODE_NEXT_TEST;
342     }
343 
344     public boolean isJvmExitError()
345     {
346         return this == BOOTERCODE_JVM_EXIT_ERROR;
347     }
348 }