本文整理汇总了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
示例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")
示例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)
示例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)
示例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)
示例6: tearDown
def tearDown(self):
"""
Called after each test
"""
self.framework.stop()
FrameworkFactory.delete_framework()
self.framework = None
示例7: tearDown
def tearDown(self):
"""
Cleans up the test environment
"""
# Stop the framework
FrameworkFactory.delete_framework()
self.framework = None
示例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()
示例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()
示例10: tearDown
def tearDown(self):
"""
Called after each test
"""
# Destroy the framework
FrameworkFactory.delete_framework()
self.framework = None
self.waiting = None
示例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"
示例12: tearDown
def tearDown(self):
"""
Cleans up the framework
"""
self.framework.stop()
FrameworkFactory.delete_framework()
self.utility = None
self.context = None
self.framework = None
示例13: tearDown
def tearDown(self):
"""
Cleans up the framework
"""
self.framework.stop()
FrameworkFactory.delete_framework()
self.remote = None
self.shell = None
self.framework = None
示例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
示例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)