Examples of ComponentFactory


Examples of org.apache.felix.ipojo.ComponentFactory

        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

Examples of org.apache.felix.ipojo.ComponentFactory

        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

Examples of org.apache.felix.ipojo.ComponentFactory

        // Remove the name attribute of the publisher
        m_subscriber.removeAttribute(m_subscriberName);

        // 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 no name is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

        // Remove the name attribute of the publisher
        m_subscriber.removeAttribute(m_subscriberCallback);

        // 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 no callback is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the publisher
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

        throws ConfigurationException, MissingHandlerException,
        UnacceptableConfiguration {

        // Remove the topics attribute of the subscriber
        m_subscriber.removeAttribute(m_subscriberTopics);
        ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
        fact.start();

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

        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 subscriber
            m_subscriber.addAttribute(m_subscriberTopics);
        }
    }
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

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

        // 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 invalid topics are specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the subscriber
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

        UnacceptableConfiguration {

        // Remove the topics attribute of the subscriber and replace with a
        // malformed one
        m_subscriber.removeAttribute(m_subscriberTopics);
        ComponentFactory fact = new ComponentFactory(getContext(), m_consumer);
        fact.start();

        // Try to create an instance with malformed specified topics
        Dictionary conf = new Hashtable();
        conf.put("instance.name","consumer with malformed topics");
        Dictionary topics = new Hashtable();
        topics.put("donut-subscriber", "| |\\| \\/ /-\\ |_ | |)");
        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 subscriber
            m_subscriber.addAttribute(m_subscriberTopics);
        }
    }
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

        m_subscriber.removeAttribute(m_subscriberDataType);
        Attribute unknownType = new Attribute("data-type", "org.unknown.Clazz");
        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 unknown data type is specified.");
        } catch (IllegalStateException e) {
            // OK
        } finally {
            // Restore the original state of the subscriber
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory


      }

  public void testRevalidationOnReconfiguration() {
    ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(),
        "org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType");

    // First inject a configuration triggering an exception of the validate method.
    Properties props = new Properties();
    props.put("prop", "KO");
    ComponentInstance ci = null;
    try {
      ci = factory.createComponentInstance(props);
    } catch (UnacceptableConfiguration e) {
      e.printStackTrace();
    } catch (MissingHandlerException e) {
      e.printStackTrace();
    } catch (ConfigurationException e) {
View Full Code Here

Examples of org.apache.felix.ipojo.ComponentFactory

        Assert.assertEquals("Is valid ?", ComponentInstance.VALID, arch.getInstanceDescription().getState());
  }

  public void testRevalidationOnReconfigurationWithController() {
    ComponentFactory factory = (ComponentFactory) Utils.getFactoryByName(getContext(),
        "org.apache.felix.ipojo.test.scenarios.component.ReconfigurableSimpleType2");

    // First inject a configuration triggering an exception of the validate method.
    Properties props = new Properties();
    props.put("prop", "KO");
    ComponentInstance ci = null;
    try {
      ci = factory.createComponentInstance(props);
    } catch (UnacceptableConfiguration e) {
      e.printStackTrace();
    } catch (MissingHandlerException e) {
      e.printStackTrace();
    } catch (ConfigurationException e) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.