Coverage Report - org.apache.maven.plugin.surefire.booterclient.ForkingStreamConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
ForkingStreamConsumer
0%
0/21
0%
0/10
2.667
 
 1  
 package org.apache.maven.plugin.surefire.booterclient;
 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.plugin.surefire.booterclient.output.OutputConsumer;
 23  
 import org.apache.maven.surefire.report.ForkingConsoleReporter;
 24  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 25  
 
 26  
 /**
 27  
  * {@link StreamConsumer} that understands Surefire output made by {@link ForkingConsoleReporter}
 28  
  * and filters it depending on configuration options
 29  
  *
 30  
  * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
 31  
  * @version $Id: ForkingStreamConsumer.java 1050534 2010-12-17 23:54:50Z hboutemy $
 32  
  * @since 2.1
 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  
      * Get the underlying output consumer.
 81  
      *
 82  
      * @return the output consumer
 83  
      */
 84  
     public OutputConsumer getOutputConsumer()
 85  
     {
 86  0
         return this.outputConsumer;
 87  
     }
 88  
 
 89  
 }