Package org.switchyard.transform

Examples of org.switchyard.transform.Transformer


    }

    @Test
    public void test_local_xslt_file_fail() throws IOException {
        try {
            Transformer transformer = getTransformer("xslt-config-03.xml");
            DefaultMessage message = newMessage(INITIAL_FAIL);
            Object result = transformer.transform(message);
            Assert.fail("xml to transform should be invalid");
        } catch (SwitchYardException e) {
          boolean exceptionMatch = e.getMessage().contains("SWITCHYARD016800");
          Assert.assertTrue(exceptionMatch);
        }
View Full Code Here


        Assert.assertTrue(transformer instanceof XsltTransformer);
    }

    @Test
    public void test_failonwarn_false_warn() throws IOException, SAXException {
        Transformer transformer = getTransformer("xslt-config-failonwarn-false-warn.xml");
        DefaultMessage message = newMessage(INITIAL);
        transformer.transform(message);
        String result = message.getContent(String.class);

        XMLUnit.setIgnoreWhitespace(true);
        Diff diff = new Diff(EXPECTED, result);
        Assert.assertTrue(diff.toString(), diff.identical());
View Full Code Here

    }

    @Test
    public void test_failonwarn_true_warn() throws IOException, SAXException {
        try {
            Transformer transformer = getTransformer("xslt-config-failonwarn-true-warn.xml");

            Assert.fail("No SwitchYardException has been thrown");
        } catch (SwitchYardException e) {
          boolean exceptionMatch = e.getMessage().contains("SWITCHYARD016802");
          Assert.assertTrue(exceptionMatch);
View Full Code Here

            throw BusMessages.MESSAGES.cannotConvertNoTransformRegistry(body.getClass().getName(), type.getName());
        }

        QName toType = JavaTypes.toMessageType(type);
        QName fromType = JavaTypes.toMessageType(body.getClass());
        Transformer transformer = transformerRegistry.getTransformer(fromType, toType);
        if (transformer == null) {
            T camelBody = super.getBody(type, body);
            if (camelBody == null) {
                throw BusMessages.MESSAGES.transformerMustBeRegistered(body.getClass().getName(), type.getName(), fromType.toString(), toType.toString());
            }
            return camelBody;
        }

        Object transformedContent = transformer.transform(body);
        if (transformedContent == null) {
            throw BusMessages.MESSAGES.transformerReturnedNull(body.getClass().getName(), type.getName(), transformer.getClass().getName());
        }
        if (!type.isInstance(transformedContent)) {
            throw BusMessages.MESSAGES.transformerReturnedIncompatibleType(body.getClass().getName(), type.getName(), transformer.getClass().getName(), transformedContent.getClass().getName());
        }

        return type.cast(transformedContent);
    }
View Full Code Here

    }

    @Test
    public void test_xsl_include_with_href() throws IOException, SAXException {
        try {
            Transformer transformer = getTransformer("xslt-config-include-href.xml");

            Assert.assertTrue(transformer instanceof XsltTransformer);
        } catch (SwitchYardException e) {
            boolean exceptionMatch = e.getMessage().contains("SWITCHYARD016802");
            Assert.assertTrue(exceptionMatch);
View Full Code Here

    }
   
    @Test
    public void test_xsl_include_with_invalid_href() throws IOException, SAXException {
        try {
            Transformer transformer = getTransformer("xslt-config-include-invalid-href.xml");
           
            Assert.fail("No SwitchYardException has been thrown");
        } catch (SwitchYardException e) {
      boolean exceptionMatch = e.getMessage().contains("SWITCHYARD016802");
            Assert.assertTrue(exceptionMatch);
View Full Code Here

            throw RuntimeMessages.MESSAGES.noTransformRegistryAvailable(_content.getClass().getName(), type.getName());
        }

        QName fromType = JavaTypes.toMessageType(_content.getClass());
        QName toType = JavaTypes.toMessageType(type);
        Transformer transformer = _transformerRegistry.getTransformer(fromType, toType);
        if (transformer == null) {
            throw RuntimeMessages.MESSAGES.noRegisteredTransformer(_content.getClass().getName(), type.getName(),
                    fromType.toString(), toType.toString());
        }

        Object transformedContent = transformer.transform(_content);
        if (transformedContent == null) {
            throw RuntimeMessages.MESSAGES.transformerReturnedNull(_content.getClass().getName(), type.getName(),
                    transformer.getClass().getName());
        }
        if (!type.isInstance(transformedContent)) {
            throw RuntimeMessages.MESSAGES.transformerReturnedIncompatibleType(_content.getClass().getName(), type.getName(), transformer.getClass().getName(),
                    transformedContent.getClass().getName());
        }

        return type.cast(transformedContent);
    }
View Full Code Here

TOP

Related Classes of org.switchyard.transform.Transformer

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.