MCPcopy Create free account
hub / github.com/CppMicroServices/CppMicroServices / TEST

Function TEST

framework/test/gtest/BundleValidationTest.cpp:37–60  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35#ifdef US_BUILD_SHARED_LIBS
36
37TEST(BundleValidationTest, BundleValidationFailure)
38{
39 using validationFuncType = std::function<bool(cppmicroservices::Bundle const&)>;
40
41 validationFuncType validationFunc = [](cppmicroservices::Bundle const&) -> bool { return false; };
42 cppmicroservices::FrameworkConfiguration configuration {
43 {cppmicroservices::Constants::FRAMEWORK_BUNDLE_VALIDATION_FUNC, validationFunc}
44 };
45
46 auto f = cppmicroservices::FrameworkFactory().NewFramework(std::move(configuration));
47 ASSERT_NO_THROW(f.Start());
48
49 auto bundleA = cppmicroservices::testing::InstallLib(f.GetBundleContext(), "TestBundleA");
50 ASSERT_TRUE(bundleA);
51
52 ASSERT_THROW(bundleA.Start(), cppmicroservices::SecurityException);
53 // a bundle validation function which returns false must cause the
54 // Framework not to start the bundle and it should not be loaded
55 // into the process.
56 ASSERT_EQ(bundleA.GetState(), cppmicroservices::Bundle::State::STATE_RESOLVED);
57
58 f.Stop();
59 f.WaitForStop(std::chrono::milliseconds::zero());
60}
61
62TEST(BundleValidationTest, BundleValidationSuccess)
63{

Callers

nothing calls this directly

Calls 12

InstallLibFunction · 0.85
NewFrameworkMethod · 0.80
GetSymbolicNameMethod · 0.80
StartMethod · 0.45
GetBundleContextMethod · 0.45
GetStateMethod · 0.45
StopMethod · 0.45
WaitForStopMethod · 0.45
AddFrameworkListenerMethod · 0.45
GetTypeMethod · 0.45
GetBundleMethod · 0.45
RemoveListenerMethod · 0.45

Tested by

no test coverage detected