summaryrefslogtreecommitdiffstats
path: root/tenant-cd-api
diff options
context:
space:
mode:
authorjonmv <venstad@gmail.com>2022-06-06 19:13:18 +0200
committerjonmv <venstad@gmail.com>2022-06-06 19:13:18 +0200
commitb610a317d9fd1e1dcad6bc639efb9e22dd4cbf26 (patch)
treedba0846ce91beea3964fa48556211f14b1395921 /tenant-cd-api
parent972d7ac82e62bb51c4e16d5b740eaa5ce45cdfa8 (diff)
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.java3
-rw-r--r--tenant-cd-api/src/main/java/ai/vespa/hosted/cd/TestRuntime.java24
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();