Coverage Report - org.apache.maven.surefire.report.ReporterConfiguration
 
Classes in this File Line Coverage Branch Coverage Complexity
ReporterConfiguration
0 %
0/21
0 %
0/2
1
 
 1  
 package org.apache.maven.surefire.report;
 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 java.io.File;
 23  
 import java.io.PrintStream;
 24  
 import java.util.List;
 25  
 import java.util.Timer;
 26  
 
 27  
 /**
 28  
  * @author Kristian Rosenvold
 29  
  */
 30  
 public class ReporterConfiguration
 31  
 {
 32  
     private final List reports;
 33  
 
 34  
     private final File reportsDirectory;
 35  
 
 36  
     private final PrintStream originalSystemOut;
 37  
 
 38  
     private final PrintStream originalSystemErr;
 39  
 
 40  
     private final Integer forkTimeout;
 41  
 
 42  
     /**
 43  
      * A non-null Boolean value
 44  
      */
 45  
     private final Boolean trimStackTrace;
 46  
 
 47  0
     private volatile boolean timedOut = false;
 48  
 
 49  
 
 50  
     public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace, Integer forkWithTimeout )
 51  0
     {
 52  0
         this.reports = reports;
 53  0
         this.reportsDirectory = reportsDirectory;
 54  0
         this.trimStackTrace = trimStackTrace;
 55  0
         this.forkTimeout = forkWithTimeout;
 56  
         /*
 57  
         * While this may seem slightly odd, when this object is constructted no user code has been run
 58  
         * (including classloading), and we can be guaranteed that no-one has modified System.out/System.err.
 59  
         * As soon as we start loading user code, all h*ll breaks loose in this respect.
 60  
          */
 61  0
         this.originalSystemOut = System.out;
 62  0
         this.originalSystemErr = System.err;
 63  
 
 64  0
     }
 65  
 
 66  
     // todo: remove once we build with 2.7.2
 67  
     public ReporterConfiguration( List reports, File reportsDirectory, Boolean trimStackTrace )
 68  
     {
 69  0
         this( reports, reportsDirectory, trimStackTrace, null );
 70  0
     }
 71  
 
 72  
     /**
 73  
      * The directory where reports will be created, normally ${project.build.directory}/surefire-reports
 74  
      *
 75  
      * @return A file pointing at the specified directory
 76  
      */
 77  
     public File getReportsDirectory()
 78  
     {
 79  0
         return reportsDirectory;
 80  
     }
 81  
 
 82  
     /**
 83  
      * Indicates if reporting should trim the stack traces.
 84  
      *
 85  
      * @return true if stacktraces should be trimmed in reporting
 86  
      */
 87  
     public Boolean isTrimStackTrace()
 88  
     {
 89  0
         return trimStackTrace;
 90  
     }
 91  
 
 92  
     /**
 93  
      * A list of classnames representing runnable reports for this test-run.
 94  
      *
 95  
      * @return A list of strings, each string is a classname of a class
 96  
      *         implementing the org.apache.maven.surefire.report.Reporter interface
 97  
      */
 98  
     public List getReports()
 99  
     {
 100  0
         return reports;
 101  
     }
 102  
 
 103  
     /**
 104  
      * The original system out belonging to the (possibly forked) surefire process.
 105  
      * Note that users of Reporter/ReporterFactory should normally not be using this.
 106  
      *
 107  
      * @return A printstream.
 108  
      */
 109  
     public PrintStream getOriginalSystemOut()
 110  
     {
 111  0
         return originalSystemOut;
 112  
     }
 113  
 
 114  
     /**
 115  
      * The original system err belonging to the (possibly forked) surefire process.
 116  
      * Note that users of Reporter/ReporterFactory should normally not be using this.
 117  
      *
 118  
      * @return A printstream.
 119  
      */
 120  
     public PrintStream getOriginalSystemErr()
 121  
     {
 122  0
         return originalSystemErr;
 123  
     }
 124  
 
 125  
     /**
 126  
      * Indicates that the test is running timed out, meaning this process could be abruptly killed.
 127  
      * This will normally tell the reporter to delete result files upon startup.
 128  
      *
 129  
      * @return true if test run can be killed by timeout
 130  
      */
 131  
     public boolean isForkWithTimeout()
 132  
     {
 133  0
         return getForkTimeout() != null;
 134  
     }
 135  
 
 136  
     public Integer getForkTimeout()
 137  
     {
 138  0
         return forkTimeout;
 139  
     }
 140  
 
 141  
     public void setTimedOut( boolean timedOut )
 142  
     {
 143  0
         this.timedOut = timedOut;
 144  0
     }
 145  
 
 146  
     public boolean isTimedOut()
 147  
     {
 148  0
         return this.timedOut;
 149  
     }
 150  
 }