Coverage Report - org.apache.maven.surefire.junitcore.JUnitCoreParameters
 
Classes in this File Line Coverage Branch Coverage Complexity
JUnitCoreParameters
93%
14/15
75%
6/8
1,2
 
 1  
 package org.apache.maven.surefire.junitcore;
 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.Properties;
 23  
 import org.apache.maven.surefire.booter.ProviderParameterNames;
 24  
 
 25  
 /**
 26  
  * @author Kristian Rosenvold
 27  
  */
 28  
 class JUnitCoreParameters
 29  
 {
 30  
     private final String parallel;
 31  
 
 32  
     private final Boolean perCoreThreadCount;
 33  
 
 34  
     private final int threadCount;
 35  
 
 36  
     private final Boolean useUnlimitedThreads;
 37  
 
 38  
     public static final String PARALLEL_KEY = ProviderParameterNames.PARALLEL_PROP;
 39  
 
 40  
     public static final String PERCORETHREADCOUNT_KEY = "perCoreThreadCount";
 41  
 
 42  
     public static final String THREADCOUNT_KEY = ProviderParameterNames.THREADCOUNT_PROP;
 43  
 
 44  
     public static final String USEUNLIMITEDTHREADS_KEY = "useUnlimitedThreads";
 45  
 
 46  
     public JUnitCoreParameters( Properties properties )
 47  25
     {
 48  25
         this.parallel = properties.getProperty( PARALLEL_KEY, "none" ).toLowerCase();
 49  25
         this.perCoreThreadCount = Boolean.valueOf( properties.getProperty( PERCORETHREADCOUNT_KEY, "true" ) );
 50  25
         this.threadCount = Integer.valueOf( properties.getProperty( THREADCOUNT_KEY, "2" ) );
 51  25
         this.useUnlimitedThreads = Boolean.valueOf( properties.getProperty( USEUNLIMITEDTHREADS_KEY, "false" ) );
 52  25
     }
 53  
 
 54  
     public boolean isParallelMethod()
 55  
     {
 56  7
         return "methods".equals( parallel );
 57  
     }
 58  
 
 59  
     public boolean isParallelClasses()
 60  
     {
 61  9
         return "classes".equals( parallel );
 62  
     }
 63  
 
 64  
     public boolean isParallelBoth()
 65  
     {
 66  5
         return "both".equals( parallel );
 67  
     }
 68  
 
 69  
     public Boolean isPerCoreThreadCount()
 70  
     {
 71  6
         return perCoreThreadCount;
 72  
     }
 73  
 
 74  
     public int getThreadCount()
 75  
     {
 76  0
         return threadCount;
 77  
     }
 78  
 
 79  
     public Boolean isUseUnlimitedThreads()
 80  
     {
 81  3
         return useUnlimitedThreads;
 82  
     }
 83  
 
 84  
     public boolean isNoThreading()
 85  
     {
 86  6
         return !( isParallelClasses() || isParallelMethod() || isParallelBoth() );
 87  
     }
 88  
 
 89  
     public boolean isAnyParallelitySelected()
 90  
     {
 91  3
         return !isNoThreading();
 92  
     }
 93  
 
 94  
     @Override
 95  
     public String toString()
 96  
     {
 97  1
         return "parallel='" + parallel + '\'' + ", perCoreThreadCount=" + perCoreThreadCount + ", threadCount="
 98  
             + threadCount + ", useUnlimitedThreads=" + useUnlimitedThreads;
 99  
     }
 100  
 }