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(); }
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 initFramework() { var frameworkFactory = new FrameworkFactory(); framework = frameworkFactory.CreateFramework(); framework.Init(); framework.Start(); bundles = framework.GetBundleContext().GetBundles(); }
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()); } }
/// <summary> /// 运行 /// </summary> private void Run() { try { SubscribeSystemEvents(); // 系统预检查 PreCheck(); // 注册COM控件。 RegisterCOM(); InitializeLogSystem(); GlobalMessageBus.SubscribeApplicationExiting(OnProcessKillingForcedly); _framework.Init(); _framework.Start(); _framework.WaitForStop(); } catch (TargetInvocationException ex) { LogManager.GetLogger(LoggerNames.Platform).Error(ex.InnerException); MessageBox.Show(ex.InnerException.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { LogManager.GetLogger(LoggerNames.Platform).Error(ex); MessageBox.Show(ex.Message, "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { LocalMessageBus.Current.RemoveAll(); ShutdownLogSystem(); ThreadProxy.Shutdown(); System.Diagnostics.Process.GetCurrentProcess().Kill(); } }
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(); }
public static void Init() { Assert.IsNull(iFramework); iFramework = new Center(); iFramework.Init(); }