Package org.apache.synapse.mediators.validate

Examples of org.apache.synapse.mediators.validate.ValidateMediator


    public void testValidateMediatorValidCase() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key", prop);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE, props));

        assertFalse(onFailInvoked);
    }
View Full Code Here


    public void testValidateMediatorValidCaseTwoSchemas() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        keys.add("xsd-key-2");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:Outer");
        source.addNamespace("m0", "http://www.apache-synapse.org/test2");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key-1", prop);
        Property prop2 = new Property();
        prop2.setType(Property.DYNAMIC_TYPE);
        prop2.setKey("file:./../../repository/conf/sample/resources/validate/validate2.xsd");
        props.put("xsd-key-2", prop2);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE_TWO_SCHEMAS, props));

        assertFalse(onFailInvoked);
    }
View Full Code Here

    public void testValidateMediatorInvalidCaseTwoSchemas() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        keys.add("xsd-key-2");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:Outer");
        source.addNamespace("m0", "http://www.apache-synapse.org/test2");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key-1", prop);
        Property prop2 = new Property();
        prop2.setType(Property.DYNAMIC_TYPE);
        prop2.setKey("file:./../../repository/conf/sample/resources/validate/validate2.xsd");
        props.put("xsd-key-2", prop2);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(INVALID_ENVELOPE_TWO_SCHEMAS, props));

        assertTrue(onFailInvoked);
    }
View Full Code Here

    public void testValidateMediatorInvalidCase() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key-1", prop);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(IN_VALID_ENVELOPE, props));

        assertTrue(onFailInvoked);
    }
View Full Code Here

    public void testValidateMediatorValidCaseNoNS() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key-1", prop);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(VALID_ENVELOPE_NO_NS, props));

        assertFalse(onFailInvoked);
    }
View Full Code Here

    public void testValidateMediatorInvalidCaseNoNS() throws Exception {
        setOnFailInvoked(false);

        // create a validate mediator
        ValidateMediator validate = new ValidateMediator();

        // set the schema url, source xpath and any name spaces
        List keys = new ArrayList();
        keys.add("xsd-key-1");
        validate.setSchemaKeys(keys);
        AXIOMXPath source = new AXIOMXPath("//m0:CheckPriceRequest");
        source.addNamespace("m0", "http://www.apache-synapse.org/test");
        validate.setSource(source);

        // set dummy mediator to be called on fail
        validate.addChild(testMediator);

        Map props = new HashMap();
        Property prop = new Property();
        prop.setType(Property.DYNAMIC_TYPE);
        prop.setKey("file:./../../repository/conf/sample/resources/validate/validate.xsd");
        props.put("xsd-key-1", prop);

        // test validate mediator, with static enveope
        validate.mediate(TestUtils.getTestContext(IN_VALID_ENVELOPE_NO_NS, props));

        assertTrue(onFailInvoked);
    }
View Full Code Here

    }

    public void testValidateMediatorDefaultFeatures() throws Exception {

        ValidateMediatorFactory mf = new ValidateMediatorFactory();
        ValidateMediator validate = (ValidateMediator)mf.createMediator(
            createOMElement(DEFAULT_FEATURES_MEDIATOR_CONFIG));

        assertNull(validate.getProperty(SCHEMA_FULL_CHECKING_FEATURE_ID));
        assertNull(validate.getProperty(HONOUR_ALL_SCHEMA_LOCATIONS_FEATURE_ID));

        makeValidInvocation(validate);
    }
View Full Code Here

    }

    public void testValidateMediatorCustomFeatures() throws Exception
    {
        ValidateMediatorFactory mf = new ValidateMediatorFactory();
        ValidateMediator validate = (ValidateMediator)mf.createMediator(
            createOMElement(CUSTOM_FEATURES_MEDIATOR_CONFIG));

        assertNotNull(validate.getProperty(SCHEMA_FULL_CHECKING_FEATURE_ID));
        assertFalse("true".equals((String)validate.getProperty(SCHEMA_FULL_CHECKING_FEATURE_ID)));
        assertNotNull(validate.getProperty(HONOUR_ALL_SCHEMA_LOCATIONS_FEATURE_ID));
        assertTrue("true".equals((String)validate.getProperty(HONOUR_ALL_SCHEMA_LOCATIONS_FEATURE_ID)));

        makeValidInvocation(validate);
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.mediators.validate.ValidateMediator

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.