Coverage Report - org.apache.maven.plugin.surefire.util.ScannerUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
ScannerUtil
94%
17/18
83%
5/6
1,6
 
 1  
 package org.apache.maven.plugin.surefire.util;
 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.util.ArrayList;
 23  
 import java.util.Collections;
 24  
 import java.util.List;
 25  
 
 26  
 import org.apache.commons.lang3.StringUtils;
 27  
 
 28  
 import javax.annotation.Nonnull;
 29  
 
 30  
 final class ScannerUtil {
 31  
 
 32  0
         private ScannerUtil() {}
 33  
 
 34  1
     private static final String FS = System.getProperty( "file.separator" );
 35  
 
 36  
     private static final String JAVA_SOURCE_FILE_EXTENSION = ".java";
 37  
 
 38  
     private static final String JAVA_CLASS_FILE_EXTENSION = ".class";
 39  
 
 40  
     public static @Nonnull String convertToJavaClassName( @Nonnull String test )
 41  
     {
 42  3
         return StringUtils.removeEnd( test, ".class" ).replace( FS, "." );
 43  
     }
 44  
 
 45  
     public static @Nonnull String convertJarFileResourceToJavaClassName( @Nonnull String test )
 46  
     {
 47  1
         return StringUtils.removeEnd( test, ".class" ).replace( "/", "." );
 48  
     }
 49  
 
 50  
     public static @Nonnull String stripBaseDir( String basedir, String test )
 51  
     {
 52  3
         return StringUtils.removeStart( test, basedir );
 53  
     }
 54  
 
 55  
     public static @Nonnull String[] processIncludesExcludes( @Nonnull List<String> list )
 56  
     {
 57  6
         List<String> newList = new ArrayList<String>();
 58  6
         for ( Object aList : list )
 59  
         {
 60  2
             String include = (String) aList;
 61  2
             String[] includes = include.split( "," );
 62  2
             Collections.addAll( newList, includes );
 63  2
         }
 64  
 
 65  6
         String[] incs = new String[newList.size()];
 66  
 
 67  8
         for ( int i = 0; i < incs.length; i++ )
 68  
         {
 69  2
             String inc = newList.get( i );
 70  2
             if ( inc.endsWith( JAVA_SOURCE_FILE_EXTENSION ) )
 71  
             {
 72  2
                 inc = StringUtils.removeEnd( inc, JAVA_SOURCE_FILE_EXTENSION ) + JAVA_CLASS_FILE_EXTENSION;
 73  
             }
 74  2
             incs[i] = inc;
 75  
 
 76  
         }
 77  6
         return incs;
 78  
     }
 79  
 }