当前位置: 首页>>代码示例>>Python>>正文


Python framework.FrameworkFactory类代码示例

本文整理汇总了Python中pelix.framework.FrameworkFactory的典型用法代码示例。如果您正苦于以下问题:Python FrameworkFactory类的具体用法?Python FrameworkFactory怎么用?Python FrameworkFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了FrameworkFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: tearDown

 def tearDown(self):
     """
     Called after each test
     """
     if self.framework is not None:
         FrameworkFactory.delete_framework(self.framework)
         self.framework = None
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:7,代码来源:test_utils.py

示例2: testCreateFrameworkAutoStart

    def testCreateFrameworkAutoStart(self):
        """
        Tests create_framework(), with specified bundles and auto-start
        """
        # Without bundles
        self.framework = pelix.create_framework([], auto_start=True)
        self.assertEqual(self.framework.get_state(), pelix.Bundle.ACTIVE,
                         "Framework hasn't been started")
        self.assertEqual(self.framework.get_bundles(), [],
                         'Framework is not empty')
        # Clean up
        FrameworkFactory.delete_framework(self.framework)

        # With bundles
        self.framework = pelix.create_framework([self.test_bundle_name],
                                                auto_start=True)
        self.assertEqual(self.framework.get_state(), pelix.Bundle.ACTIVE,
                         "Framework hasn't been started")
        self.assertEqual(len(self.framework.get_bundles()), 1,
                         'Framework should only have 1 bundle')

        bundle = self.framework.get_bundle_by_id(1)
        self.assertEqual(bundle.get_symbolic_name(), self.test_bundle_name,
                         "The test bundle hasn't been installed correctly")
        self.assertEqual(bundle.get_state(), pelix.Bundle.ACTIVE,
                         "Bundle hasn't been started")
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:26,代码来源:test_utils.py

示例3: testAddedProperty

    def testAddedProperty(self):
        """
        Tests the add_property method
        """
        pelix_test_name = "PELIX_TEST"
        pelix_test = "42"
        pelix_test_2 = "123"

        # Test without pre-set properties
        framework = FrameworkFactory.get_framework()

        self.assertIsNone(framework.get_property(pelix_test_name),
                          "Magic property value")

        # Add the property
        self.assertTrue(framework.add_property(pelix_test_name, pelix_test),
                        "add_property shouldn't fail on first call")

        self.assertEqual(framework.get_property(pelix_test_name), pelix_test,
                         "Invalid property value")

        # Update the property (must fail)
        self.assertFalse(framework.add_property(pelix_test_name, pelix_test_2),
                         "add_property must fail on second call")

        self.assertEqual(framework.get_property(pelix_test_name), pelix_test,
                         "Invalid property value")

        FrameworkFactory.delete_framework(framework)
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:29,代码来源:test_framework.py

示例4: testFrameworkRestart

    def testFrameworkRestart(self):
        """
        Tests call to Framework.update(), that restarts the framework
        """
        framework = FrameworkFactory.get_framework()
        context = framework.get_bundle_context()

        # Register the stop listener
        context.add_framework_stop_listener(self)

        # Calling update while the framework is stopped should do nothing
        framework.update()
        self.assertFalse(self.stopping, "Stop listener called")

        # Start and update the framework
        self.assertTrue(framework.start(), "Framework couldn't be started")
        framework.update()

        # The framework must have been stopped and must be active
        self.assertTrue(self.stopping, "Stop listener not called")
        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework hasn't been restarted")

        framework.stop()
        FrameworkFactory.delete_framework(framework)
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:25,代码来源:test_framework.py

示例5: testWaitForStop

    def testWaitForStop(self):
        """
        Tests the wait_for_stop() method
        """
        # Set up a framework
        framework = FrameworkFactory.get_framework()

        # No need to wait for the framework...
        self.assertTrue(framework.wait_for_stop(),
                        "wait_for_stop() must return True "
                        "on stopped framework")

        # Start the framework
        framework.start()

        # Start the framework killer
        threading.Thread(target=_framework_killer,
                         args=(framework, 0.5)).start()

        # Wait for stop
        start = time.time()
        self.assertTrue(framework.wait_for_stop(),
                        "wait_for_stop(None) should return True")
        end = time.time()
        self.assertLess(end - start, 1, "Wait should be less than 1 sec")

        FrameworkFactory.delete_framework(framework)
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:27,代码来源:test_framework.py

示例6: tearDown

 def tearDown(self):
     """
     Called after each test
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.framework = None
开发者ID:IUT1-CO2,项目名称:ipopo,代码行数:7,代码来源:test_handlers.py

示例7: tearDown

 def tearDown(self):
     """
     Cleans up the test environment
     """
     # Stop the framework
     FrameworkFactory.delete_framework()
     self.framework = None
开发者ID:cotyb,项目名称:ipopo,代码行数:7,代码来源:test_basic.py

示例8: testWaitForStopTimeout

    def testWaitForStopTimeout(self):
        """
        Tests the wait_for_stop() method
        """
        # Set up a framework
        framework = FrameworkFactory.get_framework()
        framework.start()

        # Start the framework killer
        threading.Thread(target=_framework_killer, args=(framework, 0.5)).start()

        # Wait for stop (timeout not raised)
        start = time.time()
        self.assertTrue(framework.wait_for_stop(1), "wait_for_stop() should return True")
        end = time.time()
        self.assertLess(end - start, 1, "Wait should be less than 1 sec")

        # Restart framework
        framework.start()

        # Start the framework killer
        threading.Thread(target=_framework_killer, args=(framework, 2)).start()

        # Wait for stop (timeout raised)
        start = time.time()
        self.assertFalse(framework.wait_for_stop(1), "wait_for_stop() should return False")
        end = time.time()
        self.assertLess(end - start, 1.2, "Wait should be less than 1.2 sec")

        # Wait for framework to really stop
        framework.wait_for_stop()

        FrameworkFactory.delete_framework()
开发者ID:cotyb,项目名称:ipopo,代码行数:33,代码来源:test_framework.py

示例9: testBundleStart

    def testBundleStart(self):
        """
        Tests if a bundle can be started before the framework itself
        """
        framework = FrameworkFactory.get_framework()
        context = framework.get_bundle_context()
        assert isinstance(context, BundleContext)

        # Install a bundle
        bundle = context.install_bundle(SIMPLE_BUNDLE)

        self.assertEqual(bundle.get_state(), Bundle.RESOLVED, "Bundle should be in RESOLVED state")

        # Starting the bundle now should fail
        self.assertRaises(BundleException, bundle.start)
        self.assertEqual(bundle.get_state(), Bundle.RESOLVED, "Bundle should be in RESOLVED state")

        # Start the framework
        framework.start()

        # Bundle should have been started now
        self.assertEqual(bundle.get_state(), Bundle.ACTIVE, "Bundle should be in ACTIVE state")

        # Stop the framework
        framework.stop()

        self.assertEqual(bundle.get_state(), Bundle.RESOLVED, "Bundle should be in RESOLVED state")

        # Try to start the bundle again (must fail)
        self.assertRaises(BundleException, bundle.start)
        self.assertEqual(bundle.get_state(), Bundle.RESOLVED, "Bundle should be in RESOLVED state")

        FrameworkFactory.delete_framework()
开发者ID:cotyb,项目名称:ipopo,代码行数:33,代码来源:test_framework.py

示例10: tearDown

 def tearDown(self):
     """
     Called after each test
     """
     # Destroy the framework
     FrameworkFactory.delete_framework()
     self.framework = None
     self.waiting = None
开发者ID:IUT1-CO2,项目名称:ipopo,代码行数:8,代码来源:test_waiting_list.py

示例11: tearDown

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

        # Reset the environment variable
        os.environ['bundle.import.fail'] = "0"
开发者ID:tcalmant,项目名称:ipopo,代码行数:9,代码来源:test_packages.py

示例12: tearDown

 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.utility = None
     self.context = None
     self.framework = None
开发者ID:cotyb,项目名称:ipopo,代码行数:9,代码来源:test_core.py

示例13: tearDown

 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.remote = None
     self.shell = None
     self.framework = None
开发者ID:tcalmant,项目名称:ipopo,代码行数:9,代码来源:test_remote_tls.py

示例14: tearDown

    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework(self.framework)

        # Clean up
        self.ipopo = None
        self.framework = None
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:10,代码来源:test_instantiate.py

示例15: testFrameworkStopper

    def testFrameworkStopper(self):
        """
        Tests FrameworkException stop flag handling
        """
        framework = FrameworkFactory.get_framework()
        context = framework.get_bundle_context()

        # Install the bundle
        bundle = context.install_bundle(SIMPLE_BUNDLE)
        module = bundle.get_module()

        # Set module in raiser stop mode
        module.fw_raiser = True
        module.fw_raiser_stop = True

        log_off()
        self.assertFalse(framework.start(), "Framework should be stopped")
        self.assertEqual(framework.get_state(), Bundle.RESOLVED,
                         "Framework should be stopped")
        self.assertEqual(bundle.get_state(), Bundle.RESOLVED,
                         "Bundle should be stopped")
        log_on()

        # Set module in raiser non-stop mode
        module.fw_raiser_stop = False

        log_off()
        self.assertTrue(framework.start(), "Framework should be stopped")
        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework should be started")
        self.assertEqual(bundle.get_state(), Bundle.RESOLVED,
                         "Bundle should be stopped")
        log_on()

        # Start the module
        module.fw_raiser = False
        bundle.start()
        self.assertEqual(bundle.get_state(), Bundle.ACTIVE,
                         "Bundle should be active")

        # Set module in raiser mode
        module.fw_raiser = True
        module.fw_raiser_stop = True

        # Stop the framework
        log_off()
        self.assertTrue(framework.stop(), "Framework couldn't be stopped")
        self.assertEqual(framework.get_state(), Bundle.RESOLVED,
                         "Framework should be stopped")
        self.assertEqual(bundle.get_state(), Bundle.RESOLVED,
                         "Bundle should be stopped")
        log_on()

        FrameworkFactory.delete_framework(framework)
开发者ID:isandlaTech,项目名称:cohorte-3rdparty,代码行数:54,代码来源:test_framework.py


注:本文中的pelix.framework.FrameworkFactory类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。