Package org.switchyard.validate

Examples of org.switchyard.validate.ValidationResult


    @Override
    public void handleMessage(Exchange exchange) throws HandlerException {
        Validator<?> validator = get(exchange);
        if (validator != null) {
            try {
                ValidationResult result = applyValidator(exchange, validator);
                if (!result.isValid()) {
                    throw RuntimeMessages.MESSAGES.validatorFailed(validator.getClass().getName(), result.getDetail());
                }
            } catch (SwitchYardException syEx) {
                // Validators which throw SwitchYardException should be reported as HandlerException   
                throw new HandlerException(syEx.getMessage());
            }
View Full Code Here


    @Override
    public void handleFault(Exchange exchange) {
        Validator<?> validator = get(exchange);
        if (validator != null) {
            ValidationResult result = applyValidator(exchange, validator);
            if (!result.isValid()) {
                RuntimeLogger.ROOT_LOGGER.validatorFailed(validator.getClass().getName(), result.getDetail());
            }
        }
    }
View Full Code Here

    }

    @SuppressWarnings({ "unchecked", "rawtypes" })
    private ValidationResult applyValidator(Exchange exchange, Validator validator) {
        Message message = exchange.getMessage();
        ValidationResult validationResult = null;
        if (Message.class.isAssignableFrom(validator.getType())) {
            validationResult = validator.validate(message);
        } else {
            validationResult = validator.validate(message.getContent(validator.getType()));
        }

        if (validationResult.isValid()) {
            if (_logger.isDebugEnabled()) {
                _logger.debug("Validated Message (" + System.identityHashCode(message)
                        + ") with name '" + validator.getName() + "' using validator type '" + validator.getType() + "'.");
            }
       }
View Full Code Here

    @Test
    public void test_validate_interface_impl() {
        org.switchyard.validate.Validator validator = ValidatorUtil.newValidator(TestValidator.class, JavaTypes.toMessageType(A.class));

        Assert.assertTrue(validator instanceof TestValidator);
        ValidationResult result = validator.validate(new A());
        Assert.assertTrue(result.isValid());
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

    @Test
    public void test_validate_anno_no_types_defined() {
        org.switchyard.validate.Validator validator = ValidatorUtil.newValidator(TestValidator.class, JavaTypes.toMessageType(B.class));

        Assert.assertTrue(!(validator instanceof TestValidator));
        ValidationResult result = validator.validate(new B());
        Assert.assertTrue(result.isValid());
        Assert.assertNull(result.getDetail());
        Assert.assertEquals(B.class, validator.getType());
    }
View Full Code Here

    @Test
    public void test_validate_anno_types_defined() {
        org.switchyard.validate.Validator validator = ValidatorUtil.newValidator(TestValidator.class, QName.valueOf("X"));

        Assert.assertTrue(!(validator instanceof TestValidator));
        ValidationResult result = validator.validate("X");
        Assert.assertTrue(result.isValid());
        Assert.assertNull(result.getDetail());
    }
View Full Code Here

    public void testValidatorEvents() {
        _domain.addEventObserver(_observer, ValidatorAddedEvent.class)
            .addEventObserver(_observer, ValidatorRemovedEvent.class);
        Validator<String> t = new BaseValidator<String>() {
            public ValidationResult validate(String name) {
                return new ValidationResult() {
                    public boolean isValid() {
                        return false;
                    }
                    public String getDetail() {
                        return "error";
View Full Code Here

TOP

Related Classes of org.switchyard.validate.ValidationResult

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.