Search in sources :

Example 1 with ValidatingProcessor

use of org.apache.camel.processor.validation.ValidatingProcessor in project camel by apache.

the class ValidatingProcessorNotUseSharedSchemaTest method setUp.

@Override
protected void setUp() throws Exception {
    validating = new ValidatingProcessor();
    validating.setSchemaFile(new File("src/test/resources/org/apache/camel/processor/ValidatingProcessor.xsd"));
    validating.setUseSharedSchema(false);
    super.setUp();
}
Also used : ValidatingProcessor(org.apache.camel.processor.validation.ValidatingProcessor) File(java.io.File)

Example 2 with ValidatingProcessor

use of org.apache.camel.processor.validation.ValidatingProcessor in project camel by apache.

the class ValidatingProcessorFromSourceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    File file = new File("src/test/resources/org/apache/camel/processor/ValidatingProcessor.xsd");
    String body = context.getTypeConverter().convertTo(String.class, file);
    validating = new ValidatingProcessor();
    validating.setSchemaSource(new StringSource(body));
    // loading scheme can be forced so lets try it
    validating.loadSchema();
}
Also used : ValidatingProcessor(org.apache.camel.processor.validation.ValidatingProcessor) StringSource(org.apache.camel.StringSource) File(java.io.File)

Example 3 with ValidatingProcessor

use of org.apache.camel.processor.validation.ValidatingProcessor in project camel by apache.

the class ValidatorEndpoint method createProducer.

@Override
public Producer createProducer() throws Exception {
    if (!schemaReaderConfigured) {
        if (resourceResolver != null) {
            schemaReader.setResourceResolver(resourceResolver);
        } else if (resourceResolverFactory != null) {
            resourceResolver = resourceResolverFactory.createResourceResolver(getCamelContext(), resourceUri);
            // set the created resource resolver to the resourceResolver variable, so that it can 
            // be accessed by the endpoint
            schemaReader.setResourceResolver(resourceResolver);
        } else {
            schemaReader.setResourceResolver(new DefaultValidatorResourceResolverFactory().createResourceResolver(getCamelContext(), resourceUri));
        }
        schemaReader.setSchemaLanguage(getSchemaLanguage());
        schemaReader.setSchemaFactory(getSchemaFactory());
        // force loading of schema at create time otherwise concurrent
        // processing could cause thread safe issues for the
        // javax.xml.validation.SchemaFactory
        schemaReader.loadSchema();
        // configure only once
        schemaReaderConfigured = true;
    }
    ValidatingProcessor validator = new ValidatingProcessor(schemaReader);
    configureValidator(validator);
    return new ValidatorProducer(this, validator);
}
Also used : ValidatingProcessor(org.apache.camel.processor.validation.ValidatingProcessor)

Example 4 with ValidatingProcessor

use of org.apache.camel.processor.validation.ValidatingProcessor in project camel by apache.

the class ValidatingProcessorFromUrlTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    validating = new ValidatingProcessor();
    URL url = ObjectHelper.loadResourceAsURL("org/apache/camel/processor/ValidatingProcessor.xsd");
    validating.setSchemaUrl(url);
    // loading scheme can be forced so lets try it
    validating.loadSchema();
}
Also used : ValidatingProcessor(org.apache.camel.processor.validation.ValidatingProcessor) URL(java.net.URL)

Example 5 with ValidatingProcessor

use of org.apache.camel.processor.validation.ValidatingProcessor in project camel by apache.

the class ValidatingProcessorTest method setUp.

@Override
protected void setUp() throws Exception {
    validating = new ValidatingProcessor();
    validating.setSchemaFile(new File("src/test/resources/org/apache/camel/processor/ValidatingProcessor.xsd"));
    super.setUp();
}
Also used : ValidatingProcessor(org.apache.camel.processor.validation.ValidatingProcessor) File(java.io.File)

Aggregations

ValidatingProcessor (org.apache.camel.processor.validation.ValidatingProcessor)5 File (java.io.File)3 URL (java.net.URL)1 StringSource (org.apache.camel.StringSource)1