| 35 | #ifdef US_BUILD_SHARED_LIBS |
| 36 | |
| 37 | TEST(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 | |
| 62 | TEST(BundleValidationTest, BundleValidationSuccess) |
| 63 | { |
nothing calls this directly
no test coverage detected