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();
        }
        public void MultipleInits()
        {
            IFrameworkFactory factory = new CFrameworkFactory();
            IFramework fwk = factory.NewFramework(null);
            fwk.Init();

            IBundleContext ctx = fwk.getBundleContext();

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

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

            fwk.Init();
            fwk.getBundleContext().AddFrameworkListener(mock_fwk_listener);
            fwk.Start();
            Assert.AreEqual(fwk.getState(), BundleState.ACTIVE);
            fwk.Stop();
            fwk.WaitForStop(0);
            Assert.AreEqual(fwk.getState(), BundleState.RESOLVED);

            mocks.VerifyAllExpectationsHaveBeenMet();
        }
Пример #3
0
		static void Main(string[] args)
		{
			try
			{
				IFrameworkFactory factory = new CFrameworkFactory();
				IFramework fwk = factory.NewFramework(null);
				fwk.Init();
				fwk.Start();

				IBundleContext ctx = fwk.getBundleContext();
				IBundle console = ctx.InstallBundle("framework_console");
				console.Start();

				fwk.Stop();
				fwk.WaitForStop(0);
			}
			catch (Exception ex)
			{
				Console.WriteLine(ex.ToString());
			}
		}
Пример #4
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();
		}