com.consol.citrus.Citrus Maven / Gradle / Ivy
/*
* Copyright 2006-2010 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.consol.citrus;
import com.consol.citrus.config.CitrusSpringConfig;
import com.consol.citrus.container.SequenceAfterSuite;
import com.consol.citrus.container.SequenceBeforeSuite;
import com.consol.citrus.context.TestContext;
import com.consol.citrus.context.TestContextFactory;
import com.consol.citrus.endpoint.Endpoint;
import com.consol.citrus.exceptions.CitrusRuntimeException;
import com.consol.citrus.message.MessageType;
import com.consol.citrus.report.TestSuiteListeners;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.io.ClassPathResource;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.io.*;
import java.nio.charset.Charset;
import java.util.*;
/**
* Citrus main class initializes a new Citrus runtime environment with a Spring application context. Provides before/after suite action execution
* and test execution methods.
*
* @author Christoph Deppisch
* @since 2.1
*/
public final class Citrus {
/** Citrus version */
private static String version;
/** Test context factory **/
private TestContextFactory testContextFactory;
private TestSuiteListeners testSuiteListener;
private Collection beforeSuite;
private Collection afterSuite;
/** Basic Spring application context */
private ApplicationContext applicationContext;
/** Logger */
private static Logger log = LoggerFactory.getLogger(Citrus.class);
/** Load Citrus version */
static {
try (final InputStream in = new ClassPathResource("META-INF/citrus.version").getInputStream()) {
Properties versionProperties = new Properties();
versionProperties.load(in);
version = versionProperties.get("citrus.version").toString();
} catch (IOException e) {
log.warn("Unable to read Citrus version information", e);
version = "";
}
}
/** Optional application property file */
private static final String APPLICATION_PROPERTY_FILE = System.getProperty("citrus.application.config", "citrus-application.properties");
/** Load application properties */
static {
try (final InputStream in = new ClassPathResource(APPLICATION_PROPERTY_FILE).getInputStream()) {
Properties applicationProperties = new Properties();
applicationProperties.load(in);
log.debug("Loading Citrus application properties");
for (Map.Entry
© 2015 - 2025 Weber Informatics LLC | Privacy Policy