Exemplo n.º 1
0
        public void InitShutdown()
        {
            IFrameworkFactory factory = new CFrameworkFactory();

            IFramework fwk = factory.NewFramework(null);

            Assert.IsNotNull(fwk);
            Assert.AreEqual(fwk.getState(), BundleState.INSTALLED);

            fwk.Init();
            Assert.AreEqual(fwk.getState(), BundleState.STARTING);

            IBundleContext ctx = fwk.getBundleContext();

            Assert.IsNotNull(ctx);
            Assert.AreEqual(ctx.getBundle(), fwk);

            Expect.Once.On(mock_fwk_listener)
            .Method("FrameworkEvent")
            .With(new FrameworkEvent(FrameworkEvent.Type.STARTED, fwk, null));
            ctx.AddFrameworkListener(mock_fwk_listener);


            fwk.Start();
            Assert.AreEqual(fwk.getState(), BundleState.ACTIVE);

            fwk.Stop();
            Assert.AreEqual(fwk.getState(), BundleState.STOPPING);

            fwk.WaitForStop(0);
            Assert.AreEqual(fwk.getState(), BundleState.RESOLVED);

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Exemplo n.º 2
0
        public void LoadBundle()
        {
            IFrameworkFactory factory = new CFrameworkFactory();
            IFramework        fwk     = factory.NewFramework(null);

            fwk.Init();

            Expect.Once.On(bundle_listener)
            .Method("BundleChanged");

            IBundleContext ctx = fwk.getBundleContext();

            ctx.AddBundleListener(bundle_listener);

            IBundle test_bundle = ctx.InstallBundle(TEST_BUNDLE_LOCATION);

            Assert.IsNotNull(test_bundle);
            Assert.AreEqual(test_bundle.getState(), BundleState.INSTALLED);

            Assert.AreEqual(test_bundle, ctx.getBundle(test_bundle.getBundleId()));
            Assert.AreEqual(test_bundle, ctx.InstallBundle(TEST_BUNDLE_LOCATION));

            mockery.VerifyAllExpectationsHaveBeenMet();
        }