public void writeSurefireTestClasspathProperty() { getClasspathConfiguration().getTestClasspath().writeToSystemProperty( SUREFIRE_TEST_CLASSPATH ); } }
public RunResult runSuitesInProcess( @Nonnull DefaultScanResult scanResult ) throws SurefireExecutionException, TestSetFailedException { // The test classloader must be constructed first to avoid issues with commons-logging until we properly // separate the TestNG classloader Map<String, String> providerProperties = providerConfig.getProviderProperties(); scanResult.writeTo( providerProperties ); startupConfig.writeSurefireTestClasspathProperty(); ClassLoader testClassLoader = startupConfig.getClasspathConfiguration() .toRealPath( ClasspathConfiguration.class ) .createMergedClassLoader(); CommonReflector surefireReflector = new CommonReflector( testClassLoader ); Object factory = surefireReflector.createReportingReporterFactory( startupReportConfig, consoleLogger ); try { return invokeProvider( null, testClassLoader, factory, providerConfig, false, startupConfig, true ); } catch ( InvocationTargetException e ) { throw new SurefireExecutionException( "Exception in provider", e.getTargetException() ); } }
public RunResult runSuitesInProcess( @Nonnull DefaultScanResult scanResult ) throws SurefireExecutionException, TestSetFailedException { // The test classloader must be constructed first to avoid issues with commons-logging until we properly // separate the TestNG classloader Map<String, String> providerProperties = providerConfig.getProviderProperties(); scanResult.writeTo( providerProperties ); startupConfig.writeSurefireTestClasspathProperty(); ClassLoader testClassLoader = startupConfig.getClasspathConfiguration() .toRealPath( ClasspathConfiguration.class ) .createMergedClassLoader(); CommonReflector surefireReflector = new CommonReflector( testClassLoader ); Object factory = surefireReflector.createReportingReporterFactory( startupReportConfig, consoleLogger ); try { return invokeProvider( null, testClassLoader, factory, providerConfig, false, startupConfig, true ); } catch ( InvocationTargetException e ) { throw new SurefireExecutionException( "Exception in provider", e.getTargetException() ); } }
@Override protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli, @Nonnull String startClass, @Nonnull StartupConfiguration config ) throws SurefireBooterForkException { try { AbstractPathConfiguration pathConfig = config.getClasspathConfiguration(); ModularClasspathConfiguration modularClasspathConfiguration = pathConfig.toRealPath( ModularClasspathConfiguration.class ); ModularClasspath modularClasspath = modularClasspathConfiguration.getModularClasspath(); File descriptor = modularClasspath.getModuleDescriptor(); List<String> modulePath = modularClasspath.getModulePath(); Collection<String> packages = modularClasspath.getPackages(); File patchFile = modularClasspath.getPatchFile(); List<String> classpath = toCompleteClasspath( config ); File argsFile = createArgsFile( descriptor, modulePath, classpath, packages, patchFile, startClass ); cli.createArg().setValue( "@" + escapeToPlatformPath( argsFile.getAbsolutePath() ) ); } catch ( IOException e ) { throw new SurefireBooterForkException( "Error creating args file", e ); } }
@Override protected void resolveClasspath( @Nonnull OutputStreamFlushableCommandline cli, @Nonnull String startClass, @Nonnull StartupConfiguration config, @Nonnull File dumpLogDirectory ) throws SurefireBooterForkException { try { AbstractPathConfiguration pathConfig = config.getClasspathConfiguration(); ModularClasspathConfiguration modularClasspathConfiguration = pathConfig.toRealPath( ModularClasspathConfiguration.class ); ModularClasspath modularClasspath = modularClasspathConfiguration.getModularClasspath(); File descriptor = modularClasspath.getModuleDescriptor(); List<String> modulePath = modularClasspath.getModulePath(); Collection<String> packages = modularClasspath.getPackages(); File patchFile = modularClasspath.getPatchFile(); List<String> classpath = toCompleteClasspath( config ); File argsFile = createArgsFile( descriptor, modulePath, classpath, packages, patchFile, startClass ); cli.createArg().setValue( "@" + escapeToPlatformPath( argsFile.getAbsolutePath() ) ); } catch ( IOException e ) { String error = "Error creating args file"; InPluginProcessDumpSingleton.getSingleton() .dumpException( e, error, dumpLogDirectory ); throw new SurefireBooterForkException( error, e ); } }
private Iterable<Class<?>> getSuitesIterator() throws SurefireBooterForkException { try { AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); ClassLoader unifiedClassLoader = classpathConfiguration.createMergedClassLoader(); CommonReflector commonReflector = new CommonReflector( unifiedClassLoader ); Object reporterFactory = commonReflector.createReportingReporterFactory( startupReportConfiguration, log ); ProviderFactory providerFactory = new ProviderFactory( startupConfiguration, providerConfiguration, unifiedClassLoader, reporterFactory ); SurefireProvider surefireProvider = providerFactory.createProvider( false ); return surefireProvider.getSuites(); } catch ( SurefireExecutionException e ) { throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e ); } }
private Iterable<Class<?>> getSuitesIterator() throws SurefireBooterForkException { try { AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); ClassLoader unifiedClassLoader = classpathConfiguration.createMergedClassLoader(); CommonReflector commonReflector = new CommonReflector( unifiedClassLoader ); Object reporterFactory = commonReflector.createReportingReporterFactory( startupReportConfiguration, log ); ProviderFactory providerFactory = new ProviderFactory( startupConfiguration, providerConfiguration, unifiedClassLoader, reporterFactory ); SurefireProvider surefireProvider = providerFactory.createProvider( false ); return surefireProvider.getSuites(); } catch ( SurefireExecutionException e ) { throw new SurefireBooterForkException( "Unable to create classloader to find test suites", e ); } }
@Nonnull protected List<String> toCompleteClasspath( StartupConfiguration conf ) throws SurefireBooterForkException { AbstractPathConfiguration pathConfig = conf.getClasspathConfiguration(); if ( pathConfig.isClassPathConfig() == pathConfig.isModularPathConfig() ) { throw new SurefireBooterForkException( "Could not find class-path config nor modular class-path either." ); } Classpath bootClasspath = getBooterClasspath(); Classpath testClasspath = pathConfig.getTestClasspath(); Classpath providerClasspath = pathConfig.getProviderClasspath(); Classpath completeClasspath = join( join( bootClasspath, testClasspath ), providerClasspath ); log.debug( completeClasspath.getLogMessage( "boot classpath:" ) ); log.debug( completeClasspath.getCompactLogMessage( "boot(compact) classpath:" ) ); return completeClasspath.getClassPath(); }
@Nonnull protected List<String> toCompleteClasspath( StartupConfiguration conf ) throws SurefireBooterForkException { AbstractPathConfiguration pathConfig = conf.getClasspathConfiguration(); if ( pathConfig.isClassPathConfig() == pathConfig.isModularPathConfig() ) { throw new SurefireBooterForkException( "Could not find class-path config nor modular class-path either." ); } Classpath bootClasspath = getBooterClasspath(); Classpath testClasspath = pathConfig.getTestClasspath(); Classpath providerClasspath = pathConfig.getProviderClasspath(); Classpath completeClasspath = join( join( bootClasspath, testClasspath ), providerClasspath ); getLogger().debug( completeClasspath.getLogMessage( "boot classpath:" ) ); getLogger().debug( completeClasspath.getCompactLogMessage( "boot(compact) classpath:" ) ); return completeClasspath.getClassPath(); }
private void setupBooter( String tmpDir, String dumpFileName, String surefirePropsFileName, String effectiveSystemPropertiesFileName ) throws IOException { BooterDeserializer booterDeserializer = new BooterDeserializer( createSurefirePropertiesIfFileExists( tmpDir, surefirePropsFileName ) ); // todo: print PID in debug console logger in version 2.21.2 pingScheduler = isDebugging() ? null : listenToShutdownCommands( booterDeserializer.getPluginPid() ); setSystemProperties( new File( tmpDir, effectiveSystemPropertiesFileName ) ); providerConfiguration = booterDeserializer.deserialize(); DumpErrorSingleton.getSingleton() .init( providerConfiguration.getReporterConfiguration().getReportsDirectory(), dumpFileName ); startupConfiguration = booterDeserializer.getProviderConfiguration(); systemExitTimeoutInSeconds = providerConfiguration.systemExitTimeout( DEFAULT_SYSTEM_EXIT_TIMEOUT_IN_SECONDS ); AbstractPathConfiguration classpathConfiguration = startupConfiguration.getClasspathConfiguration(); if ( classpathConfiguration.isClassPathConfig() ) { if ( startupConfiguration.isManifestOnlyJarRequestedAndUsable() ) { classpathConfiguration.toRealPath( ClasspathConfiguration.class ) .trickClassPathWhenManifestOnlyClasspath(); } startupConfiguration.writeSurefireTestClasspathProperty(); } ClassLoader classLoader = currentThread().getContextClassLoader(); classLoader.setDefaultAssertionStatus( classpathConfiguration.isEnableAssertions() ); boolean readTestsFromCommandReader = providerConfiguration.isReadTestsFromInStream(); testSet = createTestSet( providerConfiguration.getTestForFork(), readTestsFromCommandReader, classLoader ); }
AbstractPathConfiguration cp = providerConfiguration.getClasspathConfiguration(); properties.setClasspath( CLASSPATH, cp.getTestClasspath() ); properties.setClasspath( SUREFIRE_CLASSPATH, cp.getProviderClasspath() );
AbstractPathConfiguration cp = providerConfiguration.getClasspathConfiguration(); properties.setClasspath( CLASSPATH, cp.getTestClasspath() ); properties.setClasspath( SUREFIRE_CLASSPATH, cp.getProviderClasspath() );