/** * Loads the properties, closes the stream * * @param inStream The stream to read from, will be closed * @return The properties * @throws java.io.IOException If something bad happens */ public static PropertiesWrapper loadProperties( InputStream inStream ) throws IOException { try ( final InputStream stream = inStream ) { Properties p = new Properties(); p.load( stream ); Map<String, String> map = new ConcurrentHashMap<>( p.size() ); for ( String key : p.stringPropertyNames() ) { map.put( key, p.getProperty( key ) ); } return new PropertiesWrapper( map ); } }
final File reportsDirectory = new File( properties.getProperty( REPORTSDIRECTORY ) ); final String testNgVersion = properties.getProperty( TESTARTIFACT_VERSION ); final String testArtifactClassifier = properties.getProperty( TESTARTIFACT_CLASSIFIER ); final TypeEncodedValue typeEncodedTestForFork = properties.getTypeEncodedValue( FORKTESTSET ); final boolean preferTestsFromInStream = properties.getBooleanProperty( FORKTESTSET_PREFER_TESTS_FROM_IN_STREAM ); final String requestedTest = properties.getProperty( REQUESTEDTEST ); final File sourceDirectory = properties.getFileProperty( SOURCE_DIRECTORY ); final List<String> excludes = properties.getStringList( EXCLUDES_PROPERTY_PREFIX ); final List<String> includes = properties.getStringList( INCLUDES_PROPERTY_PREFIX ); final List<String> specificTests = properties.getStringList( SPECIFIC_TEST_PROPERTY_PREFIX ); final List<String> testSuiteXmlFiles = properties.getStringList( TEST_SUITE_XML_FILES ); final File testClassesDirectory = properties.getFileProperty( TEST_CLASSES_DIRECTORY ); final String runOrder = properties.getProperty( RUN_ORDER ); final String runStatisticsFile = properties.getProperty( RUN_STATISTICS_FILE ); final int rerunFailingTestsCount = properties.getIntProperty( RERUN_FAILING_TESTS_COUNT ); properties.getBooleanProperty( FAILIFNOTESTS ), runOrder ); new ReporterConfiguration( reportsDirectory, properties.getBooleanProperty( ISTRIMSTACKTRACE ) ); Collection<String> cli = properties.getStringList( MAIN_CLI_OPTIONS ); int failFastCount = properties.getIntProperty( FAIL_FAST_COUNT );
ClasspathConfiguration( @Nonnull PropertiesWrapper properties ) { this( properties.getClasspath( CLASSPATH ), properties.getClasspath( SUREFIRE_CLASSPATH ), emptyClasspath(), properties.getBooleanProperty( ENABLE_ASSERTIONS ), properties.getBooleanProperty( CHILD_DELEGATION ) ); }
public StartupConfiguration getProviderConfiguration() { boolean useSystemClassLoader = properties.getBooleanProperty( USESYSTEMCLASSLOADER ); boolean useManifestOnlyJar = properties.getBooleanProperty( USEMANIFESTONLYJAR ); String providerConfiguration = properties.getProperty( PROVIDER_CONFIGURATION ); ClassLoaderConfiguration classLoaderConfiguration = new ClassLoaderConfiguration( useSystemClassLoader, useManifestOnlyJar ); ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( properties ); return StartupConfiguration.inForkedVm( providerConfiguration, classpathConfiguration, classLoaderConfiguration ); } }
propertiesMap.put(key, testProps.getProperty(key)); PropertiesWrapper wrapper = new PropertiesWrapper(propertiesMap); List<String> suiteXmlFiles = wrapper.getStringList(BooterConstants.TEST_SUITE_XML_FILES);
Classpath getClasspath( String prefix ) { List<String> elements = getStringList( prefix ); return new Classpath( elements ); }
public Long getLongProperty( String propertyName ) { String number = getProperty( propertyName ); return number == null ? null : Long.parseLong( number ); }
/** * @return PID of Maven process where plugin is executed; or null if PID could not be determined. */ public Long getPluginPid() { return properties.getLongProperty( PLUGIN_PID ); }
public List<String> getStringList( String propertyPrefix ) { List<String> result = new ArrayList<>(); for ( int i = 0; ; i++ ) { String value = getProperty( propertyPrefix + i ); if ( value == null ) { return result; } result.add( value ); } }
try return fork( null, new PropertiesWrapper( providerProperties ), forkClient, effectiveSystemProperties, forkNumber, testProvidingInputStream, true );
/** * Retrieves as single object that is persisted with type encoding * * @param key The key for the propery * @return The object, of a supported type */ public TypeEncodedValue getTypeEncodedValue( String key ) { String typeEncoded = getProperty( key ); if ( typeEncoded != null ) { int typeSep = typeEncoded.indexOf( "|" ); String type = typeEncoded.substring( 0, typeSep ); String value = typeEncoded.substring( typeSep + 1 ); return new TypeEncodedValue( type, value ); } else { return null; } }
try return fork( null, new PropertiesWrapper( providerProperties ), forkClient, effectiveSystemProperties, forkNumber, testProvidingInputStream, true );
public File getFileProperty( String key ) { final String property = getProperty( key ); if ( property == null ) { return null; } TypeEncodedValue typeEncodedValue = new TypeEncodedValue( File.class.getName(), property ); return (File) typeEncodedValue.getDecodedValue(); }
try return fork( null, new PropertiesWrapper( providerProperties ), forkClient, effectiveSystemProperties, forkNumber, testProvidingInputStream, true );
try return fork( null, new PropertiesWrapper( providerProperties ), forkClient, effectiveSystemProperties, forkNumber, testProvidingInputStream, true );
new PropertiesWrapper( providerConfiguration.getProviderProperties() ), forkClient, effectiveSystemProperties, forkNumber, stream, false );
new PropertiesWrapper( providerConfiguration.getProviderProperties() ), forkClient, effectiveSystemProperties, forkNumber, stream, false );
private RunResult run( SurefireProperties effectiveSystemProperties, Map<String, String> providerProperties ) throws SurefireBooterForkException { TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); PropertiesWrapper props = new PropertiesWrapper( providerProperties ); TestLessInputStream stream = builder.build(); Thread shutdown = createImmediateShutdownHookThread( builder, providerConfiguration.getShutdown() ); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); int forkNumber = drawNumber(); try { addShutDownHook( shutdown ); DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log, forkNumber ); defaultReporterFactories.add( forkedReporterFactory ); ForkClient forkClient = new ForkClient( forkedReporterFactory, stream, log, new AtomicBoolean(), forkNumber ); return fork( null, props, forkClient, effectiveSystemProperties, forkNumber, stream, false ); } finally { returnNumber( forkNumber ); removeShutdownHook( shutdown ); ping.cancel( true ); builder.removeStream( stream ); } }
private RunResult run( SurefireProperties effectiveSystemProperties, Map<String, String> providerProperties ) throws SurefireBooterForkException { TestLessInputStreamBuilder builder = new TestLessInputStreamBuilder(); PropertiesWrapper props = new PropertiesWrapper( providerProperties ); TestLessInputStream stream = builder.build(); Thread shutdown = createImmediateShutdownHookThread( builder, providerConfiguration.getShutdown() ); ScheduledFuture<?> ping = triggerPingTimerForShutdown( builder ); int forkNumber = drawNumber(); try { addShutDownHook( shutdown ); DefaultReporterFactory forkedReporterFactory = new DefaultReporterFactory( startupReportConfiguration, log, forkNumber ); defaultReporterFactories.add( forkedReporterFactory ); ForkClient forkClient = new ForkClient( forkedReporterFactory, stream, log, new AtomicBoolean(), forkNumber ); return fork( null, props, forkClient, effectiveSystemProperties, forkNumber, stream, false ); } finally { returnNumber( forkNumber ); removeShutdownHook( shutdown ); ping.cancel( true ); builder.removeStream( stream ); } }
new PropertiesWrapper( providerConfiguration.getProviderProperties() ), forkClient, effectiveSystemProperties, forkNumber, stream, false );