aboutsummaryrefslogtreecommitdiffstats
path: root/container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java
diff options
context:
space:
mode:
Diffstat (limited to 'container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java')
-rw-r--r--container-core/src/test/java/com/yahoo/container/core/config/ApplicationBundleLoaderTest.java23
1 files changed, 22 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 cf8cc6053cd..04ed52db53b 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
@@ -9,6 +9,7 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.osgi.framework.Bundle;
+import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -70,7 +71,6 @@ public class ApplicationBundleLoaderTest {
assertEquals(BUNDLE_1.getSymbolicName(), osgi.getCurrentBundles().get(0).getSymbolicName());
assertEquals(BUNDLE_2.getSymbolicName(), osgi.getCurrentBundles().get(1).getSymbolicName());
-
// Both file references are active
assertEquals(2, bundleLoader.getActiveFileReferences().size());
assertEquals(BUNDLE_1_REF, bundleLoader.getActiveFileReferences().get(0));
@@ -101,6 +101,27 @@ public class ApplicationBundleLoaderTest {
}
+ @Test
+ void previous_generation_can_be_restored_after_a_failed_reconfig() {
+ bundleLoader.useBundles(List.of(BUNDLE_1_REF));
+ Set<Bundle> obsoleteBundles = bundleLoader.useBundles(List.of(BUNDLE_2_REF));
+ assertEquals(BUNDLE_1.getSymbolicName(), obsoleteBundles.iterator().next().getSymbolicName());
+
+ // Revert to the previous generation, as will be done upon a failed reconfig.
+ Collection<Bundle> bundlesToUninstall = bundleLoader.revertToPreviousGeneration();
+
+ assertEquals(1, bundlesToUninstall.size());
+ assertEquals(BUNDLE_2.getSymbolicName(), bundlesToUninstall.iterator().next().getSymbolicName());
+
+ // Both bundles are still current, until the bundle from the failed gen will be uninstalled.
+ // Uninstalling is handled by the Deconstructor, not included in this test setup.
+ assertEquals(2, osgi.getCurrentBundles().size());
+
+ // Only the bundle-1 file reference is active, bundle-2 is removed.
+ assertEquals(1, bundleLoader.getActiveFileReferences().size());
+ assertEquals(BUNDLE_1_REF, bundleLoader.getActiveFileReferences().get(0));
+ }
+
private static Map<String, Bundle> testBundles() {
return Map.of(BUNDLE_1_REF.value(), BUNDLE_1,
BUNDLE_2_REF.value(), BUNDLE_2);