diff options
author | gjoranv <gv@verizonmedia.com> | 2022-09-07 11:48:41 +0200 |
---|---|---|
committer | gjoranv <gv@verizonmedia.com> | 2022-09-07 11:48:41 +0200 |
commit | 382bf26442e368ea00e349a05340fe781144e93a (patch) | |
tree | f6c799f6545421f02b5cd3f676ca49b65c6e1e98 /container-core | |
parent | 21843fba7d909e1dc09c3c999e71982ad9a8b368 (diff) |
Add test verifying that bundles are uninstalled for generations..
that fail in the graph setup phase.
Diffstat (limited to 'container-core')
-rw-r--r-- | container-core/src/test/java/com/yahoo/container/di/ContainerTest.java | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java b/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java index 625e81997f9..c0d691c8a5a 100644 --- a/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java +++ b/container-core/src/test/java/com/yahoo/container/di/ContainerTest.java @@ -215,6 +215,31 @@ public class ContainerTest extends ContainerTestBase { assertEquals(1, currentGraph.generation()); } + @Test + void bundle_from_generation_that_throws_in_graph_creation_phase_is_uninstalled() { + ComponentEntry simpleComponent = new ComponentEntry("simpleComponent", SimpleComponent.class); + ComponentEntry configThrower = new ComponentEntry("configThrower", ComponentThrowingExceptionForMissingConfig.class); + + writeBootstrapConfigsWithBundles(List.of("bundle-1"), List.of(simpleComponent)); + Container container = newContainer(dirConfigSource); + ComponentGraph currentGraph = getNewComponentGraph(container); + + // bundle-1 is installed + assertEquals(1, osgi.getBundles().length); + assertEquals("bundle-1", osgi.getBundles()[0].getSymbolicName()); + + writeBootstrapConfigsWithBundles(List.of("bundle-2"), List.of(configThrower)); + dirConfigSource.writeConfig("test", "stringVal \"myString\""); + container.reloadConfig(2); + + assertNewComponentGraphFails(container, currentGraph, IllegalArgumentException.class); + assertEquals(1, currentGraph.generation()); + + // bundle-1 is kept, bundle-2 has been uninstalled + assertEquals(1, osgi.getBundles().length); + assertEquals("bundle-1", osgi.getBundles()[0].getSymbolicName()); + } + private void assertNewComponentGraphFails(Container container, ComponentGraph currentGraph, Class<? extends RuntimeException> exception) { try { getNewComponentGraph(container, currentGraph); |