Coverage Report - org.apache.maven.plugin.surefire.CommonReflector
 
Classes in this File Line Coverage Branch Coverage Complexity
CommonReflector
0%
0/14
0%
0/12
1.667
 
 1  
 package org.apache.maven.plugin.surefire;
 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.lang.reflect.Constructor;
 24  
 import org.apache.maven.plugin.surefire.report.FileReporterFactory;
 25  
 import org.apache.maven.surefire.booter.StartupReportConfiguration;
 26  
 import org.apache.maven.surefire.util.ReflectionUtils;
 27  
 import org.apache.maven.surefire.util.SurefireReflectionException;
 28  
 
 29  
 /**
 30  
  * @author Kristian Rosenvold
 31  
  */
 32  
 public class CommonReflector
 33  
 {
 34  
     private final Class startupReportConfiguration;
 35  
 
 36  
     private final ClassLoader surefireClassLoader;
 37  
 
 38  
     public CommonReflector( ClassLoader surefireClassLoader )
 39  0
     {
 40  0
         this.surefireClassLoader = surefireClassLoader;
 41  
 
 42  
         try
 43  
         {
 44  0
             startupReportConfiguration = surefireClassLoader.loadClass( StartupReportConfiguration.class.getName() );
 45  
         }
 46  0
         catch ( ClassNotFoundException e )
 47  
         {
 48  0
             throw new SurefireReflectionException( e );
 49  0
         }
 50  0
     }
 51  
 
 52  
     public Object createReportingReporterFactory( StartupReportConfiguration startupReportConfiguration )
 53  
     {
 54  0
         Class[] args = new Class[]{ this.startupReportConfiguration };
 55  0
         Object src = createStartupReportConfiguration( startupReportConfiguration );
 56  0
         Object[] params = new Object[]{ src };
 57  0
         return ReflectionUtils.instantiateObject( FileReporterFactory.class.getName(), args, params,
 58  
                                                   surefireClassLoader );
 59  
     }
 60  
 
 61  
 
 62  
     Object createStartupReportConfiguration( StartupReportConfiguration reporterConfiguration )
 63  
     {
 64  0
         Constructor constructor = ReflectionUtils.getConstructor( this.startupReportConfiguration,
 65  
                                                                   new Class[]{ boolean.class, boolean.class,
 66  
                                                                       String.class, boolean.class, boolean.class,
 67  
                                                                       File.class, boolean.class, String.class,
 68  
                                                                       String.class, boolean.class } );
 69  
         //noinspection BooleanConstructorCall
 70  0
         final Object[] params =
 71  
             { new Boolean( reporterConfiguration.isUseFile() ), new Boolean( reporterConfiguration.isPrintSummary() ),
 72  
                 reporterConfiguration.getReportFormat(),
 73  
                 new Boolean( reporterConfiguration.isRedirectTestOutputToFile() ),
 74  
                 new Boolean( reporterConfiguration.isDisableXmlReport() ), reporterConfiguration.getReportsDirectory(),
 75  
                 new Boolean( reporterConfiguration.isTrimStackTrace() ), reporterConfiguration.getReportNameSuffix(),
 76  
                 reporterConfiguration.getConfigurationHash(),
 77  
                 Boolean.valueOf( reporterConfiguration.isRequiresRunHistory() ) };
 78  0
         return ReflectionUtils.newInstance( constructor, params );
 79  
     }
 80  
 
 81  
 }