Coverage Report - org.apache.maven.model.converter.plugins.PCCSurefire
 
Classes in this File Line Coverage Branch Coverage Complexity
PCCSurefire
77%
34/44
53%
16/30
5
 
 1  
 package org.apache.maven.model.converter.plugins;
 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.model.converter.ProjectConverterException;
 23  
 import org.codehaus.plexus.util.xml.Xpp3Dom;
 24  
 
 25  
 import java.util.Iterator;
 26  
 import java.util.List;
 27  
 import java.util.Properties;
 28  
 import java.util.StringTokenizer;
 29  
 
 30  
 /**
 31  
  * @plexus.component role="org.apache.maven.model.converter.plugins.PluginConfigurationConverter" role-hint="surefire"
 32  
  *
 33  
  * @author Fabrizio Giustina
 34  
  * @author Dennis Lundberg
 35  
  * @version $Id: PCCSurefire.java 661727 2008-05-30 14:21:49Z bentmann $
 36  
  */
 37  4
 public class PCCSurefire
 38  
     extends AbstractPluginConfigurationConverter
 39  
 {
 40  
     /**
 41  
      * @see org.apache.maven.model.converter.plugins.AbstractPluginConfigurationConverter#getArtifactId()
 42  
      */
 43  
     public String getArtifactId()
 44  
     {
 45  0
         return "maven-surefire-plugin";
 46  
     }
 47  
 
 48  
     public String getType()
 49  
     {
 50  0
         return TYPE_BUILD_PLUGIN;
 51  
     }
 52  
 
 53  
     protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model,
 54  
                                        Properties projectProperties )
 55  
         throws ProjectConverterException
 56  
     {
 57  4
         addConfigurationChild( configuration, projectProperties, "maven.junit.jvmargs", "argLine" );
 58  
 
 59  4
         String forkMode = projectProperties.getProperty( "maven.junit.forkmode" );
 60  4
         if ( forkMode == null )
 61  
         {
 62  2
             String fork = projectProperties.getProperty( "maven.junit.fork" );
 63  2
             if ( fork != null )
 64  
             {
 65  2
                 boolean useFork = Boolean.valueOf( PropertyUtils.convertYesNoToBoolean( fork ) ).booleanValue();
 66  2
                 if ( useFork )
 67  
                 {
 68  
                     // Use "once" here as that is the default forkMode
 69  2
                     addConfigurationChild( configuration, "forkMode", "once" );
 70  
                 }
 71  
             }
 72  
         }
 73  
         else
 74  
         {
 75  2
             addConfigurationChild( configuration, projectProperties, "maven.junit.forkmode", "forkMode" );
 76  
         }
 77  
 
 78  4
         addConfigurationChild( configuration, projectProperties, "maven.junit.jvm", "jvm" );
 79  
 
 80  4
         addConfigurationChild( configuration, projectProperties, "maven.junit.printSummary", "printSummary" );
 81  
 
 82  4
         addConfigurationChild( configuration, projectProperties, "maven.junit.format", "reportFormat" );
 83  
 
 84  4
         addConfigurationChild( configuration, projectProperties, "maven.test.skip", "skip" );
 85  
 
 86  4
         String sysproperties = projectProperties.getProperty( "maven.junit.sysproperties" );
 87  4
         if ( sysproperties != null )
 88  
         {
 89  2
             StringTokenizer tokenizer = new StringTokenizer( sysproperties );
 90  2
             if ( tokenizer.hasMoreTokens() )
 91  
             {
 92  2
                 Xpp3Dom systemProperties = new Xpp3Dom( "systemProperties" );
 93  6
                 while ( tokenizer.hasMoreTokens() )
 94  
                 {
 95  4
                     String name = tokenizer.nextToken();
 96  4
                     String value = projectProperties.getProperty( name );
 97  4
                     addConfigurationChild( systemProperties, name, value );
 98  
                 }
 99  2
                 if ( systemProperties.getChildCount() > 0 )
 100  
                 {
 101  2
                     configuration.addChild( systemProperties );
 102  
                 }
 103  
             }
 104  
         }
 105  
 
 106  4
         addConfigurationChild( configuration, projectProperties, "maven.test.failure.ignore", "testFailureIgnore" );
 107  
 
 108  4
         addConfigurationChild( configuration, projectProperties, "maven.junit.usefile", "useFile" );
 109  
 
 110  4
         if ( v3Model.getBuild() != null && v3Model.getBuild().getUnitTest() != null )
 111  
         {
 112  4
             org.apache.maven.model.v3_0_0.UnitTest v3UnitTest = v3Model.getBuild().getUnitTest();
 113  
 
 114  4
             List excludes = v3UnitTest.getExcludes();
 115  4
             if ( excludes != null && excludes.size() > 0 )
 116  
             {
 117  0
                 Xpp3Dom excludesConf = new Xpp3Dom( "excludes" );
 118  0
                 for ( Iterator iter = excludes.iterator(); iter.hasNext(); )
 119  
                 {
 120  0
                     addConfigurationChild( excludesConf, "exclude", (String) iter.next() );
 121  
                 }
 122  0
                 configuration.addChild( excludesConf );
 123  
             }
 124  
 
 125  4
             List includes = v3UnitTest.getIncludes();
 126  4
             if ( includes != null && includes.size() > 0 )
 127  
             {
 128  0
                 Xpp3Dom includesConf = new Xpp3Dom( "includes" );
 129  0
                 for ( Iterator iter = includes.iterator(); iter.hasNext(); )
 130  
                 {
 131  0
                     addConfigurationChild( includesConf, "include", (String) iter.next() );
 132  
                 }
 133  0
                 configuration.addChild( includesConf );
 134  
             }
 135  
         }
 136  4
     }
 137  
 }