Package org.switchyard.config.model.validate

Examples of org.switchyard.config.model.validate.ValidatesModel


        getTransformerRegistryLoader().registerTransformers(transforms);
    }

    private void registerValidators() {
        _log.debug("Registering configured Validators for deployment " + getName());
        ValidatesModel validates = getConfig().getValidates();
        getValidatorRegistryLoader().registerValidators(validates);
    }
View Full Code Here


    }

    @Test
    public void testCreate() throws Exception {
        SwitchYardModel switchyard = new V1SwitchYardModel(SwitchYardNamespace.V_1_0.uri());
        ValidatesModel validates = new V1ValidatesModel(SwitchYardNamespace.V_1_0.uri());
        JavaValidateModel javaValidate = new V1JavaValidateModel(ValidateNamespace.V_1_0.uri());
        javaValidate.setName(new QName("msgA"));
        javaValidate.setClazz("org.examples.validate.AValidate");
        validates.addValidate(javaValidate);
        XmlValidateModel xmlValidate = new V1XmlValidateModel(ValidateNamespace.V_1_0.uri());
        xmlValidate.setName(new QName("msgB"));
        xmlValidate.setSchemaType(XmlSchemaType.XML_SCHEMA);
        FileEntryModel entry = new V1FileEntryModel(ValidateNamespace.V_1_0.uri()).setFile("/validates/xxx.xml");
        SchemaFilesModel schemaFiles = new V1SchemaFilesModel(ValidateNamespace.V_1_0.uri());
        schemaFiles.addEntry(entry);
        xmlValidate.setSchemaFiles(schemaFiles);
        xmlValidate.setFailOnWarning(true);
        validates.addValidate(xmlValidate);
        switchyard.setValidates(validates);
        String new_xml = switchyard.toString();
        String old_xml = new ModelPuller<SwitchYardModel>().pull(XML, getClass()).toString();
        XMLUnit.setIgnoreWhitespace(true);
        Diff diff = XMLUnit.compareXML(old_xml, new_xml);
View Full Code Here

    }

    @Test
    public void testRead() throws Exception {
        SwitchYardModel switchyard = _puller.pull(XML, getClass());
        ValidatesModel validates = switchyard.getValidates();
        JavaValidateModel java_validate = (JavaValidateModel)validates.getValidates().get(0);
        Assert.assertEquals("msgA", java_validate.getName().getLocalPart());
        Assert.assertEquals("org.examples.validate.AValidate", java_validate.getClazz());
        XmlValidateModel xml_validate = (XmlValidateModel)validates.getValidates().get(1);
        Assert.assertEquals("msgB", xml_validate.getName().getLocalPart());
        Assert.assertEquals("/validates/xxx.xml", xml_validate.getSchemaFiles().getEntries().get(0).getFile());

    }
View Full Code Here

    }

    @Test
    public void testParenthood() throws Exception {
        SwitchYardModel switchyard_1 = _puller.pull(XML, getClass());
        ValidatesModel validates_1 = switchyard_1.getValidates();
        ValidateModel validate = validates_1.getValidates().get(0);
        ValidatesModel validates_2 = validate.getValidates();
        SwitchYardModel switchyard_2 = validates_2.getSwitchYard();
        Assert.assertEquals(validates_1, validates_2);
        Assert.assertEquals(switchyard_1, switchyard_2);
    }
View Full Code Here

            switchyardConfig = new ModelPuller<SwitchYardModel>().pull(swConfigStream);
        } finally {
            swConfigStream.close();
        }

        ValidatesModel validates = switchyardConfig.getValidates();

        ValidateModel validateModel = validates.getValidates().get(0);

        if (validateModel == null) {
            Assert.fail("No validate config.");
        }
View Full Code Here

     */
    @Override
    public ScannerOutput<SwitchYardModel> scan(ScannerInput<SwitchYardModel> input) throws IOException {
        SwitchYardNamespace switchyardNamespace = input.getSwitchyardNamespace();
        SwitchYardModel switchyardModel = new V1SwitchYardModel(switchyardNamespace.uri());
        ValidatesModel validatesModel = null;

        ValidateNamespace validateNamespace = ValidateNamespace.DEFAULT;
        for (ValidateNamespace value : ValidateNamespace.values()) {
            if (value.versionMatches(switchyardNamespace)) {
                validateNamespace = value;
                break;
            }
        }

        List<Class<?>> validatorClasses = scanForValidators(input.getURLs());
        for (Class<?> validator : validatorClasses) {
            List<ValidatorTypes> supportedValidators = ValidatorUtil.listValidations(validator);

            for (ValidatorTypes supportedValidate : supportedValidators) {
                JavaValidateModel validateModel = new V1JavaValidateModel(validateNamespace.uri());

                String bean = CDIUtil.getNamedAnnotationValue(validator);
                if (bean != null) {
                    validateModel.setBean(bean);
                } else {
                    validateModel.setClazz(validator.getName());
                }
                validateModel.setName(supportedValidate.getName());

                if (validatesModel == null) {
                    validatesModel = new V1ValidatesModel(switchyardNamespace.uri());
                    switchyardModel.setValidates(validatesModel);
                }
                validatesModel.addValidate(validateModel);
            }
        }

        return new ScannerOutput<SwitchYardModel>().setModel(switchyardModel);
    }
View Full Code Here

            for (URL resource : resources) {
                InputStream configStream = resource.openStream();

                try {
                    ValidatesModel validatesModel = new ModelPuller<ValidatesModel>().pull(configStream);
                    registerValidators(validatesModel);
                } catch (final DuplicateValidatorException e) {
                    _log.debug(e.getMessage(), e);
                } finally {
                    configStream.close();
View Full Code Here

TOP

Related Classes of org.switchyard.config.model.validate.ValidatesModel

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.