From 568b0da317d4e8184950706a3ac1bbfb38d04b8f Mon Sep 17 00:00:00 2001 From: David Kornel Date: Mon, 6 May 2024 13:56:16 +0200 Subject: [PATCH] Allow to inherit ResoruceManager annotation Signed-off-by: David Kornel --- .../io/skodjob/testframe/annotations/ResourceManager.java | 2 ++ .../io/skodjob/testframe/test/integration/AbstractIT.java | 8 ++++++++ .../test/integration/KubeResourceManagerCleanerIT.java | 6 ++---- 3 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 test-frame-test/src/test/java/io/skodjob/testframe/test/integration/AbstractIT.java diff --git a/test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManager.java b/test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManager.java index 064d368..0c350a9 100644 --- a/test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManager.java +++ b/test-frame-common/src/main/java/io/skodjob/testframe/annotations/ResourceManager.java @@ -9,6 +9,7 @@ import org.junit.jupiter.api.extension.ExtendWith; import java.lang.annotation.ElementType; +import java.lang.annotation.Inherited; import java.lang.annotation.Retention; import java.lang.annotation.Target; @@ -23,6 +24,7 @@ */ @Target(ElementType.TYPE) @Retention(RUNTIME) +@Inherited @ExtendWith(ResourceManagerExtension.class) @ExtendWith(ResourceManagerCleanerExtension.class) public @interface ResourceManager { diff --git a/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/AbstractIT.java b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/AbstractIT.java new file mode 100644 index 0000000..3474d45 --- /dev/null +++ b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/AbstractIT.java @@ -0,0 +1,8 @@ +package io.skodjob.testframe.test.integration; + +import io.skodjob.testframe.annotations.ResourceManager; + +@ResourceManager() +public class AbstractIT { + protected String nsName = "test"; +} diff --git a/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/KubeResourceManagerCleanerIT.java b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/KubeResourceManagerCleanerIT.java index edd9fa7..4d5c060 100644 --- a/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/KubeResourceManagerCleanerIT.java +++ b/test-frame-test/src/test/java/io/skodjob/testframe/test/integration/KubeResourceManagerCleanerIT.java @@ -6,7 +6,6 @@ import io.fabric8.kubernetes.api.model.Namespace; import io.fabric8.kubernetes.api.model.NamespaceBuilder; -import io.skodjob.testframe.annotations.ResourceManager; import io.skodjob.testframe.annotations.TestVisualSeparator; import io.skodjob.testframe.clients.KubeClusterException; import io.skodjob.testframe.resources.KubeResourceManager; @@ -20,15 +19,14 @@ import static org.junit.jupiter.api.Assertions.assertNull; import static org.junit.jupiter.api.Assertions.assertThrows; -@ResourceManager @TestVisualSeparator @TestInstance(TestInstance.Lifecycle.PER_CLASS) -public class KubeResourceManagerCleanerIT { +public class KubeResourceManagerCleanerIT extends AbstractIT { @BeforeAll void setupAll() { KubeResourceManager.getInstance().createResourceWithWait( - new NamespaceBuilder().withNewMetadata().withName("test").endMetadata().build()); + new NamespaceBuilder().withNewMetadata().withName(nsName).endMetadata().build()); } @BeforeEach