diff --git a/oap-stdlib/src/main/java/oap/application/testng/AbstractKernelFixture.java b/oap-stdlib/src/main/java/oap/application/testng/AbstractKernelFixture.java index 617addbfda..d1f165e7b1 100644 --- a/oap-stdlib/src/main/java/oap/application/testng/AbstractKernelFixture.java +++ b/oap-stdlib/src/main/java/oap/application/testng/AbstractKernelFixture.java @@ -36,6 +36,7 @@ import oap.testng.TestDirectoryFixture; import javax.annotation.Nonnull; +import java.io.UncheckedIOException; import java.net.URL; import java.nio.file.Path; import java.util.ArrayList; @@ -44,6 +45,7 @@ import java.util.Map; import static oap.http.testng.HttpAsserts.httpPrefix; +import static oap.io.IoStreams.Encoding.PLAIN; import static oap.testng.TestDirectoryFixture.testDirectory; public abstract class AbstractKernelFixture> extends AbstractEnvFixture { @@ -114,8 +116,8 @@ protected void defineDefaults() { } @SuppressWarnings( "unchecked" ) - public Self withConfdResources( Class clazz, String confdResource ) { - this.confd = TestDirectoryFixture.testPath( "/application.test.confd" ); + public Self withConfdResources( Class clazz, String confdResource ) throws UncheckedIOException { + initConfd(); Resources.filePaths( clazz, confdResource ) .forEach( path -> oap.io.Files.copyDirectory( path, this.confd ) ); @@ -123,20 +125,35 @@ public Self withConfdResources( Class clazz, String confdResource ) { return ( Self ) this; } + @SuppressWarnings( "unchecked" ) + public Self withConfResource( Class clazz, String confdResource ) throws UncheckedIOException { + initConfd(); + + Resources.filePath( clazz, confdResource ) + .ifPresent( path -> oap.io.Files.copy( path, PLAIN, this.confd.resolve( path.getFileName() ), PLAIN ) ); + + return ( Self ) this; + } + + private void initConfd() { + if( this.confd == null ) + this.confd = TestDirectoryFixture.testPath( "/application.test.confd" + "." + prefix ); + } + @Nonnull - public T service( @Nonnull String moduleName, @Nonnull Class clazz ) { + public T service( @Nonnull String moduleName, @Nonnull Class clazz ) throws IllegalArgumentException { return kernel.serviceOfClass( moduleName, clazz ) .orElseThrow( () -> new IllegalArgumentException( "unknown service " + moduleName + ":" + clazz ) ); } @Nonnull - public T service( @Nonnull String moduleName, @Nonnull String serviceName ) { + public T service( @Nonnull String moduleName, @Nonnull String serviceName ) throws IllegalArgumentException { return kernel.service( moduleName, serviceName ) .orElseThrow( () -> new IllegalArgumentException( "unknown service " + moduleName + ":" + serviceName ) ); } @Nonnull - public T service( @Nonnull String reference ) { + public T service( @Nonnull String reference ) throws IllegalArgumentException { return kernel.service( reference ) .orElseThrow( () -> new IllegalArgumentException( "unknown service " + reference ) ); } diff --git a/pom.xml b/pom.xml index 30668116e6..1fdf661adc 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ - 9.9.12 + 9.9.13 7.4.0