diff options
author | Jon Marius Venstad <jonmv@users.noreply.github.com> | 2022-06-07 11:38:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-07 11:38:14 +0200 |
commit | 36663583469ce63be5467907dd8e976d798f8f31 (patch) | |
tree | 80b2107efe63554f55a380462df86f9d4671217c /tenant-cd-api | |
parent | 0fd0880cfcfa5a1064ee78a63fc9f20d5a03183b (diff) | |
parent | b760d66aefe51e44875673b0035e1ed4cedaaa2d (diff) |
Merge pull request #22928 from vespa-engine/jonmv/junit-test-runner-2
Reimplement JUnit integratino, with unit tests, and structured report
Diffstat (limited to 'tenant-cd-api')
-rw-r--r-- | tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java | 3 | ||||
-rw-r--r-- | tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java | 24 |
2 files changed, 11 insertions, 16 deletions
diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java index 6f359a23675..431829543e7 100644 --- a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java +++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/IntegrationTest.java @@ -2,11 +2,8 @@ package ai.vespa.hosted.cd; import org.junit.jupiter.api.Tag; -import org.junit.jupiter.api.Test; -import java.lang.annotation.ElementType; import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; import static java.lang.annotation.ElementType.ANNOTATION_TYPE; diff --git a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java index bcb3c236ca8..1bf0a3081bd 100644 --- a/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java +++ b/tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java @@ -3,9 +3,7 @@ package ai.vespa.hosted.cd; import ai.vespa.cloud.Zone; import ai.vespa.hosted.cd.internal.TestRuntimeProvider; -import org.osgi.framework.BundleReference; -import java.util.Optional; import java.util.ServiceLoader; import java.util.logging.Logger; @@ -16,19 +14,19 @@ import java.util.logging.Logger; * @author mortent */ public interface TestRuntime { - static final Logger logger = Logger.getLogger(TestRuntime.class.getName()); + + Logger logger = Logger.getLogger(TestRuntime.class.getName()); + static TestRuntime get() { - var classloader = TestRuntime.class.getClassLoader(); - - if (classloader instanceof BundleReference) { - logger.info("Loading Test runtime from TestRuntimeProvider"); - return Optional.ofNullable(TestRuntimeProvider.getTestRuntime()) - .orElseThrow(() -> new RuntimeException("Component graph not ready, retrying")); - } else { - logger.info("Loading Test runtime from ServiceLoader"); - ServiceLoader<TestRuntime> serviceLoader = ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader()); - return serviceLoader.findFirst().orElseThrow(() -> new RuntimeException("No TestRuntime implementation found")); + TestRuntime provided = TestRuntimeProvider.getTestRuntime(); + if (provided != null) { + logger.info("Using test runtime from TestRuntimeProvider"); + return provided; } + logger.info("Using test runtime from ServiceLoader"); + return ServiceLoader.load(TestRuntime.class, TestRuntime.class.getClassLoader()) + .findFirst() + .orElseThrow(() -> new IllegalStateException("No TestRuntime initialized")); } Deployment deploymentToTest(); |