public void trickClassPathWhenManifestOnlyClasspath() { System.setProperty( "surefire.real.class.path", System.getProperty( "java.class.path" ) ); getTestClasspath().writeToSystemProperty( "java.class.path" ); } }
@Override public final boolean isModularPathConfig() { return !isClassPathConfig(); }
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 ); } }
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() ); } }
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 ); }
boolean disableXmlReport = false; ClasspathConfiguration classPathConfig = new ClasspathConfiguration(false, false); StartupConfiguration startupConfiguration = new StartupConfiguration(provider, classPathConfig, new ClassLoaderConfiguration(useSystemClassloader, useManifestOnlyJar), forkRequested, inForkedVM);
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() ); } }
private StartupConfiguration newStartupConfigWithClasspath( @Nonnull ClassLoaderConfiguration classLoaderConfiguration, @Nonnull Set<Artifact> providerArtifacts, @Nonnull String providerName ) { TestClassPath testClasspathWrapper = generateTestClasspath(); Classpath testClasspath = testClasspathWrapper.toClasspath(); testClasspathWrapper.avoidArtifactDuplicates( providerArtifacts ); Classpath providerClasspath = ClasspathCache.getCachedClassPath( providerName ); if ( providerClasspath == null ) { providerClasspath = ClasspathCache.setCachedClasspath( providerName, providerArtifacts ); } getConsoleLogger().debug( testClasspath.getLogMessage( "test classpath:" ) ); getConsoleLogger().debug( providerClasspath.getLogMessage( "provider classpath:" ) ); getConsoleLogger().debug( testClasspath.getCompactLogMessage( "test(compact) classpath:" ) ); getConsoleLogger().debug( providerClasspath.getCompactLogMessage( "provider(compact) classpath:" ) ); Artifact[] additionalInProcArtifacts = { getCommonArtifact(), getApiArtifact() }; Set<Artifact> inProcArtifacts = retainInProcArtifactsUnique( providerArtifacts, additionalInProcArtifacts ); Classpath inProcClasspath = createInProcClasspath( providerClasspath, inProcArtifacts ); getConsoleLogger().debug( inProcClasspath.getLogMessage( "in-process classpath:" ) ); getConsoleLogger().debug( inProcClasspath.getCompactLogMessage( "in-process(compact) classpath:" ) ); ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( testClasspath, providerClasspath, inProcClasspath, effectiveIsEnableAssertions(), isChildDelegation() ); return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, isForking(), false ); }
private StartupConfiguration newStartupConfigWithClasspath( @Nonnull ClassLoaderConfiguration classLoaderConfiguration, @Nonnull Set<Artifact> providerArtifacts, @Nonnull String providerName ) { TestClassPath testClasspathWrapper = generateTestClasspath(); Classpath testClasspath = testClasspathWrapper.toClasspath(); testClasspathWrapper.avoidArtifactDuplicates( providerArtifacts ); Classpath providerClasspath = ClasspathCache.getCachedClassPath( providerName ); if ( providerClasspath == null ) { providerClasspath = ClasspathCache.setCachedClasspath( providerName, providerArtifacts ); } getConsoleLogger().debug( testClasspath.getLogMessage( "test classpath:" ) ); getConsoleLogger().debug( providerClasspath.getLogMessage( "provider classpath:" ) ); getConsoleLogger().debug( testClasspath.getCompactLogMessage( "test(compact) classpath:" ) ); getConsoleLogger().debug( providerClasspath.getCompactLogMessage( "provider(compact) classpath:" ) ); Artifact[] additionalInProcArtifacts = { getCommonArtifact(), getApiArtifact(), getLoggerApiArtifact() }; Set<Artifact> inProcArtifacts = retainInProcArtifactsUnique( providerArtifacts, additionalInProcArtifacts ); Classpath inProcClasspath = createInProcClasspath( providerClasspath, inProcArtifacts ); getConsoleLogger().debug( inProcClasspath.getLogMessage( "in-process classpath:" ) ); getConsoleLogger().debug( inProcClasspath.getCompactLogMessage( "in-process(compact) classpath:" ) ); ClasspathConfiguration classpathConfiguration = new ClasspathConfiguration( testClasspath, providerClasspath, inProcClasspath, effectiveIsEnableAssertions(), isChildDelegation() ); return new StartupConfiguration( providerName, classpathConfiguration, classLoaderConfiguration, isForking(), false ); }