Coverage Report - org.apache.maven.surefire.booter.ForkingWriterStreamConsumer
 
Classes in this File Line Coverage Branch Coverage Complexity
ForkingWriterStreamConsumer
0%
0/19
0%
0/10
3.5
 
 1  
 package org.apache.maven.surefire.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 org.apache.maven.surefire.report.ForkingConsoleReporter;
 23  
 import org.codehaus.plexus.util.cli.StreamConsumer;
 24  
 
 25  
 import java.io.PrintWriter;
 26  
 import java.io.Writer;
 27  
 
 28  
 /**
 29  
  * @author Jason van Zyl
 30  
  * @version $Revision: 682222 $
 31  
  * @deprecated use {@link org.apache.maven.surefire.booter.output.ForkingStreamConsumer}
 32  
  */
 33  
 public class ForkingWriterStreamConsumer
 34  
     implements StreamConsumer
 35  
 {
 36  
     private PrintWriter printWriter;
 37  
 
 38  
     private int standardPrefixLength;
 39  
 
 40  
     private int headingPrefixLength;
 41  
 
 42  
     private boolean showHeading;
 43  
 
 44  
     private int footerPrefixLength;
 45  
 
 46  
     private boolean showFooter;
 47  
 
 48  
     public ForkingWriterStreamConsumer( Writer writer, boolean showHeading, boolean showFooter )
 49  0
     {
 50  0
         this.showHeading = showHeading;
 51  
 
 52  0
         this.showFooter = showFooter;
 53  
 
 54  0
         printWriter = new PrintWriter( writer );
 55  
 
 56  0
         standardPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_STANDARD.length();
 57  
 
 58  0
         headingPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_HEADING.length();
 59  
 
 60  0
         footerPrefixLength = ForkingConsoleReporter.FORKING_PREFIX_FOOTER.length();
 61  0
     }
 62  
 
 63  
     public void consumeLine( String line )
 64  
     {
 65  0
         if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_HEADING ) )
 66  
         {
 67  0
             if ( showHeading )
 68  
             {
 69  0
                 printWriter.println( line.substring( headingPrefixLength ) );
 70  
             }
 71  
         }
 72  0
         else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_STANDARD ) )
 73  
         {
 74  0
             printWriter.println( line.substring( standardPrefixLength ) );
 75  
         }
 76  0
         else if ( line.startsWith( ForkingConsoleReporter.FORKING_PREFIX_FOOTER ) )
 77  
         {
 78  0
             if ( showFooter )
 79  
             {
 80  0
                 printWriter.println( line.substring( footerPrefixLength ) );
 81  
             }
 82  
         }
 83  
         else
 84  
         {
 85  
             // stdout
 86  0
             printWriter.println( line );
 87  
         }
 88  0
         printWriter.flush();
 89  0
     }
 90  
 }