Package com.consol.citrus.exceptions

Examples of com.consol.citrus.exceptions.CitrusRuntimeException


     */
    public static TemplateBasedScriptBuilder fromTemplateResource(Resource scriptTemplateResource) {
        try {
            return new TemplateBasedScriptBuilder(FileUtils.readToString(scriptTemplateResource.getInputStream()));
        } catch (IOException e) {
            throw new CitrusRuntimeException("Error loading script template from file resource", e);
        }
    }
View Full Code Here


            while ((line = reader.readLine()) != null) {
                contentBuilder.append(PropertyUtils.replacePropertiesInString(line, properties));
                contentBuilder.append("\n");
            }
        } catch (FileNotFoundException e) {
            throw new CitrusRuntimeException("Failed to create test case, unable to find test case template", e);
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to create test case, error while accessing test case template file", e);
        } finally {
            try {
                if (reader != null) {
                    reader.close();
                }
View Full Code Here

            File file = new File(filePath);
            if (!file.getParentFile().exists()) {
                boolean success = file.getParentFile().mkdirs();
               
                if (!success) {
                    throw new CitrusRuntimeException("Unable to create folder structure for test case");
                }
            }
               
            buffered = new BufferedOutputStream(new FileOutputStream(file));
            buffered.write(buildFileContentFromTemplate(properties, templateFilePath).getBytes());
            buffered.flush();
        } catch (FileNotFoundException e) {
            throw new CitrusRuntimeException("Failed to create test case", e);
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to create test case, unable to access test file", e);
        } finally {
            try {
                if (buffered != null) {
                    buffered.close();
                }
View Full Code Here

                messagePayload = buildMarkupBuilderScript(context.replaceDynamicContentInString(scriptData));
            }
           
            return messagePayload;
        } catch (IOException e) {
            throw new CitrusRuntimeException("Failed to build control message payload", e);
        }
    }
View Full Code Here

            Class<?> groovyClass = loader.parseClass(TemplateBasedScriptBuilder.fromTemplateResource(scriptTemplateResource)
                                                            .withCode(scriptData)
                                                            .build());
           
            if (groovyClass == null) {
                throw new CitrusRuntimeException("Could not load groovy script!");   
            }
           
            GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
            return (String) groovyObject.invokeMethod("run", new Object[] {});
        } catch (CompilationFailedException e) {
            throw new CitrusRuntimeException(e);
        } catch (InstantiationException e) {
            throw new CitrusRuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new CitrusRuntimeException(e);
        }
    }
View Full Code Here

        }

        Document doc = XMLUtils.parseMessagePayload(message.getPayload().toString());

        if (doc == null) {
            throw new CitrusRuntimeException("Not able to set message elements, because no XML ressource defined");
        }

        for (Entry<String, String> entry : xPathExpressions.entrySet()) {
            String pathExpression = entry.getKey();
            String valueExpression = entry.getValue();

            //check if value expr is variable or function (and resolve it if yes)
            valueExpression = context.replaceDynamicContentInString(valueExpression);

            if (valueExpression == null) {
                throw new CitrusRuntimeException(
                        "Can not set null values in XML document - path expression is " + pathExpression);
            }

            Node node;
            if (XPathUtils.isXPathExpression(pathExpression)) {
View Full Code Here

                Class<?> groovyClass = loader.parseClass(TemplateBasedScriptBuilder.fromTemplateResource(scriptTemplateResource)
                                                            .withCode(validationScript)
                                                            .build());
               
                if (groovyClass == null) {
                    throw new CitrusRuntimeException("Failed to load groovy validation script resource");
                }
               
                GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance();
                ((GroovyScriptExecutor) groovyObject).validate(receivedMessage, context);
               
                log.info("Groovy message validation finished successfully: All values OK");
            }
        } catch (CompilationFailedException e) {
            throw new CitrusRuntimeException(e);
        } catch (InstantiationException e) {
            throw new CitrusRuntimeException(e);
        } catch (IllegalAccessException e) {
            throw new CitrusRuntimeException(e);
        } catch (AssertionError e) {
            throw new ValidationException("Groovy script validation failed with assertion error:\n" + e.getMessage(), e);
        }
    }
View Full Code Here

        }
       
        try {
            return InetAddress.getLocalHost().getHostName();
        } catch (UnknownHostException e) {
            throw new CitrusRuntimeException("Unable to locate local host address", e);
        }
    }
View Full Code Here

                    if (!outputFile.exists()) {
                        boolean success = outputFile.getFile().getParentFile().mkdirs();
                       
                        if (!success) {
                            throw new CitrusRuntimeException("Unable to create folder structure for JUnit report");
                        }
                       
                        outputFile.createRelative("");
                    }
                   
View Full Code Here

            return context.getApplicationContext().getBean(endpointUri, Endpoint.class);
        }

        StringTokenizer tok = new StringTokenizer(endpointUri, ":");
        if (tok.countTokens() < 2) {
            throw new CitrusRuntimeException(String.format("Invalid endpoint uri '%s'", endpointUri));
        }

        String componentName = tok.nextToken();
        EndpointComponent component = getEndpointComponents(context.getApplicationContext()).get(componentName);

        if (component == null) {
            // try to get component from default Citrus modules
            component = resolveDefaultComponent(componentName);
        }

        if (component == null) {
            throw new CitrusRuntimeException(String.format("Unable to create endpoint component with name '%s'", componentName));
        }

        if (endpointCache.containsKey(endpointUri)) {
            log.info(String.format("Found cached endpoint for uri '%s'", endpointUri));
            return endpointCache.get(endpointUri);
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.