This is an automated email from the ASF dual-hosted git repository.

pengzheng pushed a commit to branch hotfix/framework-startup-optimization
in repository https://gitbox.apache.org/repos/asf/celix.git


The following commit(s) were added to 
refs/heads/hotfix/framework-startup-optimization by this push:
     new 096db1ee Add test case for updating bundle from a different location.
096db1ee is described below

commit 096db1ee4914e3cca786a7323c7cb51968586093
Author: PengZheng <howto...@gmail.com>
AuthorDate: Wed Aug 2 20:03:56 2023 +0800

    Add test case for updating bundle from a different location.
---
 .../gtest/src/CelixBundleContextBundlesTestSuite.cc | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/libs/framework/gtest/src/CelixBundleContextBundlesTestSuite.cc 
b/libs/framework/gtest/src/CelixBundleContextBundlesTestSuite.cc
index f0c1b0a4..6b673a56 100644
--- a/libs/framework/gtest/src/CelixBundleContextBundlesTestSuite.cc
+++ b/libs/framework/gtest/src/CelixBundleContextBundlesTestSuite.cc
@@ -29,6 +29,9 @@
 
 #include "bundle_context_private.h"
 #include "celix_api.h"
+#include "celix_bundle.h"
+#include "celix_bundle_context.h"
+#include "celix_stdlib_cleanup.h"
 #include "celix_file_utils.h"
 
 class CelixBundleContextBundlesTestSuite : public ::testing::Test {
@@ -313,6 +316,24 @@ TEST_F(CelixBundleContextBundlesTestSuite, 
UpdateBundlesTest) {
     ASSERT_FALSE(celix_bundleContext_updateBundle(ctx, bndId1, NULL));
 }
 
+TEST_F(CelixBundleContextBundlesTestSuite, 
ForceUpdateUsingBundleFromDifferentLocation) {
+    long bndId1 = celix_bundleContext_installBundle(ctx, TEST_BND1_LOC, true);
+    ASSERT_TRUE(bndId1 >= 0L);
+    ASSERT_TRUE(celix_bundleContext_isBundleInstalled(ctx, bndId1));
+    ASSERT_TRUE(celix_bundleContext_isBundleActive(ctx, bndId1));
+    celix_autofree char* name1 = 
celix_bundleContext_getBundleSymbolicName(ctx, bndId1);
+    EXPECT_TRUE(celix_bundleContext_useBundle(ctx, bndId1, nullptr, [] (void 
*, const bundle_t *bundle) {
+        // make bundle cache root newer than the bundle at location 
TEST_BND2_LOC
+        celix_autofree char* root = celix_bundle_getEntry(bundle, "/");
+        celix_utils_touch(root);
+    }));
+    ASSERT_TRUE(celix_bundleContext_updateBundle(ctx, bndId1, TEST_BND2_LOC));
+    ASSERT_TRUE(celix_bundleContext_isBundleInstalled(ctx, bndId1));
+    celix_autofree char* name2 = 
celix_bundleContext_getBundleSymbolicName(ctx, bndId1);
+    // bundle cache contains the bundle at location TEST_BND2_LOC
+    ASSERT_STRNE(name1, name2);
+}
+
 TEST_F(CelixBundleContextBundlesTestSuite, 
UpdateCorruptUncompressedBundlesTest) {
     const char* testExtractDir1 = "extractBundleTestDir1";
     const char* testExtractDir2 = "extractBundleTestDir2";

Reply via email to