Skip to content

Commit

Permalink
better-kernel-log
Browse files Browse the repository at this point in the history
  • Loading branch information
alebastrov committed Oct 12, 2023
1 parent 8eb37eb commit 9fa2d3c
Showing 1 changed file with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
package oap.application.testng;

import com.google.common.base.Preconditions;
import lombok.extern.slf4j.Slf4j;
import oap.application.ApplicationConfiguration;
import oap.application.Kernel;
import oap.application.module.Module;
Expand Down Expand Up @@ -52,6 +53,7 @@
import static oap.testng.TestDirectoryFixture.testDirectory;
import static oap.util.Pair.__;

@Slf4j
public abstract class AbstractKernelFixture<Self extends AbstractKernelFixture<Self>> extends AbstractEnvFixture<Self> {
public static final String ANY = "*";
public static final String TEST_HTTP_PORT = "TEST_HTTP_PORT";
Expand Down Expand Up @@ -198,16 +200,26 @@ protected void before() {

for( var cd : confd ) {
Resources.filePaths( cd._1, cd._2 )
.forEach( path -> oap.io.Files.copyDirectory( path, this.confdPath ) );
.forEach( path -> {
if( path.toFile().exists() && path.toFile().isDirectory() ) {
log.info( "Copy directory " + path + " -> " + confdPath );
oap.io.Files.copyDirectory( path, confdPath );
} else {
if ( !path.toFile().exists() ) log.warn( "Configuration directory " + path + " is not found" );
else log.warn( "Configuration directory " + path + " is not a directory" );
}
} );
}


for( var cd : conf ) {
Resources.filePath( cd._1, cd._2 )
.ifPresent( path -> oap.io.Files.copy( path, PLAIN, this.confdPath.resolve( path.getFileName() ), PLAIN ) );
var p = Resources.filePath( cd._1, cd._2 );
p.ifPresentOrElse( path -> {
Path destPath = confdPath.resolve( path.getFileName() );
log.info( "Copying file " + path + " -> " + destPath );
oap.io.Files.copy( path, PLAIN, destPath, PLAIN );
}, () -> log.warn( "Configuration file " + cd + " is not found" ) );
}


var moduleConfigurations = Module.CONFIGURATION.urlsFromClassPath();
moduleConfigurations.addAll( additionalModules );
this.kernel = new Kernel( "FixtureKernel#" + kernelN++ + "#" + prefix, moduleConfigurations );
Expand Down

0 comments on commit 9fa2d3c

Please sign in to comment.