Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ComponentFactory$FactoryClassloader


        m_subscriber.removeAttribute(m_subscriberDataType);
        Attribute unknownType = new Attribute("data-type", "java.lang.String");
        m_subscriber.addAttribute(unknownType);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when unappropriated data type is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the subscriber
View Full Code Here


         * Create the provider and the consumer instances.
         */
        Dictionary properties = new Hashtable();

        // Provider
        ComponentFactory providerFactory = new ComponentFactory(getContext(),
                m_provider);
        providerFactory.start();
        properties.put("instance.name","Emperor of donuts");
        ComponentInstance providerInstance = providerFactory
                .createComponentInstance(properties);
        ServiceReference providerService = IPojoTestUtils
                .getServiceReferenceByName(getContext(), DonutProvider.class
                        .getName(), providerInstance.getInstanceName());
        DonutProvider provider = (DonutProvider) getContext()
                .getService(providerService);

        // The consumer
        properties = new Hashtable();
        ComponentFactory consumerFactory = new ComponentFactory(getContext(),
                m_consumer);
        consumerFactory.start();
        properties.put("instance.name","Homer Simpson");
        properties.put("slow", "false");
        ComponentInstance consumerInstance = consumerFactory
                .createComponentInstance(properties);
        ServiceReference consumerService = IPojoTestUtils
                .getServiceReferenceByName(getContext(), DonutConsumer.class
                        .getName(), consumerInstance.getInstanceName());
        DonutConsumer consumer = (DonutConsumer) getContext()
                .getService(consumerService);

        /**
         * Test the normal behaviour of the instances.
         */
        consumer.clearDonuts();
        Donut sentDonut = provider.sellDonut();
        Donut receivedDonut = consumer.waitForDonut();
        assertEquals("The received donut must be the same as the sent one.",
                sentDonut, receivedDonut);

        /**
         * Destroy component's instances.
         */
        getContext().ungetService(providerService);
        providerInstance.dispose();
        getContext().ungetService(consumerService);
        consumerInstance.dispose();
        providerFactory.stop();
        consumerFactory.stop();
    }
View Full Code Here

        // Remove the name attribute of the publisher
        m_publisher.removeAttribute(m_publisherName);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when no name is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        // Remove the name attribute of the publisher
        m_publisher.removeAttribute(m_publisherField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when no field is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        m_publisher.removeAttribute(m_publisherField);
        Attribute unexistingField = new Attribute("field", "m_unexistingField");
        m_publisher.addAttribute(unexistingField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when an unexisting field is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        m_publisher.removeAttribute(m_publisherField);
        Attribute badTypedField = new Attribute("field", "m_name");
        m_publisher.addAttribute(badTypedField);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when an bad typed field is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        throws ConfigurationException, MissingHandlerException,
        UnacceptableConfiguration {

        // Remove the topics attribute of the publisher
        m_publisher.removeAttribute(m_publisherTopics);
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        fact.start();

        // Try to create an instance without specified topics
        Dictionary conf = new Hashtable();
        conf.put("instance.name","provider without topics");

        ComponentInstance instance;
        try {
            instance = fact.createComponentInstance(conf);
            // Should not be executed
            instance.dispose();
            fail("The factory must not create instance without specified topics.");
        } catch (ConfigurationException e) {
            // OK
        } finally {
            fact.stop();
            // Restore the original state of the publisher
            m_publisher.addAttribute(m_publisherTopics);
        }
    }
View Full Code Here

        Attribute malformedTopics = new Attribute("topics",
                "| |\\| \\/ /-\\ |_ | |)");
        m_publisher.addAttribute(malformedTopics);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when invalid topics are specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        Attribute malformedTopics = new Attribute("topics",
                "a/pattern/topic/*");
        m_publisher.addAttribute(malformedTopics);

        // Create and try to start the factory
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        try {
            fact.start();
            // Should not be executed
            fact.stop();
            fail("The factory must not start when invalid topics are specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

        UnacceptableConfiguration {

        // Remove the topics attribute of the publisher and replace with a
        // malformed one
        m_publisher.removeAttribute(m_publisherTopics);
        ComponentFactory fact = new ComponentFactory(getContext(), m_provider);
        fact.start();

        // Try to create an instance with malformed specified topics
        Dictionary conf = new Hashtable();
        conf.put("instance.name","provider with malformed topics");
        Dictionary topics = new Hashtable();
        topics.put("donut-publisher", "| |\\| \\/ /-\\ |_ | |)");
        conf.put("event.topics", topics);

        ComponentInstance instance;
        try {
            instance = fact.createComponentInstance(conf);
            // Should not be executed
            instance.dispose();
            fail("The factory must not create instance with invalid specified topics.");
        } catch (ConfigurationException e) {
            // OK
        } finally {
            fact.stop();
            // Restore the original state of the publisher
            m_publisher.addAttribute(m_publisherTopics);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.ComponentFactory$FactoryClassloader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.