Package org.objectweb.celtix.configuration

Examples of org.objectweb.celtix.configuration.ConfigurationMetadata


        addModel("config-metadata/wsa-config.xml");
        addModel("config-metadata/instrumentation-config.xml");
    }

    public Configuration buildConfiguration(String namespaceUri, String id, Configuration parent) {
        ConfigurationMetadata model = getModel(namespaceUri);
        if (null == model) {
            throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
        }
        /*
        if (parent != null && !isValidChildConfiguration(model, parent)) {
View Full Code Here


            builder.getModel(UNKNOWN_CONFIGURATION_URI);
        } catch (ConfigurationException ex) {
            assertEquals("UNKNOWN_NAMESPACE_EXC", ex.getCode());
        }
       
        ConfigurationMetadata unknownModel = EasyMock.createMock(ConfigurationMetadata.class);
        unknownModel.getNamespaceURI();
        EasyMock.expectLastCall().andReturn(UNKNOWN_CONFIGURATION_URI);
        EasyMock.replay(unknownModel);
        builder.addModel(unknownModel);
        assertSame(unknownModel, builder.getModel(UNKNOWN_CONFIGURATION_URI));
        EasyMock.verify(unknownModel);
View Full Code Here

        }
    }
   
    public void testGetConfiguration() {
        ConfigurationBuilder builder = new ConfigurationBuilderImpl();
        ConfigurationMetadata model = EasyMock.createMock(ConfigurationMetadata.class);
        model.getNamespaceURI();
        EasyMock.expectLastCall().andReturn(BUS_CONFIGURATION_URI);
        EasyMock.replay(model);
        builder.addModel(model);
        assertNull(builder.getConfiguration(BUS_CONFIGURATION_URI, "celtix"));       
        EasyMock.verify(model);
       
        model = EasyMock.createMock(ConfigurationMetadata.class);
        model.getNamespaceURI();
        EasyMock.expectLastCall().andReturn(HTTP_LISTENER_CONFIGURATION_URI);
        EasyMock.replay(model);
        builder.addModel(model);
        Configuration parent = EasyMock.createMock(Configuration.class);
        assertNull(builder.getConfiguration(HTTP_LISTENER_CONFIGURATION_URI,
View Full Code Here

        }
        return c;
    }

    public Configuration buildConfiguration(String namespaceUri, String id, Configuration parent) {
        ConfigurationMetadata model = getModel(namespaceUri);
        if (null == model) {
            throw new ConfigurationException(new Message("UNKNOWN_NAMESPACE_EXC", BUNDLE, namespaceUri));
        }
        /*
        if (parent != null && !isValidChildConfiguration(model, parent)) {
View Full Code Here

                throw new ConfigurationException(new Message("METADATA_RESOURCE_EXC",
                                                             BUNDLE, resource));
            }
        }

        ConfigurationMetadata model = null;
        ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(true);
        if (null != is) {
            try {
                model = builder.build(is);
            } catch (IOException ex) {
View Full Code Here

        InputSource src = null;
        src = new InputSource(new File(path).toURI().toString());
       
        ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(false);
        builder.setValidation(true);
        ConfigurationMetadata model = null;

        try {
            model = builder.build(src);
        } catch (IOException ex) {
            throw new ConfigurationException(new Message("FAILED_TO_GENERATE_BEAN_EXC", LOG), ex);
        }
       
        String className = SpringUtils.getBeanClassName(model.getNamespaceURI());
       
        StringBuffer classFileName = new StringBuffer(className);
        for (int i = 0; i < classFileName.length(); i++) {
            if ('.' == classFileName.charAt(i)) {
                classFileName.setCharAt(i, File.separatorChar);
View Full Code Here

        cb = ConfigurationBuilderFactory.getBuilder(null);
       
        ConfigurationMetadataBuilder builder = new ConfigurationMetadataBuilder(true);
        InputStream is = DefaultResourceManager.instance()
            .getResourceAsStream("org/objectweb/celtix/bus/configuration/resources/top.xml");
        ConfigurationMetadata model = null;
        try {
            model = builder.build(is);
        } catch (IOException ex) {
            // ignore
        }
        cb.addModel(model);
        return cb.buildConfiguration(model.getNamespaceURI(), id);
    }
View Full Code Here

        assertNotNull(factory.createDefaultProvider(null));
    }
   
    public void testConstruction() {
        assertNotNull(top);       
        ConfigurationMetadata model = top.getModel();
        assertNotNull(model);
        assertEquals(18, model.getDefinitions().size());
    }
View Full Code Here

        "http://celtix.objectweb.org/configuration/types";
   

    public void testStandardTypes() {
            
        ConfigurationMetadata model = buildMetadata("meta1.xml");
        assertEquals("http://celtix.objectweb.org/configuration/test/meta1",
                     model.getNamespaceURI());
        Collection<ConfigurationItemMetadata> definitions = model.getDefinitions();
        assertEquals(9, definitions.size());
        ConfigurationItemMetadata definition = null;
       
        definition = model.getDefinition("booleanItem");
        assertNotNull(definition);
        assertEquals("booleanItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "boolean"),
                     definition.getType());
        assertEquals(LifecyclePolicy.STATIC, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("shortItem");
        assertNotNull(definition);
        assertEquals("shortItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "short"),
                     definition.getType());
       
        definition = model.getDefinition("intItem");
        assertNotNull(definition);
        assertEquals("intItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "int"),
                     definition.getType());
       
        definition = model.getDefinition("integerItem");
        assertNotNull(definition);
        assertEquals("integerItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "integer"),
                     definition.getType());
        // assertNull(definition.getDescription());
        assertEquals(LifecyclePolicy.PROCESS, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("longItem");
        assertNotNull(definition);
        assertEquals("longItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "long"),
                     definition.getType());
        // assertEquals(definition.getName() + " description", definition.getDescription());
        assertEquals(LifecyclePolicy.BUS, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("floatItem");
        assertNotNull(definition);
        assertEquals("floatItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "float"),
                     definition.getType());
       
        definition = model.getDefinition("doubleItem");
        assertNotNull(definition);
        assertEquals("doubleItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "double"),
                     definition.getType());
        // assertEquals(definition.getName() + " description", definition.getDescription());
        assertEquals(LifecyclePolicy.DYNAMIC, definition.getLifecyclePolicy());
       
        definition = model.getDefinition("stringItem");
        assertNotNull(definition);
        assertEquals("stringItem", definition.getName());
        assertEquals(new QName(XMLConstants.W3C_XML_SCHEMA_NS_URI, "string"),
                     definition.getType());
       
        definition = model.getDefinition("stringListItem");
        assertNotNull(definition);
        assertEquals("stringListItem", definition.getName());
        assertEquals(new QName(TYPES_NAMESPACE_URI, "stringListType"),
                     definition.getType());
        assertEquals(LifecyclePolicy.STATIC, definition.getLifecyclePolicy());
View Full Code Here

        }
        assertNotNull(buildMetadata("meta7.xml", false));
    }
   
    public void testDefaultValue() {       
        ConfigurationMetadata model = buildMetadata("meta8.xml");
        Collection<ConfigurationItemMetadata> definitions = model.getDefinitions();
        assertEquals(9, definitions.size());
       
        ConfigurationItemMetadata definition = null
        Object defaultValue = null;
      
        definition = model.getDefinition("booleanItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Boolean", defaultValue.getClass().getName());
        assertEquals(true, ((Boolean)defaultValue).booleanValue());
       
        definition = model.getDefinition("integerItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.math.BigInteger", defaultValue.getClass().getName());
        assertEquals(44959, ((BigInteger)defaultValue).intValue());
       
        definition = model.getDefinition("longItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Long", defaultValue.getClass().getName());
        assertEquals(-99, ((Long)defaultValue).longValue());
       
        definition = model.getDefinition("doubleItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.Double", defaultValue.getClass().getName());
        assertTrue(Math.abs(1234.5678 - ((Double)defaultValue).doubleValue()) < 0.5E-5);
       
        definition = model.getDefinition("stringItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);
        assertEquals("java.lang.String", defaultValue.getClass().getName());
        assertEquals("\"Hello World!\"", (String)defaultValue);
       
        definition = model.getDefinition("stringListItem");
        defaultValue = definition.getDefaultValue();
        assertNotNull(defaultValue);

        assertEquals("org.objectweb.celtix.configuration.types.StringListType",
                     defaultValue.getClass().getName());
View Full Code Here

TOP

Related Classes of org.objectweb.celtix.configuration.ConfigurationMetadata

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.