diff options
author | gjoranv <gv@verizonmedia.com> | 2023-01-03 14:49:54 +0100 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2023-01-05 14:23:15 +0100 |
commit | 1319d959d05779da814bf8109c6af1279366bf54 (patch) | |
tree | efda276e60f3f01de1c99ac39789efcea46844fa /container-core/src/test | |
parent | ef182321fbb32257fee506ccc9f3cdd02a7df572 (diff) |
Add method for listing bsnVersion for active application bundles.
Diffstat (limited to 'container-core/src/test')
3 files changed, 24 insertions, 1 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java index e646e916521..764771bc285 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java @@ -2,6 +2,7 @@ package com.yahoo.container.core.config; import com.yahoo.container.di.Osgi.GenerationStatus; +import com.yahoo.jdisc.core.BsnVersion; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.osgi.framework.Bundle; @@ -35,6 +36,7 @@ public class ApplicationBundleLoaderTest { @Test void bundles_are_installed_and_started() { bundleLoader.useBundles(List.of(BUNDLE_1_REF)); + bundleLoader.completeGeneration(GenerationStatus.SUCCESS); assertEquals(1, osgi.getInstalledBundles().size()); // The bundle is installed and started @@ -48,6 +50,16 @@ public class ApplicationBundleLoaderTest { } @Test + void current_bundles_metadata_can_be_retrieved() { + bundleLoader.useBundles(List.of(BUNDLE_1_REF, BUNDLE_2_REF)); + bundleLoader.completeGeneration(GenerationStatus.SUCCESS); + + List<BsnVersion> activeBundles = bundleLoader.activeBundlesBsnVersion(); + assertEquals(new BsnVersion(BUNDLE_1), activeBundles.get(0)); + assertEquals(new BsnVersion(BUNDLE_2), activeBundles.get(1)); + } + + @Test void generation_must_be_marked_complete_before_using_new_bundles() { bundleLoader.useBundles(List.of(BUNDLE_1_REF)); assertThrows(IllegalStateException.class, diff --git a/container-core/src/test/java/com/yahoo/container/core/config/BundleTestUtil.java b/container-core/src/test/java/com/yahoo/container/core/config/BundleTestUtil.java index fddbeaf42be..60ea9009e1e 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/BundleTestUtil.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/BundleTestUtil.java @@ -4,6 +4,7 @@ import com.yahoo.config.FileReference; import com.yahoo.filedistribution.fileacquirer.FileAcquirer; import com.yahoo.osgi.Osgi; import org.osgi.framework.Bundle; +import org.osgi.framework.Version; import java.util.List; import java.util.Map; @@ -16,7 +17,7 @@ public class BundleTestUtil { public static final FileReference BUNDLE_1_REF = new FileReference("bundle-1"); public static final Bundle BUNDLE_1 = new TestBundle(BUNDLE_1_REF.value()); public static final FileReference BUNDLE_2_REF = new FileReference("bundle-2"); - public static final Bundle BUNDLE_2 = new TestBundle(BUNDLE_2_REF.value()); + public static final Bundle BUNDLE_2 = new TestBundle(BUNDLE_2_REF.value(), new Version(2, 0, 0, "SNAPSHOT")); public static Map<String, Bundle> testBundles() { return Map.of(BUNDLE_1_REF.value(), BUNDLE_1, diff --git a/container-core/src/test/java/com/yahoo/container/core/config/TestBundle.java b/container-core/src/test/java/com/yahoo/container/core/config/TestBundle.java index 17709844f99..babc936494e 100644 --- a/container-core/src/test/java/com/yahoo/container/core/config/TestBundle.java +++ b/container-core/src/test/java/com/yahoo/container/core/config/TestBundle.java @@ -21,11 +21,17 @@ public class TestBundle extends MockBundle { private static final BundleRevision revision = new TestBundleRevision(); private final String symbolicName; + private final Version version; boolean started = false; public TestBundle(String symbolicName) { + this(symbolicName, BundleVersion); + } + + public TestBundle(String symbolicName, Version version) { this.symbolicName = symbolicName; + this.version = version; } @Override @@ -38,6 +44,10 @@ public class TestBundle extends MockBundle { return symbolicName; } + @Override + public Version getVersion() { + return version; + } @SuppressWarnings("unchecked") @Override |