Package com.consol.citrus.exceptions

Examples of com.consol.citrus.exceptions.CitrusRuntimeException


     */
    public T header(Resource resource) {
        try {
            getMessageContentBuilder().getHeaderData().add(FileUtils.readToString(resource));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read header resource", e);
        }
        return self;
    }
View Full Code Here


            for (String faultDetailPath : faultDetailResourcePaths) {
                String resourcePath = context.replaceDynamicContentInString(faultDetailPath);
                controlFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context))));
            }
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);
        }

        return controlFault;
    }
View Full Code Here

    protected void validateMessage(Message receivedMessage, TestContext context) {
        try {
            super.validateMessage(receivedMessage, context);

            if (!attachments.isEmpty() && !(receivedMessage instanceof SoapMessage)) {
                throw new CitrusRuntimeException(String.format("Unable to perform SOAP attachment validation on message type '%s'", receivedMessage.getClass()));
            }

            for (SoapAttachment attachment : attachments) {
                // handle variables in content id
                if (attachment.getContentId() != null) {
                    attachment.setContentId(context.replaceDynamicContentInString(attachment.getContentId()));
                }

                // handle variables in content type
                if (attachment.getContentType() != null) {
                    attachment.setContentType(context.replaceDynamicContentInString(attachment.getContentType()));
                }

                if (StringUtils.hasText(attachment.getContent())) {
                    attachment.setContent(context.replaceDynamicContentInString(attachment.getContent()));
                } else if (attachment.getContentResourcePath() != null) {
                    attachment.setContent(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(attachment.getContentResourcePath(), context))));
                }

            }

            if (!attachments.isEmpty()) {
                attachmentValidator.validateAttachment((SoapMessage) receivedMessage, attachments);
            }

        } catch (IOException e) {
            throw new CitrusRuntimeException(e);
        }
    }
View Full Code Here

        SoapFault soapFault = new SoapFault();
        soapFault.setPayload(soapMessage.getPayload());

        if (!StringUtils.hasText(faultCode)) {
            throw new CitrusRuntimeException("Missing fault code definition for SOAP fault generation. Please specify a proper SOAP fault code!");
        }
        soapFault.setFaultCode(context.replaceDynamicContentInString(faultCode));

        for (Map.Entry<String, Object> header : soapMessage.copyHeaders().entrySet()) {
            if (!header.getKey().equals(MessageHeaders.ID)) {
                soapFault.setHeader(header.getKey(), header.getValue());
            }
        }

        for (String headerData : soapMessage.getHeaderData()) {
            soapFault.addHeaderData(headerData);
        }

        for (SoapAttachment soapAttachment : soapMessage.getAttachments()) {
            soapFault.addAttachment(soapAttachment);
        }

        if (StringUtils.hasText(faultActor)) {
            soapFault.setFaultActor(context.replaceDynamicContentInString(faultActor));
        }

        if (faultString != null) {
            soapFault.setFaultString(context.replaceDynamicContentInString(faultString));
        }

        for (String faultDetail : faultDetails) {
            soapFault.addFaultDetail(context.replaceDynamicContentInString(faultDetail));
        }

        try {
            for (String faultDetailPath : faultDetailResourcePaths) {
                String resourcePath = context.replaceDynamicContentInString(faultDetailPath);
                soapFault.addFaultDetail(context.replaceDynamicContentInString(FileUtils.readToString(FileUtils.getFileResource(resourcePath, context))));
            }
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to create SOAP fault detail from file resource", e);
        }

        return soapFault;
    }
View Full Code Here

                soapMessage.addAttachment(attachment);
            }

        } catch (IOException e) {
            throw new CitrusRuntimeException(e);
        }

        return soapMessage;
    }
View Full Code Here

        if (WsAddressingVersion.VERSION10.equals(addressingHeaders.getVersion())) {
            version = new Addressing10();
        } else if (WsAddressingVersion.VERSION200408.equals(addressingHeaders.getVersion())) {
            version = new Addressing200408();
        } else {
            throw new CitrusRuntimeException("Unsupported ws addressing version '" +
                    addressingHeaders.getVersion() + "'");
        }

        version.addAddressingHeaders(soapMessage, map);
    }
View Full Code Here

        try {
            Transformer transformer = transformerFactory.newTransformer();
            transformer.transform(new StringSource(soapMessage.getPayload().toString()), soapRequest.getSoapBody().getPayloadResult());
        } catch (TransformerException e) {
            throw new CitrusRuntimeException("Failed to write SOAP body payload", e);
        }

        // Copy headers into soap-header:
        for (Entry<String, Object> headerEntry : soapMessage.copyHeaders().entrySet()) {
            if (MessageHeaderUtils.isSpringInternalHeader(headerEntry.getKey())) {
                continue;
            }

            if (headerEntry.getKey().equalsIgnoreCase(SoapMessageHeaders.SOAP_ACTION)) {
                soapRequest.setSoapAction(headerEntry.getValue().toString());
            } else if (headerEntry.getKey().toLowerCase().startsWith(SoapMessageHeaders.HTTP_PREFIX)) {
                handleOutboundMimeMessageHeader(soapRequest,
                        headerEntry.getKey().substring(SoapMessageHeaders.HTTP_PREFIX.length()),
                        headerEntry.getValue(),
                        endpointConfiguration.isHandleMimeHeaders());
            } else if (!headerEntry.getKey().startsWith(MessageHeaders.PREFIX)) {
                SoapHeaderElement headerElement;
                if (QNameUtils.validateQName(headerEntry.getKey())) {
                    headerElement = soapRequest.getSoapHeader().addHeaderElement(QNameUtils.parseQNameString(headerEntry.getKey()));
                } else {
                    headerElement = soapRequest.getSoapHeader().addHeaderElement(QNameUtils.createQName("", headerEntry.getKey(), ""));
                }

                headerElement.setText(headerEntry.getValue().toString());
            }
        }

        for (String headerData : soapMessage.getHeaderData()) {
            try {
                Transformer transformer = transformerFactory.newTransformer();
                transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
                transformer.transform(new StringSource(headerData),
                        soapRequest.getSoapHeader().getResult());
            } catch (TransformerException e) {
                throw new CitrusRuntimeException("Failed to write SOAP header content", e);
            }
        }

        for (final Attachment attachment : soapMessage.getAttachments()) {
            if (log.isDebugEnabled()) {
View Full Code Here

            handleInboundHttpHeaders(message);

            return message;
        } catch (TransformerException e) {
            throw new CitrusRuntimeException("Failed to read web service message payload source", e);
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to read web service message", e);
        }
    }
View Full Code Here

                        message.setHeader(SoapMessageHeaders.SOAP_ACTION, soapMessage.getSoapAction());
                    }
                }
            }
        } catch (TransformerException e) {
            throw new CitrusRuntimeException("Failed to read SOAP header source", e);
        }
    }
View Full Code Here

    /**
     * Create the test case.
     */
    public void createTestCase() {
        if (Character.isLowerCase(name.charAt(0))) {
            throw new CitrusRuntimeException("Test name must start with an uppercase letter");
        }
       
        Properties properties = prepareTestCaseProperties();
       
        targetPackage = targetPackage.replace('.', '/');
View Full Code Here

TOP

Related Classes of com.consol.citrus.exceptions.CitrusRuntimeException

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.