public static Classpath emptyClasspath() { return new Classpath(); }
public void setClasspath( String prefix, Classpath classpath ) { List classpathElements = classpath.getClassPath(); for ( int i = 0, size = classpathElements.size(); i < size; ++i ) { String element = (String) classpathElements.get( i ); setProperty( prefix + i, element ); } }
private static Classpath createInProcClasspath( Classpath providerClasspath, Set<Artifact> newArtifacts ) { Classpath inprocClasspath = providerClasspath.clone(); for ( Artifact newArtifact : newArtifacts ) { inprocClasspath = inprocClasspath.addClassPathElementUrl( newArtifact.getFile().getAbsolutePath() ); } return inprocClasspath; }
public static Classpath join( Classpath firstClasspath, Classpath secondClasspath ) { LinkedHashSet<String> accumulated = new LinkedHashSet<>(); if ( firstClasspath != null ) { firstClasspath.addTo( accumulated ); } if ( secondClasspath != null ) { secondClasspath.addTo( accumulated ); } return new Classpath( accumulated ); }
@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(); }
ResolvePathsRequest<String> req = ResolvePathsRequest.ofStrings( testClasspath.getClassPath() ) .setMainModuleDescriptor( moduleDescriptor.getAbsolutePath() ); testClasspath = new Classpath( result.getClasspathElements() ); Classpath testModulepath = new Classpath( result.getModulepathElements().keySet() ); ModularClasspath modularClasspath = new ModularClasspath( moduleDescriptor, testModulepath.getClassPath(), packages, getTestClassesDirectory() ); testClasspath, providerClasspath, effectiveIsEnableAssertions(), isChildDelegation() ); getConsoleLogger().debug( testClasspath.getLogMessage( "test classpath:" ) ); getConsoleLogger().debug( testModulepath.getLogMessage( "test modulepath:" ) ); getConsoleLogger().debug( providerClasspath.getLogMessage( "provider classpath:" ) ); getConsoleLogger().debug( testClasspath.getCompactLogMessage( "test(compact) classpath:" ) ); getConsoleLogger().debug( testModulepath.getCompactLogMessage( "test(compact) modulepath:" ) ); getConsoleLogger().debug( providerClasspath.getCompactLogMessage( "provider(compact) classpath:" ) );
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 ); }
final Classpath getInprocTestClasspath() { return join( getInprocClasspath(), getTestClasspath() ); }
public ClasspathConfiguration( boolean enableAssertions, boolean childDelegation ) { this( emptyClasspath(), emptyClasspath(), emptyClasspath(), enableAssertions, childDelegation ); }
final ClassLoader createMergedClassLoader( Classpath cp ) throws SurefireExecutionException { return cp.createClassLoader( isChildDelegation(), isEnableAssertions(), "test" ); } }
@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(); }
ResolvePathsRequest<String> req = ResolvePathsRequest.ofStrings( testClasspath.getClassPath() ) .setJdkHome( javaHome ) .setMainModuleDescriptor( moduleDescriptor.getAbsolutePath() ); testClasspath = new Classpath( result.getClasspathElements() ); Classpath testModulepath = new Classpath( result.getModulepathElements().keySet() ); ModularClasspath modularClasspath = new ModularClasspath( moduleDescriptor, testModulepath.getClassPath(), packages, getTestClassesDirectory() ); testClasspath, providerClasspath, inProcClasspath, effectiveIsEnableAssertions(), isChildDelegation() ); getConsoleLogger().debug( testClasspath.getLogMessage( "test classpath:" ) ); getConsoleLogger().debug( testModulepath.getLogMessage( "test modulepath:" ) ); getConsoleLogger().debug( providerClasspath.getLogMessage( "provider classpath:" ) ); getConsoleLogger().debug( testClasspath.getCompactLogMessage( "test(compact) classpath:" ) ); getConsoleLogger().debug( testModulepath.getCompactLogMessage( "test(compact) modulepath:" ) ); getConsoleLogger().debug( providerClasspath.getCompactLogMessage( "provider(compact) classpath:" ) ); getConsoleLogger().debug( inProcClasspath.getLogMessage( "in-process classpath:" ) ); getConsoleLogger().debug( inProcClasspath.getCompactLogMessage( "in-process(compact) classpath:" ) );
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 ); }
ClasspathConfiguration( @Nonnull PropertiesWrapper properties ) { this( properties.getClasspath( CLASSPATH ), properties.getClasspath( SUREFIRE_CLASSPATH ), emptyClasspath(), properties.getBooleanProperty( ENABLE_ASSERTIONS ), properties.getBooleanProperty( CHILD_DELEGATION ) ); }
@Override public Classpath clone() { return new Classpath( unmodifiableElements ); } }
public void setClasspath( String prefix, Classpath classpath ) { List<String> classpathElements = classpath.getClassPath(); for ( int i = 0; i < classpathElements.size(); ++i ) { String element = classpathElements.get( i ); setProperty( prefix + i, element ); } }
private static Classpath createInProcClasspath( Classpath providerClasspath, Set<Artifact> newArtifacts ) { Classpath inprocClasspath = providerClasspath.clone(); for ( Artifact newArtifact : newArtifacts ) { inprocClasspath = inprocClasspath.addClassPathElementUrl( newArtifact.getFile().getAbsolutePath() ); } return inprocClasspath; }
public Classpath addClassPathElementUrl( String path ) { if ( path == null ) { throw new IllegalArgumentException( "Null is not a valid class path element url." ); } return !unmodifiableElements.contains( path ) ? new Classpath( this, path ) : this; }
public void setClasspath( String prefix, Classpath classpath ) { List<String> classpathElements = classpath.getClassPath(); for ( int i = 0; i < classpathElements.size(); ++i ) { String element = classpathElements.get( i ); setProperty( prefix + i, element ); } }