Package com.alibaba.citrus.springext

Examples of com.alibaba.citrus.springext.Schema$Transformer


        assertThat(names.size(), greaterThan(0));
        assertThat(names.toString(), containsAll("www.springframework.org", "www.alibaba.com", "spring-beans.xsd"));

        // beans
        Schema beansSchema = names.get("www.springframework.org/schema/beans/spring-beans.xsd");

        assertNotNull(beansSchema);
        assertEquals("http://www.springframework.org/schema/beans", beansSchema.getTargetNamespace());
        assertEquals("http://www.springframework.org/schema/beans", beansSchema.getTargetNamespace()); // try hard

        // dummy
        Schema dummySchema = names.get("www.alibaba.com/schema/tests.xsd");

        assertNotNull(dummySchema);
        assertEquals(null, dummySchema.getTargetNamespace());
        assertEquals(null, dummySchema.getTargetNamespace()); // try hard
    }
View Full Code Here


    @Test
    public void sourceInfo() throws Exception {
        Map<String, Schema> names = sps.getNamedMappings();
        Resource resource;

        Schema beansSchema = names.get("www.springframework.org/schema/beans/spring-beans-2.5.xsd");
        resource = assertSourceInfoAndGetResource(beansSchema, SpringPluggableSchemaSourceInfo.class);
        assertResource("org/springframework/beans/factory/xml/spring-beans-2.5.xsd", resource);

        SpringSchemasSourceInfo parent = ((SpringPluggableSchemaSourceInfo) beansSchema).getParent();
        resource = assertSourceInfoAndGetResource(parent, SpringSchemasSourceInfo.class);
View Full Code Here

    public void unqualifiedStyleContribution() throws Exception {
        cps = new ConfigurationPointsImpl((ClassLoader) null, null);

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/cp1");
        Contribution contrib1 = cp1.getContribution("test1", BEAN_DEFINITION_PARSER);
        Schema schema = contrib1.getSchemas().getMainSchema();

        // my/cp1/test1.xsd包含elementFormDefault,转换后被强制去除。
        assertQualified(schema, false);
    }
View Full Code Here

            }
        });

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/cp1");
        Contribution contrib1 = cp1.getContribution("test1", BEAN_DEFINITION_PARSER);
        Schema schema = contrib1.getSchemas().getMainSchema();

        // my/cp1/test1.xsd包含elementFormDefault。此处摸拟老版本,故qualified被保留。
        assertQualified(schema, true);
    }
View Full Code Here

    @Test
    public void unqualifiedStyleSpringPluggableSchemas() throws Exception {
        sps = new SpringPluggableSchemas();

        Schema schema = sps.getNamedMappings().get("www.alibaba.com/schema/springext-base-types.xsd");

        // springext-base-types.xsd包含elementFormDefault,转换后被保留。
        assertQualified(schema, true);
    }
View Full Code Here

        ConfigurationPoint cp1 = cps.getConfigurationPointByName("my/services");
        resource = assertSourceInfoAndGetResource(cp1, ConfigurationPointSourceInfo.class, null);
        assertResource("TEST-INF/test12/cps", resource);

        // configuration point schema
        Schema cp1Schema = cp1.getSchemas().getMainSchema();
        resource = assertSourceInfoAndGetResource(cp1Schema, ConfigurationPointSchemaSourceInfo.class, cp1);
        assertResource(null, resource);

        Schema cp1Schema2 = cp1.getSchemas().getVersionedSchema("2.0");
        resource = assertSourceInfoAndGetResource(cp1Schema2, ConfigurationPointSchemaSourceInfo.class, cp1);
        assertResource(null, resource);

        // contribution
        Contribution contrib1 = cp1.getContribution("myservice", ContributionType.BEAN_DEFINITION_PARSER);
        resource = assertSourceInfoAndGetResource(contrib1, ContributionSourceInfo.class, cp1);
        assertResource("TEST-INF/test12/my-services.bean-definition-parsers", resource);

        Contribution contrib2 = cp1.getContribution("myservice-abc-xyz", ContributionType.BEAN_DEFINITION_DECORATOR);
        resource = assertSourceInfoAndGetResource(contrib2, ContributionSourceInfo.class, cp1);
        assertResource("TEST-INF/test12/my-services.bean-definition-decorators", resource);

        // contribution schema
        Schema contrib1Schema = contrib1.getSchemas().getMainSchema();
        resource = assertSourceInfoAndGetResource(contrib1Schema, ContributionSchemaSourceInfo.class, contrib1);
        assertResource("TEST-INF/test12/my/services/myservice.xsd", resource);

        Schema contrib1Schema2 = contrib2.getSchemas().getVersionedSchema("2.0");
        resource = assertSourceInfoAndGetResource(contrib1Schema2, ContributionSchemaSourceInfo.class, contrib2);
        assertResource("TEST-INF/test12/my/services/myservice-abc-xyz-2.0.xsd", resource);
    }
View Full Code Here

        ConfigurationPoint cp = cps.getConfigurationPointByName("my/services");
        VersionableSchemas schemas = cp.getSchemas();

        // cp - main schema
        Schema mainSchema = schemas.getMainSchema();

        assertEquals("http://www.alibaba.com/my/services", mainSchema.getTargetNamespace());
        assertEquals("svc", mainSchema.getNamespacePrefix()); // cps定义中指定了nsPrefix

        // cp - version 1.0 schema
        Schema versionedSchema_10 = schemas.getVersionedSchema("1.0");

        assertEquals("http://www.alibaba.com/my/services", versionedSchema_10.getTargetNamespace());
        assertEquals("svc", versionedSchema_10.getNamespacePrefix()); // cps定义中指定了nsPrefix

        // cp - version 2.0 schema
        Schema versionedSchema_20 = schemas.getVersionedSchema("2.0");

        assertEquals("http://www.alibaba.com/my/services", versionedSchema_20.getTargetNamespace());
        assertEquals("svc", versionedSchema_20.getNamespacePrefix()); // cps定义中指定了nsPrefix

        // cp - main schema, no nsPrefix specified
        cp = cps.getConfigurationPointByName("my/plugins");
        schemas = cp.getSchemas();
        mainSchema = schemas.getMainSchema();
View Full Code Here

    @Test
    public void getVersion() {
        Map<String, Schema> names = sps.getNamedMappings();

        Schema beansSchema = names.get("www.springframework.org/schema/beans/spring-beans.xsd");
        assertEquals(null, beansSchema.getVersion());

        Schema beansSchema25 = names.get("www.springframework.org/schema/beans/spring-beans-2.5.xsd");
        assertEquals("2.5", beansSchema25.getVersion());
    }
View Full Code Here

        assertThat(names.size(), greaterThan(0));
        assertThat(names.toString(), containsAll("www.springframework.org", "www.alibaba.com", "spring-beans.xsd"));

        // beans
        Schema beansSchema = names.get("www.springframework.org/schema/beans/spring-beans.xsd");

        assertNotNull(beansSchema);
        assertEquals("http://www.springframework.org/schema/beans", beansSchema.getTargetNamespace());
        assertEquals("http://www.springframework.org/schema/beans", beansSchema.getTargetNamespace()); // try hard

        // dummy
        Schema dummySchema = names.get("www.alibaba.com/schema/tests.xsd");

        assertNotNull(dummySchema);
        assertEquals(null, dummySchema.getTargetNamespace());
        assertEquals(null, dummySchema.getTargetNamespace()); // try hard
    }
View Full Code Here

        assertEquals("testy", i.next().attributeValue("name"));
    }

    private Schema assertReplaced(Map<String, Schema> nameToSchemas, String name, Schema original) {
        assertNotSame(original, nameToSchemas.get(name));
        Schema newSchema = nameToSchemas.remove(name);
        assertNotNull(newSchema);
        return newSchema;
    }
View Full Code Here

TOP

Related Classes of com.alibaba.citrus.springext.Schema$Transformer

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.