Package org.apache.camel

Examples of org.apache.camel.NoTypeConversionAvailableException


        // we send in a Date object which cannot be converted to XML so it should fail
        try {
            template.requestBody("direct:start", new Date());
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            NoTypeConversionAvailableException ntae = assertIsInstanceOf(NoTypeConversionAvailableException.class, e.getCause().getCause());
            assertEquals(Date.class, ntae.getFromType());
            assertEquals(Document.class, ntae.getToType());
            assertNotNull(ntae.getValue());
            assertNotNull(ntae.getMessage());
        }

        assertMockEndpointsSatisfied();
    }
View Full Code Here


        try {
            template.sendBody("direct:start", new MyOrder());
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            NoTypeConversionAvailableException cause = assertIsInstanceOf(NoTypeConversionAvailableException.class, e.getCause());
            assertEquals("Unknown", cause.getValue());
        }
    }
View Full Code Here

        try {
            template.sendBody("direct:start", new MyOrder());
            fail("Should have thrown an exception");
        } catch (CamelExecutionException e) {
            NoTypeConversionAvailableException cause = assertIsInstanceOf(NoTypeConversionAvailableException.class, e.getCause());
            assertEquals("org.apache.camel.component.bean.BeanOverloadedMethodFQNTest$Unknown", cause.getValue());
        }
    }
View Full Code Here

        ObjectHelper.notNull(camelContext, "CamelContext of Exchange");
        TypeConverter converter = camelContext.getTypeConverter();
        if (converter != null) {
            return converter.mandatoryConvertTo(type, exchange, value);
        }
        throw new NoTypeConversionAvailableException(value, type);
    }
View Full Code Here

    }

    public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws NoTypeConversionAvailableException {
        T answer = convertTo(type, exchange, value);
        if (answer == null) {
            throw new NoTypeConversionAvailableException(value, type);
        }
        return answer;
    }
View Full Code Here

    public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws NoTypeConversionAvailableException {
        T answer;
        try {
            answer = doConvertTo(type, exchange, value);
        } catch (Exception e) {
            throw new NoTypeConversionAvailableException(value, type, e);
        }

        if (answer == null) {
            throw new NoTypeConversionAvailableException(value, type);
        }

        return answer;
    }
View Full Code Here

    public <T> T mandatoryConvertTo(Class<T> type, Exchange exchange, Object value) throws NoTypeConversionAvailableException {
        Object answer;
        try {
            answer = doConvertTo(type, exchange, value);
        } catch (Exception e) {
            throw new NoTypeConversionAvailableException(value, type, e);
        }
        if (answer == Void.TYPE) {
            // Could not find suitable conversion
            throw new NoTypeConversionAvailableException(value, type);
        } else {
            return (T) answer;
        }
    }
View Full Code Here

                public Object evaluate(Exchange exchange) {
                    Object answer = exchange.getIn().getBody(type);
                    if (answer == null) {
                        Object defaultValue = exchange.getIn().getBody();
                        if (defaultValue != null) {
                            throw new RuntimeCamelException(new NoTypeConversionAvailableException(defaultValue, type));
                        }

                        // if we don't have a body then lets instantiate and inject a new instance
                        answer = exchange.getContext().getInjector().newInstance(type);
                    }
View Full Code Here

    }

    public <T> T mandatoryConvertTo(Class<T> type, Object value) throws NoTypeConversionAvailableException {
        T answer = convertTo(type, value);
        if (answer == null) {
            throw new NoTypeConversionAvailableException(value, type);
        }
        return answer;
    }
View Full Code Here

        CamelContext camelContext = exchange.getContext();
        TypeConverter converter = camelContext.getTypeConverter();
        if (converter != null) {
            return converter.mandatoryConvertTo(type, exchange, value);
        }
        throw new NoTypeConversionAvailableException(value, type);
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.NoTypeConversionAvailableException

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.