Skip to content

Commit

Permalink
Add test for bundle uninstall.
Browse files Browse the repository at this point in the history
  • Loading branch information
PengZheng committed May 13, 2023
1 parent f5fe0f4 commit b1ab9ca
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions libs/framework/gtest/src/CelixBundleContextBundlesTestSuite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <celix_log_utils.h>

#include "celix_api.h"
#include "celix_file_utils.h"

class CelixBundleContextBundlesTestSuite : public ::testing::Test {
public:
Expand Down Expand Up @@ -152,6 +153,29 @@ TEST_F(CelixBundleContextBundlesTestSuite, InstallAndUninstallBundlesTest) {
ASSERT_FALSE(celix_bundleContext_isBundleActive(ctx, bndId2)); //not auto started
ASSERT_TRUE(celix_bundleContext_isBundleActive(ctx, bndId3));

char *bndRoot1 = nullptr;
ASSERT_TRUE(celix_bundleContext_useBundle(ctx, bndId1, &bndRoot1, [](void* handle, const celix_bundle_t* bnd) {
char **root = static_cast<char **>(handle);
*root = celix_bundle_getEntry(bnd, "/");
}));
ASSERT_TRUE(bndRoot1 != nullptr);
char* bndRoot2 = nullptr;
ASSERT_TRUE(celix_bundleContext_useBundle(ctx, bndId2, &bndRoot2, [](void* handle, const celix_bundle_t* bnd) {
char **root = static_cast<char **>(handle);
*root = celix_bundle_getEntry(bnd, "/");
}));
ASSERT_TRUE(bndRoot2 != nullptr);
char* bndRoot3 = nullptr;
ASSERT_TRUE(celix_bundleContext_useBundle(ctx, bndId3, &bndRoot3, [](void* handle, const celix_bundle_t* bnd) {
char **root = static_cast<char **>(handle);
*root = celix_bundle_getEntry(bnd, "/");
}));
ASSERT_TRUE(bndRoot3 != nullptr);

ASSERT_TRUE(celix_utils_directoryExists(bndRoot1));
ASSERT_TRUE(celix_utils_directoryExists(bndRoot2));
ASSERT_TRUE(celix_utils_directoryExists(bndRoot3));

//uninstall bundles
ASSERT_TRUE(celix_bundleContext_uninstallBundle(ctx, bndId1));
ASSERT_TRUE(celix_bundleContext_uninstallBundle(ctx, bndId2));
Expand All @@ -165,6 +189,14 @@ TEST_F(CelixBundleContextBundlesTestSuite, InstallAndUninstallBundlesTest) {
ASSERT_FALSE(celix_bundleContext_isBundleActive(ctx, bndId2));
ASSERT_FALSE(celix_bundleContext_isBundleActive(ctx, bndId3));

ASSERT_FALSE(celix_utils_directoryExists(bndRoot1));
ASSERT_FALSE(celix_utils_directoryExists(bndRoot2));
ASSERT_FALSE(celix_utils_directoryExists(bndRoot3));

free(bndRoot1);
free(bndRoot2);
free(bndRoot3);

//reinstall bundles
long bndId4 = celix_bundleContext_installBundle(ctx, TEST_BND1_LOC, true);
long bndId5 = celix_bundleContext_installBundle(ctx, TEST_BND2_LOC, false);
Expand Down

0 comments on commit b1ab9ca

Please sign in to comment.