Search in sources :

Example 16 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class TestTool method runScenarios.

public static void runScenarios(ServletContext application, HttpServletRequest request, Writer out, boolean silent) {
    String paramLogLevel = request.getParameter("loglevel");
    String paramAutoScroll = request.getParameter("autoscroll");
    String paramExecute = request.getParameter("execute");
    String paramWaitBeforeCleanUp = request.getParameter("waitbeforecleanup");
    String paramGlobalTimeout = request.getParameter("timeout");
    int timeout = globalTimeout;
    if (paramGlobalTimeout != null) {
        try {
            timeout = Integer.parseInt(paramGlobalTimeout);
        } catch (NumberFormatException e) {
        }
    }
    String servletPath = request.getServletPath();
    int i = servletPath.lastIndexOf('/');
    String realPath = application.getRealPath(servletPath.substring(0, i));
    String paramScenariosRootDirectory = request.getParameter("scenariosrootdirectory");
    IbisContext ibisContext = getIbisContext(application);
    AppConstants appConstants = getAppConstants(ibisContext);
    runScenarios(ibisContext, appConstants, paramLogLevel, paramAutoScroll, paramExecute, paramWaitBeforeCleanUp, timeout, realPath, paramScenariosRootDirectory, out, silent);
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 17 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class TestTool method executeStep.

public static int executeStep(String step, Properties properties, String stepDisplayName, Map<String, Map<String, Object>> queues, Map<String, Object> writers, int parameterTimeout) {
    int stepPassed = RESULT_ERROR;
    String fileName = properties.getProperty(step);
    String fileNameAbsolutePath = properties.getProperty(step + ".absolutepath");
    int i = step.indexOf('.');
    String queueName;
    String fileContent;
    // vul globale var
    zeefVijlNeem = fileNameAbsolutePath;
    // inlezen file voor deze stap
    if ("".equals(fileName)) {
        errorMessage("No file specified for step '" + step + "'", writers);
    } else {
        if (step.endsWith("readline") || step.endsWith("writeline")) {
            fileContent = fileName;
        } else {
            if (fileName.endsWith("ignore")) {
                debugMessage("creating dummy expected file for filename '" + fileName + "'", writers);
                fileContent = "ignore";
            } else {
                debugMessage("Read file " + fileName, writers);
                fileContent = readFile(fileNameAbsolutePath, writers);
            }
        }
        if (fileContent == null) {
            errorMessage("Could not read file '" + fileName + "'", writers);
        } else {
            queueName = step.substring(i + 1, step.lastIndexOf("."));
            if (step.endsWith(".read") || (allowReadlineSteps && step.endsWith(".readline"))) {
                if ("nl.nn.adapterframework.jms.JmsListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJmsListenerRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent);
                } else if ("nl.nn.adapterframework.jdbc.FixedQuerySender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeFixedQuerySenderRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent);
                } else if ("nl.nn.adapterframework.http.IbisWebServiceSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderRead(step, stepDisplayName, properties, queues, writers, queueName, "ibisWebService", fileName, fileContent);
                } else if ("nl.nn.adapterframework.http.WebServiceSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderRead(step, stepDisplayName, properties, queues, writers, queueName, "webService", fileName, fileContent);
                } else if ("nl.nn.adapterframework.http.WebServiceListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJavaListenerOrWebServiceListenerRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent, parameterTimeout);
                } else if ("nl.nn.adapterframework.http.HttpSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderRead(step, stepDisplayName, properties, queues, writers, queueName, "http", fileName, fileContent);
                } else if ("nl.nn.adapterframework.senders.IbisJavaSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderRead(step, stepDisplayName, properties, queues, writers, queueName, "ibisJava", fileName, fileContent);
                } else if ("nl.nn.adapterframework.receivers.JavaListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJavaListenerOrWebServiceListenerRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent, parameterTimeout);
                } else if ("nl.nn.adapterframework.testtool.FileListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeFileListenerRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent);
                } else if ("nl.nn.adapterframework.testtool.FileSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeFileSenderRead(step, stepDisplayName, properties, queues, writers, queueName, fileName, fileContent);
                } else if ("nl.nn.adapterframework.testtool.XsltProviderListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeXsltProviderListenerRead(stepDisplayName, properties, queues, writers, queueName, fileContent, createParametersMapFromParamProperties(properties, step, writers, false, null));
                } else {
                    errorMessage("Property '" + queueName + ".className' not found or not valid", writers);
                }
            } else {
                String resolveProperties = properties.getProperty("scenario.resolveProperties");
                if (resolveProperties == null || !resolveProperties.equalsIgnoreCase("false")) {
                    AppConstants appConstants = AppConstants.getInstance();
                    fileContent = StringResolver.substVars(fileContent, appConstants);
                }
                if ("nl.nn.adapterframework.jms.JmsSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJmsSenderWrite(stepDisplayName, queues, writers, queueName, fileContent);
                } else if ("nl.nn.adapterframework.http.IbisWebServiceSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderWrite(stepDisplayName, queues, writers, queueName, "ibisWebService", fileContent);
                } else if ("nl.nn.adapterframework.http.WebServiceSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderWrite(stepDisplayName, queues, writers, queueName, "webService", fileContent);
                } else if ("nl.nn.adapterframework.http.WebServiceListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJavaOrWebServiceListenerWrite(stepDisplayName, queues, writers, queueName, fileContent);
                } else if ("nl.nn.adapterframework.http.HttpSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderWrite(stepDisplayName, queues, writers, queueName, "http", fileContent);
                } else if ("nl.nn.adapterframework.senders.IbisJavaSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeSenderWrite(stepDisplayName, queues, writers, queueName, "ibisJava", fileContent);
                } else if ("nl.nn.adapterframework.receivers.JavaListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeJavaOrWebServiceListenerWrite(stepDisplayName, queues, writers, queueName, fileContent);
                } else if ("nl.nn.adapterframework.testtool.FileSender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeFileSenderWrite(stepDisplayName, queues, writers, queueName, fileContent);
                } else if ("nl.nn.adapterframework.testtool.XsltProviderListener".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeXsltProviderListenerWrite(step, stepDisplayName, queues, writers, queueName, fileName, fileContent, properties);
                } else if ("nl.nn.adapterframework.senders.DelaySender".equals(properties.get(queueName + ".className"))) {
                    stepPassed = executeDelaySenderWrite(stepDisplayName, queues, writers, queueName, fileContent);
                } else {
                    errorMessage("Property '" + queueName + ".className' not found or not valid", writers);
                }
            }
        }
    }
    return stepPassed;
}
Also used : AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 18 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class LogWriter method doPipe.

@Override
public PipeRunResult doPipe(Message message, PipeLineSession session) throws PipeRunException {
    IbisContext ibisContext = getAdapter().getConfiguration().getIbisManager().getIbisContext();
    AppConstants appConstants = TestTool.getAppConstants(ibisContext);
    // Property webapp.realpath is not available in appConstants which was
    // created with AppConstants.getInstance(ClassLoader classLoader), this
    // should be fixed but for now use AppConstants.getInstance().
    String realPath = AppConstants.getInstance().getResolvedProperty("webapp.realpath") + "larva/";
    List<String> scenariosRootDirectories = new ArrayList<String>();
    List<String> scenariosRootDescriptions = new ArrayList<String>();
    String currentScenariosRootDirectory = TestTool.initScenariosRootDirectories(appConstants, realPath, null, scenariosRootDirectories, scenariosRootDescriptions, null);
    String paramScenariosRootDirectory = currentScenariosRootDirectory;
    String paramExecute = currentScenariosRootDirectory;
    if (StringUtils.isNotEmpty(execute)) {
        paramExecute = paramExecute + execute;
    }
    String paramLogLevel = getLogLevel();
    String paramAutoScroll = "true";
    String paramWaitBeforeCleanUp = getWaitBeforeCleanup();
    LogWriter out = new LogWriter();
    out.setLogger(log);
    out.setWriteToLog(writeToLog);
    out.setWriteToSystemOut(writeToSystemOut);
    boolean silent = true;
    TestTool.setTimeout(getTimeout());
    int numScenariosFailed = TestTool.runScenarios(ibisContext, appConstants, paramLogLevel, paramAutoScroll, paramExecute, paramWaitBeforeCleanUp, getTimeout(), realPath, paramScenariosRootDirectory, out, silent);
    PipeForward forward = numScenariosFailed == 0 ? getSuccessForward() : failForward;
    return new PipeRunResult(forward, out.toString());
}
Also used : IbisContext(nl.nn.adapterframework.configuration.IbisContext) PipeRunResult(nl.nn.adapterframework.core.PipeRunResult) ArrayList(java.util.ArrayList) PipeForward(nl.nn.adapterframework.core.PipeForward) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 19 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class FileSender method runAntScript.

private void runAntScript() {
    Project ant = new Project();
    DefaultLogger consoleLogger = new DefaultLogger();
    consoleLogger.setErrorPrintStream(System.err);
    consoleLogger.setOutputPrintStream(System.out);
    consoleLogger.setMessageOutputLevel(Project.MSG_INFO);
    ant.addBuildListener(consoleLogger);
    // iterate over appConstants and add them as properties
    AppConstants appConstants = AppConstants.getInstance();
    @SuppressWarnings("unchecked") Enumeration<String> enums = (Enumeration<String>) appConstants.propertyNames();
    while (enums.hasMoreElements()) {
        String key = enums.nextElement();
        ant.setProperty(key, appConstants.getResolvedProperty(key));
    }
    ant.init();
    ProjectHelper helper = new ProjectHelperImpl();
    helper.parse(ant, new File(filename));
    ant.executeTarget(ant.getDefaultTarget());
}
Also used : Project(org.apache.tools.ant.Project) ProjectHelper(org.apache.tools.ant.ProjectHelper) Enumeration(java.util.Enumeration) ProjectHelperImpl(org.apache.tools.ant.helper.ProjectHelperImpl) DefaultLogger(org.apache.tools.ant.DefaultLogger) File(java.io.File) AppConstants(nl.nn.adapterframework.util.AppConstants)

Example 20 with AppConstants

use of nl.nn.adapterframework.util.AppConstants in project iaf by ibissource.

the class LoginFilter method init.

@Override
public void init(FilterConfig filterConfig) throws ServletException {
    AppConstants appConstants = AppConstants.getInstance();
    dtapStage = appConstants.getResolvedProperty("dtap.stage");
    instanceName = appConstants.getResolvedProperty("instance.name");
    String ldapAuthMode = appConstants.getString("ldap.auth.mode", LDAP_AUTH_MODE_NONE_STR);
    ldapAuthModeNum = getLdapAuthModeNum(ldapAuthMode);
    if (ldapAuthModeNum < 0) {
        log.warn("Unknown ldapAuthMode [" + ldapAuthMode + "], will use [" + LDAP_AUTH_MODE_NONE_STR + "]");
        ldapAuthModeNum = 0;
    }
    if (ldapAuthModeNum >= LDAP_AUTH_MODE_SIMPLE) {
        String allowedExtensionsString = filterConfig.getInitParameter("allowedExtensions");
        if (allowedExtensionsString != null) {
            allowedExtensions.addAll(Arrays.asList(allowedExtensionsString.split("\\s+")));
        }
        String allowedObserverPathsString = filterConfig.getInitParameter("allowedObserverPaths");
        if (allowedObserverPathsString != null) {
            allowedObserverPaths.addAll(Arrays.asList(allowedObserverPathsString.split("\\s+")));
        }
        String allowedDataAdminPathsString = filterConfig.getInitParameter("allowedDataAdminPaths");
        if (allowedDataAdminPathsString != null) {
            allowedDataAdminPaths.addAll(Arrays.asList(allowedDataAdminPathsString.split("\\s+")));
        }
        String allowedTesterPathsString = filterConfig.getInitParameter("allowedTesterPaths");
        if (allowedTesterPathsString != null) {
            allowedTesterPaths.addAll(Arrays.asList(allowedTesterPathsString.split("\\s+")));
        }
        if (ldapAuthModeNum >= LDAP_AUTH_MODE_BASIC) {
            ldapAuthUrl = appConstants.getResolvedProperty("ldap.auth.url");
            if (ldapAuthUrl == null) {
                String ldapAuthUrlProp = "ldap.auth." + dtapStage.toLowerCase() + ".url";
                ldapAuthUrl = appConstants.getResolvedProperty(ldapAuthUrlProp);
            }
            ldapAuthUserBase = appConstants.getResolvedProperty("ldap.auth.user.base");
            if (ldapAuthModeNum >= LDAP_AUTH_MODE_FULL) {
                ldapAuthObserverBase = appConstants.getResolvedProperty("ldap.auth.observer.base");
                if (ldapAuthObserverBase == null) {
                    throw new ServletException("property [ldap.auth.observer.base] should be set");
                }
                ldapAuthDataAdminBase = appConstants.getResolvedProperty("ldap.auth.dataadmin.base");
                if (ldapAuthDataAdminBase == null) {
                    throw new ServletException("property [ldap.auth.dataadmin.base] should be set");
                }
                ldapAuthTesterBase = appConstants.getResolvedProperty("ldap.auth.tester.base");
                if (ldapAuthTesterBase == null) {
                    throw new ServletException("property [ldap.auth.tester.base] should be set");
                }
            }
        }
    }
}
Also used : ServletException(javax.servlet.ServletException) AppConstants(nl.nn.adapterframework.util.AppConstants)

Aggregations

AppConstants (nl.nn.adapterframework.util.AppConstants)42 IbisContext (nl.nn.adapterframework.configuration.IbisContext)7 File (java.io.File)6 ConfigurationException (nl.nn.adapterframework.configuration.ConfigurationException)6 IOException (java.io.IOException)4 ArrayList (java.util.ArrayList)3 FileWriter (java.io.FileWriter)2 URL (java.net.URL)2 Enumeration (java.util.Enumeration)2 ServletContext (javax.servlet.ServletContext)2 ServletException (javax.servlet.ServletException)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 Date (java.util.Date)1 HashMap (java.util.HashMap)1 ZipEntry (java.util.zip.ZipEntry)1 ZipInputStream (java.util.zip.ZipInputStream)1