コード例 #1
0
ファイル: test_basic.py プロジェクト: cotyb/ipopo
 def tearDown(self):
     """
     Cleans up the test environment
     """
     # Stop the framework
     FrameworkFactory.delete_framework()
     self.framework = None
コード例 #2
0
    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)
コード例 #3
0
ファイル: test_handlers.py プロジェクト: pombredanne/ipopo
 def tearDown(self):
     """
     Called after each test
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.framework = None
コード例 #4
0
    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
0
ファイル: test_framework.py プロジェクト: cotyb/ipopo
    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()
コード例 #6
0
    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)
コード例 #7
0
ファイル: test_utils.py プロジェクト: huyidao625/ipopo
    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()

        # 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")
コード例 #8
0
def test_init_bundle_loader_with_running_framework(delete_framework):
    """
    Tests that creating a Loader instance with an already running Pelix
    framework will work and enforce a correct configuration of the framework.
    """

    framework = pelix.framework.create_framework(())
    assert framework.get_bundle_by_name("pelix.ipopo.core") is None
    assert FrameworkFactory.is_framework_running()

    # Creating a loader instance where existing framework misses
    # pelix.ipopo.core bundle.
    # This bundle is expected to be added to the framework at Loader
    # initialization
    loader = BundleLoader()
    assert framework is loader.framework
    assert loader.framework.get_bundle_by_name("pelix.ipopo.core") is not None
    del loader

    # Same as above, but now, existing framework HAS pelix.ipopo.core bundle
    loader = BundleLoader()
    assert framework is loader.framework
    assert loader.framework.get_bundle_by_name("pelix.ipopo.core") is not None
    del loader

    # Framework outlives the Loader
    assert FrameworkFactory.is_framework_running()
コード例 #9
0
 def tearDown(self):
     """
     Called after each test
     """
     if self.framework is not None:
         FrameworkFactory.delete_framework(self.framework)
         self.framework = None
コード例 #10
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    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()
コード例 #11
0
ファイル: test_basic_ssl.py プロジェクト: pombredanne/ipopo
 def tearDown(self):
     """
     Cleans up the test environment
     """
     # Stop the framework
     FrameworkFactory.delete_framework()
     self.framework = None
コード例 #12
0
    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")
コード例 #13
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    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()
コード例 #14
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    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()
コード例 #15
0
ファイル: test_utils.py プロジェクト: huyidao625/ipopo
 def tearDown(self):
     """
     Called after each test
     """
     if self.framework is not None:
         FrameworkFactory.delete_framework()
         self.framework = None
コード例 #16
0
ファイル: test_framework.py プロジェクト: cotyb/ipopo
    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()
コード例 #17
0
ファイル: test_waiting_list.py プロジェクト: IUT1-CO2/ipopo
 def tearDown(self):
     """
     Called after each test
     """
     # Destroy the framework
     FrameworkFactory.delete_framework()
     self.framework = None
     self.waiting = None
コード例 #18
0
 def tearDown(self):
     """
     Called after each test
     """
     # Destroy the framework
     FrameworkFactory.delete_framework()
     self.framework = None
     self.waiting = None
コード例 #19
0
ファイル: test_core.py プロジェクト: cotyb/ipopo
 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.utility = None
     self.context = None
     self.framework = None
コード例 #20
0
ファイル: test_remote_tls.py プロジェクト: pombredanne/ipopo
 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.remote = None
     self.shell = None
     self.framework = None
コード例 #21
0
ファイル: test_core.py プロジェクト: pombredanne/ipopo
 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.utility = None
     self.context = None
     self.framework = None
コード例 #22
0
ファイル: test_packages.py プロジェクト: pombredanne/ipopo
    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

        # Reset the environment variable
        os.environ['bundle.import.fail'] = "0"
コード例 #23
0
ファイル: test_packages.py プロジェクト: tcalmant/ipopo
    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

        # Reset the environment variable
        os.environ['bundle.import.fail'] = "0"
コード例 #24
0
    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework(self.framework)

        # Clean up
        self.ipopo = None
        self.framework = None
コード例 #25
0
    def tearDown(self):
        """
        Called after each test
        """
        self.framework.stop()
        FrameworkFactory.delete_framework(self.framework)

        # Clean up
        self.ipopo = None
        self.framework = None
コード例 #26
0
ファイル: test_core.py プロジェクト: pombredanne/ipopo
 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.shell = None
     self.context = None
     self.framework = None
     self._flag = False
コード例 #27
0
ファイル: test_core.py プロジェクト: cotyb/ipopo
 def tearDown(self):
     """
     Cleans up the framework
     """
     self.framework.stop()
     FrameworkFactory.delete_framework()
     self.shell = None
     self.context = None
     self.framework = None
     self._flag = False
コード例 #28
0
    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)
コード例 #29
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    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()
コード例 #30
0
    def testFrameworkStartRaiser(self):
        """
        Tests framework start and stop with a bundle raising exception
        """
        framework = FrameworkFactory.get_framework()
        context = framework.get_bundle_context()

        # Register the stop listener
        context.add_framework_stop_listener(self)

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

        # Set module in raiser mode
        module.raiser = True

        # Framework can start...
        log_off()
        self.assertTrue(framework.start(), "Framework should be started")
        log_on()

        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework should be in ACTIVE state")

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

        # Stop the framework
        self.assertTrue(framework.stop(), "Framework should be stopped")

        # Remove raiser mode
        module.raiser = False

        # Framework can start
        self.assertTrue(framework.start(), "Framework couldn't be started")
        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework should be in ACTIVE state")
        self.assertEqual(bundle.get_state(), Bundle.ACTIVE,
                         "Bundle should be in ACTIVE state")

        # Set module in raiser mode
        module.raiser = True

        # Stop the framework
        log_off()
        self.assertTrue(framework.stop(), "Framework couldn't be stopped")
        log_on()

        self.assertTrue(self.stopping, "Stop listener not called")

        FrameworkFactory.delete_framework(framework)
コード例 #31
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    def testFrameworkStartRaiser(self):
        """
        Tests framework start and stop with a bundle raising exception
        """
        framework = FrameworkFactory.get_framework()
        context = framework.get_bundle_context()

        # Register the stop listener
        context.add_framework_stop_listener(self)

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

        # Set module in raiser mode
        module_.raiser = True

        # Framework can start...
        log_off()
        self.assertTrue(framework.start(), "Framework should be started")
        log_on()

        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework should be in ACTIVE state")

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

        # Stop the framework
        self.assertTrue(framework.stop(), "Framework should be stopped")

        # Remove raiser mode
        module_.raiser = False

        # Framework can start
        self.assertTrue(framework.start(), "Framework couldn't be started")
        self.assertEqual(framework.get_state(), Bundle.ACTIVE,
                         "Framework should be in ACTIVE state")
        self.assertEqual(bundle.get_state(), Bundle.ACTIVE,
                         "Bundle should be in ACTIVE state")

        # Set module in raiser mode
        module_.raiser = True

        # Stop the framework
        log_off()
        self.assertTrue(framework.stop(), "Framework couldn't be stopped")
        log_on()

        self.assertTrue(self.stopping, "Stop listener not called")

        FrameworkFactory.delete_framework()
コード例 #32
0
ファイル: test_framework.py プロジェクト: cotyb/ipopo
    def testBundleZero(self):
        """
        Tests if bundle 0 is the framework
        """
        framework = FrameworkFactory.get_framework()

        self.assertIsNone(framework.get_bundle_by_name(None), "None name is not bundle 0")

        self.assertIs(framework, framework.get_bundle_by_id(0), "Invalid bundle 0")

        pelix_name = framework.get_symbolic_name()
        self.assertIs(framework, framework.get_bundle_by_name(pelix_name), "Invalid system bundle name")

        FrameworkFactory.delete_framework()
コード例 #33
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    def testUninstall(self):
        """
        Tests if the framework raises an exception if uninstall() is called
        """
        # Set up a framework
        framework = FrameworkFactory.get_framework()
        self.assertRaises(BundleException, framework.uninstall)

        # Even once started...
        framework.start()
        self.assertRaises(BundleException, framework.uninstall)
        framework.stop()

        FrameworkFactory.delete_framework()
コード例 #34
0
    def testUninstall(self):
        """
        Tests if the framework raises an exception if uninstall() is called
        """
        # Set up a framework
        framework = FrameworkFactory.get_framework()
        self.assertRaises(BundleException, framework.uninstall)

        # Even once started...
        framework.start()
        self.assertRaises(BundleException, framework.uninstall)
        framework.stop()

        FrameworkFactory.delete_framework(framework)
コード例 #35
0
ファイル: test_report.py プロジェクト: pombredanne/ipopo
    def tearDown(self):
        """
        Cleans up the framework
        """
        self.framework.stop()
        FrameworkFactory.delete_framework()

        # Remove the output file
        if os.path.exists(self.out_file):
            os.remove(self.out_file)

        self.report = None
        self.shell = None
        self.context = None
        self.framework = None
コード例 #36
0
 def framework(self) -> Framework:
     """
     The currently running Pelix framework instance, or a new one if none is running (anyway,
     the framework instance will continue after deletion of this BundleLoader instance)
     """
     if FrameworkFactory.is_framework_running():
         self._framework = FrameworkFactory.get_framework()
         # Do not use self.context, because it will call back this.
         context = self._framework.get_bundle_context()
         if not context.get_service_reference(SERVICE_IPOPO):
             self._framework.install_bundle(SERVICE_IPOPO)
     else:
         self._framework = pelix.framework.create_framework(())
         self._framework.install_bundle(SERVICE_IPOPO)
         self._framework.start()
     return self._framework
コード例 #37
0
    def testDuplicatedFactory(self):
        """
        Tests the behavior of iPOPO if two bundles provide the same factory.
        """
        # Start the framework
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        ipopo = install_ipopo(self.framework)

        # Install bundles: both provide a "basic-component-factory" factory
        # and instantiate a component (both with different names)
        module_A = install_bundle(self.framework, "tests.ipopo.ipopo_bundle")
        module_B = install_bundle(self.framework,
                                  "tests.ipopo.ipopo_bundle_copy")

        # Ensure that the module providing the factory is the correct one
        self.assertIs(module_A,
                      ipopo.get_factory_bundle(
                          module_A.BASIC_FACTORY).get_module(),
                      "Duplicated factory is not provided by the first module")
        self.assertIs(module_A,
                      ipopo.get_factory_bundle(
                          module_B.BASIC_FACTORY).get_module(),
                      "Duplicated factory is not provided by the first module")

        # Component of module A must be there
        self.assertIsNotNone(
            ipopo.get_instance_details(module_A.BASIC_INSTANCE),
            "Component from module A not started")

        # Component of module B must be absent
        self.assertRaises(ValueError,
                          ipopo.get_instance_details, module_B.BASIC_INSTANCE)
コード例 #38
0
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo_bundle = install_bundle(self.framework, "pelix.ipopo.core")
コード例 #39
0
    def testDuplicatedFactory(self):
        """
        Tests the behavior of iPOPO if two bundles provide the same factory.
        """
        # Start the framework
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        ipopo = install_ipopo(self.framework)

        # Install bundles: both provide a "basic-component-factory" factory
        # and instantiate a component (both with different names)
        module_A = install_bundle(self.framework, "tests.ipopo.ipopo_bundle")
        module_B = install_bundle(self.framework,
                                  "tests.ipopo.ipopo_bundle_copy")

        # Ensure that the module providing the factory is the correct one
        self.assertIs(
            module_A,
            ipopo.get_factory_bundle(module_A.BASIC_FACTORY).get_module(),
            "Duplicated factory is not provided by the first module")
        self.assertIs(
            module_A,
            ipopo.get_factory_bundle(module_B.BASIC_FACTORY).get_module(),
            "Duplicated factory is not provided by the first module")

        # Component of module A must be there
        self.assertIsNotNone(
            ipopo.get_instance_details(module_A.BASIC_INSTANCE),
            "Component from module A not started")

        # Component of module B must be absent
        self.assertRaises(ValueError, ipopo.get_instance_details,
                          module_B.BASIC_INSTANCE)
コード例 #40
0
ファイル: test_decorators.py プロジェクト: ahmadshahwan/ipopo
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.context = self.framework.get_bundle_context()
コード例 #41
0
ファイル: test_decorators.py プロジェクト: huyidao625/ipopo
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.context = self.framework.get_bundle_context()
コード例 #42
0
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo = install_ipopo(self.framework)
コード例 #43
0
ファイル: test_contexts.py プロジェクト: IUT1-CO2/ipopo
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo_bundle = install_bundle(self.framework, "pelix.ipopo.core")
コード例 #44
0
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo = install_ipopo(self.framework)
コード例 #45
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    def testBundleZero(self):
        """
        Tests if bundle 0 is the framework
        """
        framework = FrameworkFactory.get_framework()

        self.assertIsNone(framework.get_bundle_by_name(None),
                          "None name is not bundle 0")

        self.assertIs(framework, framework.get_bundle_by_id(0),
                      "Invalid bundle 0")

        pelix_name = framework.get_symbolic_name()
        self.assertIs(framework, framework.get_bundle_by_name(pelix_name),
                      "Invalid system bundle name")

        FrameworkFactory.delete_framework()
コード例 #46
0
ファイル: test_framework.py プロジェクト: cotyb/ipopo
    def testPropertiesWithoutPreset(self):
        """
        Test framework properties
        """
        pelix_test_name = "PELIX_TEST"
        pelix_test = "42"

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

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

        os.environ[pelix_test_name] = pelix_test
        self.assertEqual(framework.get_property(pelix_test_name), pelix_test, "Invalid property value")
        del os.environ[pelix_test_name]

        FrameworkFactory.delete_framework()
コード例 #47
0
    def setUp(self):
        """
        Called before each test. Initiates a framework and loads the current
        module as the first bundle
        """
        self.test_bundle_name = "tests.framework.service_bundle"

        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
コード例 #48
0
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo = install_ipopo(self.framework)
     self.module = install_bundle(self.framework,
                                  "tests.ipopo.ipopo_fields_bundle")
コード例 #49
0
 def setUp(self):
     """
     Called before each test. Initiates a framework.
     """
     self.framework = FrameworkFactory.get_framework()
     self.framework.start()
     self.ipopo = install_ipopo(self.framework)
     self.module = install_bundle(self.framework,
                                  "tests.ipopo.ipopo_fields_bundle")
コード例 #50
0
ファイル: test_services.py プロジェクト: IUT1-CO2/ipopo
    def setUp(self):
        """
        Called before each test. Initiates a framework and loads the current
        module as the first bundle
        """
        self.test_bundle_name = "tests.framework.service_bundle"

        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
コード例 #51
0
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)

        # Install the test bundle
        self.module = install_bundle(self.framework)
コード例 #52
0
ファイル: test_handlers.py プロジェクト: pombredanne/ipopo
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()

        # Compatibility issue
        if sys.version_info[0] < 3:
            self.assertCountEqual = self.assertItemsEqual
コード例 #53
0
ファイル: test_framework.py プロジェクト: pombredanne/ipopo
    def testPropertiesWithoutPreset(self):
        """
        Test framework properties
        """
        pelix_test_name = "PELIX_TEST"
        pelix_test = "42"

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

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

        os.environ[pelix_test_name] = pelix_test
        self.assertEqual(framework.get_property(pelix_test_name), pelix_test,
                         "Invalid property value")
        del os.environ[pelix_test_name]

        FrameworkFactory.delete_framework()
コード例 #54
0
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.ipopo = install_ipopo(self.framework)

        # Install the test bundle
        self.module = install_bundle(self.framework)
コード例 #55
0
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()

        self.test_bundle_name = SIMPLE_BUNDLE

        self.bundle = None
        self.received = []
コード例 #56
0
ファイル: test_packages.py プロジェクト: pombredanne/ipopo
    def setUp(self):
        """
        Called before each test. Initiates a framework.
        """
        self.framework = FrameworkFactory.get_framework()
        self.framework.start()
        self.context = self.framework.get_bundle_context()

        # Get the path to the current test package
        self.test_root = os.path.join(
            os.path.abspath(os.path.dirname(__file__)), "vault")