Author: krosenvold Date: Thu Aug 25 14:37:50 2011 New Revision: 1161579 URL: http://svn.apache.org/viewvc?rev=1161579&view=rev Log: [SUREFIRE-763] environmentVariables fails with useSystemClassLoader=false or forkMode=always
Fixed with testcase Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java (with props) maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java (contents, props changed) - copied, changed from r1160400, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml (with props) maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java (with props) Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java (contents, props changed) maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java (contents, props changed) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml (contents, props changed) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java (contents, props changed) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test2.java (contents, props changed) maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test3.java (contents, props changed) Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerProviderConfigurationTest.java Thu Aug 25 14:37:50 2011 @@ -26,22 +26,22 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.Properties; - -import junit.framework.Assert; -import junit.framework.TestCase; - import org.apache.maven.surefire.booter.BooterDeserializer; import org.apache.maven.surefire.booter.ClassLoaderConfiguration; import org.apache.maven.surefire.booter.ClasspathConfiguration; import org.apache.maven.surefire.booter.ProviderConfiguration; import org.apache.maven.surefire.booter.StartupConfiguration; import org.apache.maven.surefire.booter.SystemPropertyManager; +import org.apache.maven.surefire.booter.TypeEncodedValue; import org.apache.maven.surefire.report.ReporterConfiguration; import org.apache.maven.surefire.testset.DirectoryScannerParameters; import org.apache.maven.surefire.testset.TestArtifactInfo; import org.apache.maven.surefire.testset.TestRequest; import org.apache.maven.surefire.util.RunOrder; +import junit.framework.Assert; +import junit.framework.TestCase; + /** * Performs roundtrip testing of serialization/deserialization of the ProviderConfiguration * @@ -51,7 +51,7 @@ public class BooterDeserializerProviderC extends TestCase { - private final String aTest = "aTest"; + public static final TypeEncodedValue aTestTyped = new TypeEncodedValue( String.class.getName(), "aTest" ); private final String aUserRequestedTest = "aUserRequestedTest"; @@ -128,7 +128,7 @@ public class BooterDeserializerProviderC throws IOException { final ProviderConfiguration reloaded = getReloadedProviderConfiguration(); - Assert.assertEquals( aTest, reloaded.getTestForForkString() ); + Assert.assertEquals( aTestTyped, reloaded.getTestForFork() ); } @@ -170,6 +170,7 @@ public class BooterDeserializerProviderC final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration(); Properties props = new Properties(); BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props ); + String aTest = "aTest"; booterSerializer.serialize( booterConfiguration, testProviderConfiguration, aTest, "never" ); final File propsTest = SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true ); @@ -181,15 +182,14 @@ public class BooterDeserializerProviderC { File cwd = new File( "." ); - ReporterConfiguration reporterConfiguration = - new ReporterConfiguration( cwd, Boolean.TRUE ); + ReporterConfiguration reporterConfiguration = new ReporterConfiguration( cwd, Boolean.TRUE ); String aUserRequestedTestMethod = "aUserRequestedTestMethod"; TestRequest testSuiteDefinition = new TestRequest( getSuiteXmlFileStrings(), getTestSourceDirectory(), aUserRequestedTest, aUserRequestedTestMethod ); return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration, new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(), - aTest ); + aTestTyped ); } private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration ) Modified: maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java (original) +++ maven/surefire/trunk/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/booterclient/BooterDeserializerStartupConfigurationTest.java Thu Aug 25 14:37:50 2011 @@ -50,8 +50,6 @@ public class BooterDeserializerStartupCo { private final ClasspathConfiguration classpathConfiguration = createClasspathConfiguration(); - private final String aTest = "aTest"; - public void testProvider() throws IOException { @@ -129,6 +127,7 @@ public class BooterDeserializerStartupCo final ForkConfiguration forkConfiguration = ForkConfigurationTest.getForkConfiguration(); Properties props = new Properties(); BooterSerializer booterSerializer = new BooterSerializer( forkConfiguration, props ); + String aTest = "aTest"; booterSerializer.serialize( getProviderConfiguration(), startupConfiguration, aTest, "never" ); final File propsTest = SystemPropertyManager.writePropertiesFile( props, forkConfiguration.getTempDirectory(), "propsTest", true ); @@ -150,7 +149,7 @@ public class BooterDeserializerStartupCo aUserRequestedTestMethod ); return new ProviderConfiguration( directoryScannerParameters, true, reporterConfiguration, new TestArtifactInfo( "5.0", "ABC" ), testSuiteDefinition, new Properties(), - aTest ); + BooterDeserializerProviderConfigurationTest.aTestTyped ); } private StartupConfiguration getTestStartupConfiguration( ClassLoaderConfiguration classLoaderConfiguration ) Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/BooterDeserializer.java Thu Aug 25 14:37:50 2011 @@ -60,7 +60,7 @@ public class BooterDeserializer final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION ); final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER ); - final Object testForFork = properties.getTypeDecoded( FORKTESTSET ); + final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET ); final String requestedTest = properties.getProperty( REQUESTEDTEST ); final String requestedTestMethod = properties.getProperty( REQUESTEDTESTMETHOD ); final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY ); @@ -85,7 +85,7 @@ public class BooterDeserializer return new ProviderConfiguration( dirScannerParams, properties.getBooleanProperty( FAILIFNOTESTS ), reporterConfiguration, testNg, testSuiteDefinition, - properties.getProperties(), testForFork ); + properties.getProperties(), typeEncodedTestForFork ); } public StartupConfiguration getProviderConfiguration() Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ForkedBooter.java Thu Aug 25 14:37:50 2011 @@ -51,7 +51,6 @@ public class ForkedBooter { try { - long start = System.currentTimeMillis(); if ( args.length > 1 ) { SystemPropertyManager.setSystemProperties( new File( args[1] ) ); @@ -63,12 +62,11 @@ public class ForkedBooter ProviderConfiguration booterConfiguration = booterDeserializer.deserialize(); final StartupConfiguration providerConfiguration = booterDeserializer.getProviderConfiguration(); - SurefireStarter starter = new SurefireStarter( providerConfiguration, booterConfiguration, null ); - Object forkedTestSet = booterConfiguration.getTestForFork(); + TypeEncodedValue forkedTestSet = booterConfiguration.getTestForFork(); final RunResult result = forkedTestSet != null - ? starter.runSuitesInProcessWhenForked(forkedTestSet ) + ? starter.runSuitesInProcessWhenForked( forkedTestSet ) : starter.runSuitesInProcessWhenForked(); // noinspection CallToSystemExit Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PropertiesWrapper.java Thu Aug 25 14:37:50 2011 @@ -19,14 +19,11 @@ package org.apache.maven.surefire.booter * under the License. */ -import java.io.ByteArrayInputStream; import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Properties; -import org.apache.maven.surefire.util.NestedRuntimeException; -import org.apache.maven.surefire.util.ReflectionUtils; import org.apache.maven.surefire.util.internal.StringUtils; /** @@ -83,7 +80,8 @@ public class PropertiesWrapper { return null; } - return (File) getParamValue( property, File.class.getName() ); + TypeEncodedValue typeEncodedValue = new TypeEncodedValue( File.class.getName(), property ); + return (File) typeEncodedValue.getDecodedValue(); } public List getStringList( String propertyPrefix ) @@ -104,7 +102,7 @@ public class PropertiesWrapper * @param key The key for the propery * @return The object, of a supported type */ - public Object getTypeDecoded( String key ) + public TypeEncodedValue getTypeEncodedValue( String key ) { String typeEncoded = getProperty( key ); if ( typeEncoded == null ) @@ -114,89 +112,9 @@ public class PropertiesWrapper int typeSep = typeEncoded.indexOf( "|" ); String type = typeEncoded.substring( 0, typeSep ); String value = typeEncoded.substring( typeSep + 1 ); - return getParamValue( value, type ); + return new TypeEncodedValue( type, value ); } - private Object getParamValue( String param, String typeName ) - { - if ( typeName.trim().length() == 0 ) - { - return null; - } - else if ( typeName.equals( String.class.getName() ) ) - { - return param; - } - else if ( typeName.equals( Class.class.getName() ) ) - { - return ReflectionUtils.loadClass( Thread.currentThread().getContextClassLoader(), param ); - } - else if ( typeName.equals( File.class.getName() ) ) - { - return new File( param ); - } - else if ( typeName.equals( File[].class.getName() ) ) - { - List stringList = processStringList( param ); - File[] fileList = new File[stringList.size()]; - for ( int j = 0; j < stringList.size(); j++ ) - { - fileList[j] = new File( (String) stringList.get( j ) ); - } - return fileList; - } - else if ( typeName.equals( ArrayList.class.getName() ) ) - { - return processStringList( param ); - } - else if ( typeName.equals( Boolean.class.getName() ) ) - { - return Boolean.valueOf( param ); - } - else if ( typeName.equals( Integer.class.getName() ) ) - { - return Integer.valueOf( param ); - } - else if ( typeName.equals( Properties.class.getName() ) ) - { - final Properties result = new Properties(); - try - { - ByteArrayInputStream bais = new ByteArrayInputStream( param.getBytes( "8859_1" ) ); - result.load( bais ); - } - catch ( Exception e ) - { - throw new NestedRuntimeException( "bug in property conversion", e ); - } - return result; - } - else - { - // TODO: could attempt to construct with a String constructor if needed - throw new IllegalArgumentException( "Unknown parameter type: " + typeName ); - } - } - - private static List processStringList( String stringList ) - { - String sl = stringList; - - if ( sl.startsWith( "[" ) && sl.endsWith( "]" ) ) - { - sl = sl.substring( 1, sl.length() - 1 ); - } - - List list = new ArrayList(); - - String[] stringArray = StringUtils.split( sl, "," ); - - for ( int i = 0; i < stringArray.length; i++ ) - { - list.add( stringArray[i].trim() ); - } - return list; - } public void setProperty( String key, File file ) { @@ -214,7 +132,7 @@ public class PropertiesWrapper } } - Classpath getClasspath( String prefix ) + Classpath getClasspath( String prefix ) { List elements = getStringList( prefix ); return new Classpath( elements ); @@ -246,7 +164,7 @@ public class PropertiesWrapper return; } int i = 0; - for (Iterator iterator = items.iterator(); iterator.hasNext();) + for ( Iterator iterator = items.iterator(); iterator.hasNext(); ) { Object item = iterator.next(); if ( item == null ) @@ -254,7 +172,7 @@ public class PropertiesWrapper throw new NullPointerException( propertyPrefix + i + " has null value" ); } - String[] stringArray = StringUtils.split(item.toString(), ","); + String[] stringArray = StringUtils.split( item.toString(), "," ); for ( int j = 0; j < stringArray.length; j++ ) { Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/ProviderConfiguration.java Thu Aug 25 14:37:50 2011 @@ -60,11 +60,12 @@ public class ProviderConfiguration private final boolean failIfNoTests; - private final Object forkTestSet; + private final TypeEncodedValue forkTestSet; public ProviderConfiguration( DirectoryScannerParameters directoryScannerParameters, boolean failIfNoTests, ReporterConfiguration reporterConfiguration, TestArtifactInfo testArtifact, - TestRequest testSuiteDefinition, Properties providerProperties, Object forkTestSet ) + TestRequest testSuiteDefinition, Properties providerProperties, + TypeEncodedValue typeEncodedTestSet ) { this.providerProperties = providerProperties; this.reporterConfiguration = reporterConfiguration; @@ -72,7 +73,7 @@ public class ProviderConfiguration this.testSuiteDefinition = testSuiteDefinition; this.dirScannerParams = directoryScannerParameters; this.failIfNoTests = failIfNoTests; - this.forkTestSet = forkTestSet; + this.forkTestSet = typeEncodedTestSet; } @@ -123,19 +124,10 @@ public class ProviderConfiguration return providerProperties; } - public Object getTestForFork() + public TypeEncodedValue getTestForFork() { return forkTestSet; } - public String getTestForForkString() - { - if ( forkTestSet instanceof File ) - { - return forkTestSet.toString(); - } - return (String) forkTestSet; - } - } Modified: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java (original) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/SurefireStarter.java Thu Aug 25 14:37:50 2011 @@ -25,6 +25,7 @@ import org.apache.maven.surefire.report. import org.apache.maven.surefire.suite.RunResult; import org.apache.maven.surefire.testset.TestSetFailedException; import org.apache.maven.surefire.util.NestedRuntimeException; +import org.apache.maven.surefire.util.ReflectionUtils; /** * Invokes surefire with the correct classloader setup. @@ -57,7 +58,7 @@ public class SurefireStarter this.startupReportConfiguration = startupReportConfiguration; } - public RunResult runSuitesInProcessWhenForked( Object testSet ) + public RunResult runSuitesInProcessWhenForked( TypeEncodedValue testSet ) throws SurefireExecutionException { writeSurefireTestClasspathProperty(); @@ -75,7 +76,9 @@ public class SurefireStarter final Object forkingReporterFactory = createForkingReporterFactory( surefireReflector ); - return invokeProvider( testSet, testsClassLoader, surefireClassLoader, forkingReporterFactory ); + Object test = testSet.getDecodedValue(); + + return invokeProvider( test, testsClassLoader, surefireClassLoader, forkingReporterFactory ); } private Object createForkingReporterFactory( SurefireReflector surefireReflector ) Added: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java?rev=1161579&view=auto ============================================================================== --- maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java (added) +++ maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java Thu Aug 25 14:37:50 2011 @@ -0,0 +1,126 @@ +package org.apache.maven.surefire.booter; + +/* +* Licensed to the Apache Software Foundation (ASF) under one +* or more contributor license agreements. See the NOTICE file +* distributed with this work for additional information +* regarding copyright ownership. The ASF licenses this file +* to you under the Apache License, Version 2.0 (the +* "License"); you may not use this file except in compliance +* with the License. You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, +* software distributed under the License is distributed on an +* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +* KIND, either express or implied. See the License for the +* specific language governing permissions and limitations +* under the License. +*/ + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.util.Properties; +import org.apache.maven.surefire.util.NestedRuntimeException; +import org.apache.maven.surefire.util.ReflectionUtils; + +/** + * @author Kristian Rosenvold + */ +public class TypeEncodedValue +{ + String type; + + String value; + + public TypeEncodedValue( String type, String value ) + { + this.type = type; + this.value = value; + } + + public String getType() + { + return type; + } + + public boolean isTypeClass() + { + return Class.class.getName().equals( type ); + } + + public Object getDecodedValue() + { + if ( type.trim().length() == 0 ) + { + return null; + } + else if ( type.equals( String.class.getName() ) ) + { + return value; + } + else if ( isTypeClass() ) + { + return ReflectionUtils.loadClass( Thread.currentThread().getContextClassLoader(), value ); + } + else if ( type.equals( File.class.getName() ) ) + { + return new File( value ); + } + else if ( type.equals( Boolean.class.getName() ) ) + { + return Boolean.valueOf( value ); + } + else if ( type.equals( Integer.class.getName() ) ) + { + return Integer.valueOf( value ); + } + else if ( type.equals( Properties.class.getName() ) ) + { + final Properties result = new Properties(); + try + { + ByteArrayInputStream bais = new ByteArrayInputStream( value.getBytes( "8859_1" ) ); + result.load( bais ); + } + catch ( Exception e ) + { + throw new NestedRuntimeException( "bug in property conversion", e ); + } + return result; + } + else + { + throw new IllegalArgumentException( "Unknown parameter type: " + type ); + } + } + + public boolean equals( Object o ) + { + if ( this == o ) + { + return true; + } + if ( o == null || getClass() != o.getClass() ) + { + return false; + } + + TypeEncodedValue that = (TypeEncodedValue) o; + + if ( type != null ? !type.equals( that.type ) : that.type != null ) + { + return false; + } + return !( value != null ? !value.equals( that.value ) : that.value != null ); + + } + + public int hashCode() + { + int result = type != null ? type.hashCode() : 0; + result = 31 * result + ( value != null ? value.hashCode() : 0 ); + return result; + } +} Propchange: maven/surefire/trunk/surefire-booter/src/main/java/org/apache/maven/surefire/booter/TypeEncodedValue.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/ForkModeTestNGIT.java ('svn:executable' removed) Modified: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java ('svn:executable' removed) Copied: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java (from r1160400, maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java) URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java?p2=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java&p1=maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java&r1=1160400&r2=1161579&rev=1161579&view=diff ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/TestNgTestMethodPatternAfterIT.java (original) +++ maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java Thu Aug 25 14:37:50 2011 @@ -1,4 +1,4 @@ -package org.apache.maven.surefire.its; +package org.apache.maven.surefire.its.misc; /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -19,26 +19,34 @@ package org.apache.maven.surefire.its; */ +import org.apache.maven.surefire.its.SurefireVerifierTestClass; + /** - * Test project using -Dtest=mtClass#myMethod* + * SUREFIRE-674 Asserts that the build fails when tests have errors * - * @author <a href="mailto:ol...@apache.org">Olivier Lamy</a> + * @author Kristian Rosenvold */ -public class TestNgTestMethodPatternAfterIT - extends AsbtractTestMethodPattern +public class Surefire763EnvironmentForkMode + extends SurefireVerifierTestClass { - public TestNgTestMethodPatternAfterIT() + + public Surefire763EnvironmentForkMode() { - super( "/testng-method-pattern-after" ); + super( "/environment-variables" ); + } + + public void okWhenUseSystemClassLoader() + throws Exception + { + addGoal( "-DuseSystemClassLoader=true" ); + executeTest(); } - public void testMethodPattern() + public void okeWhenDontUseSystemClassLoader() throws Exception { + addGoal( "-DuseSystemClassLoader=false" ); executeTest(); - verifyErrorFreeLog(); - verifyTextInLog( "Called tearDown" ); - assertTestSuiteResults( 2, 0, 0, 0 ); } -} +} \ No newline at end of file Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/misc/Surefire763EnvironmentForkMode.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml?rev=1161579&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml Thu Aug 25 14:37:50 2011 @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one + ~ or more contributor license agreements. See the NOTICE file + ~ distributed with this work for additional information + ~ regarding copyright ownership. The ASF licenses this file + ~ to you under the Apache License, Version 2.0 (the + ~ "License"); you may not use this file except in compliance + ~ with the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, + ~ software distributed under the License is distributed on an + ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + ~ KIND, either express or implied. See the License for the + ~ specific language governing permissions and limitations + ~ under the License. + --> + +<project xmlns="http://maven.apache.org/POM/4.0.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + + <groupId>org.apache.maven.plugins.surefire</groupId> + <artifactId>environment-variables</artifactId> + <version>1.0-SNAPSHOT</version> + <name>Test for checking environment variables into forks</name> + + <properties> + <forkMode>always</forkMode> + <useSystemClassLoader>false</useSystemClassLoader> + </properties> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.4</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>${surefire.version}</version> + <configuration> + <forkMode>${forkMode}</forkMode> + <useSystemClassLoader>${useSystemClassLoader}</useSystemClassLoader> + <environmentVariables> + <DUMMY_ENV_VAR>foo</DUMMY_ENV_VAR> + </environmentVariables> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + </plugins> + </build> + +</project> Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Added: maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java?rev=1161579&view=auto ============================================================================== --- maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java (added) +++ maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java Thu Aug 25 14:37:50 2011 @@ -0,0 +1,21 @@ +package environment; +import org.junit.Assert; +import org.junit.Test; + +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsNull.notNullValue; + + +public class BasicTest +{ + + + @Test + public void testEnvVar() + { + Assert.assertThat( System.getenv( "PATH" ), notNullValue() ); + Assert.assertThat( System.getenv( "DUMMY_ENV_VAR" ), is( "foo" ) ); + } + + +} Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java ------------------------------------------------------------------------------ svn:eol-style = native Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/pom.xml ('svn:executable' removed) Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test1.java ('svn:executable' removed) Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test2.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test2.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test2.java ('svn:executable' removed) Modified: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test3.java URL: http://svn.apache.org/viewvc/maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test3.java?rev=1161579&r1=1161578&r2=1161579&view=diff ============================================================================== (empty) Propchange: maven/surefire/trunk/surefire-integration-tests/src/test/resources/fork-mode-testng/src/test/java/forkMode/Test3.java ('svn:executable' removed)