Coverage Report - org.apache.maven.surefire.booter.output.ForkingStreamConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
ForkingStreamConsumer
95%
20/21
100%
10/10
2.667
 
 1  
 package org.apache.maven.surefire.booter.output;
 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 org.apache.maven.surefire.report.ForkingConsoleReporter;
 23  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 24  
 
 25  
 /**
 26  
  * {@link StreamConsumer} that understands Surefire output made by {@link ForkingConsoleReporter}
 27  
  * and filters it depending on configuration options
 28  
  *
 29  
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
 30  
  * @version $Id: ForkingStreamConsumer.java 682222 2008-08-03 21:44:16Z hboutemy $
 31  
  * @since 2.1
 32  
  */
 33  
 public class ForkingStreamConsumer
 34  
     implements StreamConsumer
 35  
 {
 36  4
     private final static int STANDARD_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_STANDARD.length();
 37  
 
 38  4
     private final static int HEADING_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_HEADING.length();
 39  
 
 40  4
     private final static int FOOTER_PREFIX_LENGTH = ForkingConsoleReporter.FORKING_PREFIX_FOOTER.length();
 41  
 
 42  
     private OutputConsumer outputConsumer;
 43  
 
 44  
     public ForkingStreamConsumer( OutputConsumer outputConsumer )
 45  24
     {
 46  24
         this.outputConsumer = outputConsumer;
 47  24
     }
 48  
 
 49  
     public void consumeLine( String line )
 50  
     {
 51  24
         if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_HEADING ) )
 52  
         {
 53  4
             outputConsumer.consumeHeaderLine( line.substring( HEADING_PREFIX_LENGTH ) );
 54  
         }
 55  20
         else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_STANDARD ) )
 56  
         {
 57  12
             String message = line.substring( STANDARD_PREFIX_LENGTH );
 58  12
             if ( ForkingConsoleReporter.isTestSetStartingMessage( message ) )
 59  
             {
 60  4
                 outputConsumer.testSetStarting( ForkingConsoleReporter.parseTestSetStartingMessage( message ) );
 61  
             }
 62  8
             else if ( ForkingConsoleReporter.isTestSetCompletedMessage( message ) )
 63  
             {
 64  4
                 outputConsumer.testSetCompleted();
 65  
             }
 66  12
             outputConsumer.consumeMessageLine( message );
 67  12
         }
 68  8
         else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_FOOTER ) )
 69  
         {
 70  4
             outputConsumer.consumeFooterLine( line.substring( FOOTER_PREFIX_LENGTH ) );
 71  
         }
 72  
         else
 73  
         {
 74  4
             outputConsumer.consumeOutputLine( line );
 75  
         }
 76  24
     }
 77  
 
 78  
     /**
 79  
      * Get the underlying output consumer.
 80  
      */
 81  
     public OutputConsumer getOutputConsumer()
 82  
     {
 83  0
         return this.outputConsumer;
 84  
     }
 85  
 
 86  
 }