Skip to content

Commit

Permalink
Merge branch 'citrusframework:main' into feat/improve-schema-resolvin…
Browse files Browse the repository at this point in the history
…g-DomXmlMessageValidator
  • Loading branch information
Tom-29 authored Sep 25, 2023
2 parents 0e5afa8 + cf23cba commit 5f2907a
Show file tree
Hide file tree
Showing 373 changed files with 3,611 additions and 1,729 deletions.
5 changes: 5 additions & 0 deletions catalog/citrus-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,11 @@
<artifactId>citrus-junit5</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-quarkus</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.citrusframework</groupId>
<artifactId>citrus-main</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class DockerExecuteAction extends AbstractTestAction {
public static final String DEFAULT_JSON_MESSAGE_VALIDATOR = "defaultJsonMessageValidator";

/** Logger */
private static Logger log = LoggerFactory.getLogger(DockerExecuteAction.class);
private static final Logger logger = LoggerFactory.getLogger(DockerExecuteAction.class);

/**
* Default constructor.
Expand All @@ -94,14 +94,14 @@ public DockerExecuteAction(Builder builder) {
@Override
public void doExecute(TestContext context) {
try {
if (log.isDebugEnabled()) {
log.debug(String.format("Executing Docker command '%s'", command.getName()));
if (logger.isDebugEnabled()) {
logger.debug(String.format("Executing Docker command '%s'", command.getName()));
}
command.execute(dockerClient, context);

validateCommandResult(command, context);

log.info(String.format("Docker command execution successful: '%s'", command.getName()));
logger.info(String.format("Docker command execution successful: '%s'", command.getName()));
} catch (CitrusRuntimeException e) {
throw e;
} catch (Exception e) {
Expand All @@ -115,8 +115,8 @@ public void doExecute(TestContext context) {
* @param context
*/
private void validateCommandResult(DockerCommand command, TestContext context) {
if (log.isDebugEnabled()) {
log.debug("Starting Docker command result validation");
if (logger.isDebugEnabled()) {
logger.debug("Starting Docker command result validation");
}

if (StringUtils.hasText(expectedCommandResult)) {
Expand All @@ -128,7 +128,7 @@ private void validateCommandResult(DockerCommand command, TestContext context) {
String commandResultJson = jsonMapper.writeValueAsString(command.getCommandResult());
JsonMessageValidationContext validationContext = new JsonMessageValidationContext();
getMessageValidator(context).validateMessage(new DefaultMessage(commandResultJson), new DefaultMessage(expectedCommandResult), context, Collections.singletonList(validationContext));
log.info("Docker command result validation successful - all values OK!");
logger.info("Docker command result validation successful - all values OK!");
} catch (JsonProcessingException e) {
throw new CitrusRuntimeException(e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
public class DockerClient extends AbstractEndpoint implements Producer, ReplyConsumer {

/** Logger */
private static Logger log = LoggerFactory.getLogger(DockerClient.class);
private static final Logger logger = LoggerFactory.getLogger(DockerClient.class);

/** Store of reply messages */
private CorrelationManager<DockerCommand> correlationManager;
Expand Down Expand Up @@ -74,14 +74,14 @@ public void send(Message message, TestContext context) {
String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(message);
correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context);

if (log.isDebugEnabled()) {
log.debug("Sending Docker request to: '" + getEndpointConfiguration().getDockerClientConfig().getDockerHost() + "'");
if (logger.isDebugEnabled()) {
logger.debug("Sending Docker request to: '" + getEndpointConfiguration().getDockerClientConfig().getDockerHost() + "'");
}

DockerCommand command = message.getPayload(DockerCommand.class);
command.execute(this, context);

log.info("Docker request was sent to endpoint: '" + getEndpointConfiguration().getDockerClientConfig().getDockerHost() + "'");
logger.info("Docker request was sent to endpoint: '" + getEndpointConfiguration().getDockerClientConfig().getDockerHost() + "'");

correlationManager.store(correlationKey, command);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class ContainerInspect extends AbstractDockerCommand<InspectContainerResponse> {

/** Logger */
private static Logger log = LoggerFactory.getLogger(ContainerInspect.class);
private static final Logger logger = LoggerFactory.getLogger(ContainerInspect.class);

/**
* Default constructor initializing the command name.
Expand All @@ -47,7 +47,7 @@ public void execute(DockerClient dockerClient, TestContext context) {

setCommandResult(response);

log.debug(response.toString());
logger.debug(response.toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class ImageInspect extends AbstractDockerCommand<InspectImageResponse> {

/** Logger */
private static Logger log = LoggerFactory.getLogger(ImageInspect.class);
private static final Logger logger = LoggerFactory.getLogger(ImageInspect.class);

/**
* Default constructor initializing the command name.
Expand All @@ -46,7 +46,7 @@ public void execute(DockerClient dockerClient, TestContext context) {
InspectImageResponse response = command.exec();

setCommandResult(response);
log.debug(response.toString());
logger.debug(response.toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class Info extends AbstractDockerCommand<com.github.dockerjava.api.model.Info> {

/** Logger */
private static Logger log = LoggerFactory.getLogger(Info.class);
private static final Logger logger = LoggerFactory.getLogger(Info.class);

/**
* Default constructor initializing the command name.
Expand All @@ -41,7 +41,7 @@ public Info() {
@Override
public void execute(DockerClient dockerClient, TestContext context) {
setCommandResult(dockerClient.getEndpointConfiguration().getDockerClient().infoCmd().exec());
log.debug(getCommandResult().toString());
logger.debug(getCommandResult().toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class Version extends AbstractDockerCommand<com.github.dockerjava.api.model.Version> {

/** Logger */
private static Logger log = LoggerFactory.getLogger(Version.class);
private static final Logger logger = LoggerFactory.getLogger(Version.class);

/**
* Default constructor initializing the command name.
Expand All @@ -44,7 +44,7 @@ public void execute(DockerClient dockerClient, TestContext context) {
VersionCmd command = dockerClient.getEndpointConfiguration().getDockerClient().versionCmd();
setCommandResult(command.exec());

log.debug(getCommandResult().toString());
logger.debug(getCommandResult().toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
public class AbstractDockerIT extends TestNGCitrusSpringSupport {

/** Logger */
private static final Logger log = LoggerFactory.getLogger(AbstractDockerIT.class);
private static final Logger logger = LoggerFactory.getLogger(AbstractDockerIT.class);

/** Docker connection state, checks connectivity only once per test run */
private static boolean connected = false;
Expand All @@ -57,7 +57,7 @@ public void checkDockerEnvironment() {

connected = future.get(5000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
log.warn("Skipping Docker test execution as no proper Docker environment is available on host system!", e);
logger.warn("Skipping Docker test execution as no proper Docker environment is available on host system!", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public class KubernetesExecuteAction extends AbstractTestAction {
public static final String DEFAULT_JSON_PATH_MESSAGE_VALIDATOR = "defaultJsonPathMessageValidator";

/** Logger */
private static Logger log = LoggerFactory.getLogger(KubernetesExecuteAction.class);
private static final Logger logger = LoggerFactory.getLogger(KubernetesExecuteAction.class);

/**
* Default constructor.
Expand All @@ -123,14 +123,14 @@ public KubernetesExecuteAction(Builder builder) {
@Override
public void doExecute(TestContext context) {
try {
if (log.isDebugEnabled()) {
log.debug(String.format("Executing Kubernetes command '%s'", command.getName()));
if (logger.isDebugEnabled()) {
logger.debug(String.format("Executing Kubernetes command '%s'", command.getName()));
}
command.execute(kubernetesClient, context);

validateCommandResult(command, context);

log.info(String.format("Kubernetes command execution successful: '%s'", command.getName()));
logger.info(String.format("Kubernetes command execution successful: '%s'", command.getName()));
} catch (CitrusRuntimeException e) {
throw e;
} catch (Exception e) {
Expand All @@ -144,8 +144,8 @@ public void doExecute(TestContext context) {
* @param context
*/
private void validateCommandResult(KubernetesCommand command, TestContext context) {
if (log.isDebugEnabled()) {
log.debug("Starting Kubernetes command result validation");
if (logger.isDebugEnabled()) {
logger.debug("Starting Kubernetes command result validation");
}

CommandResult<?> result = command.getCommandResult();
Expand All @@ -159,15 +159,15 @@ private void validateCommandResult(KubernetesCommand command, TestContext contex
.getObjectMapper().writeValueAsString(result);
if (StringUtils.hasText(commandResult)) {
getMessageValidator(context).validateMessage(new DefaultMessage(commandResultJson), new DefaultMessage(commandResult), context, Collections.singletonList(new JsonMessageValidationContext()));
log.info("Kubernetes command result validation successful - all values OK!");
logger.info("Kubernetes command result validation successful - all values OK!");
}

if (!CollectionUtils.isEmpty(commandResultExpressions)) {
JsonPathMessageValidationContext validationContext = new JsonPathMessageValidationContext.Builder()
.expressions(commandResultExpressions)
.build();
getPathValidator(context).validateMessage(new DefaultMessage(commandResultJson), new DefaultMessage(commandResult), context, Collections.singletonList(validationContext));
log.info("Kubernetes command result path validation successful - all values OK!");
logger.info("Kubernetes command result path validation successful - all values OK!");
}
} catch (JsonProcessingException e) {
throw new CitrusRuntimeException(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
public class KubernetesClient extends AbstractEndpoint implements Producer, ReplyConsumer {

/** Logger */
private static Logger log = LoggerFactory.getLogger(KubernetesClient.class);
private static final Logger logger = LoggerFactory.getLogger(KubernetesClient.class);

/** Store of reply messages */
private CorrelationManager<KubernetesCommand> correlationManager;
Expand Down Expand Up @@ -72,14 +72,14 @@ public void send(Message message, TestContext context) {
String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(message);
correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context);

if (log.isDebugEnabled()) {
log.debug("Sending Kubernetes request to: '" + getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl() + "'");
if (logger.isDebugEnabled()) {
logger.debug("Sending Kubernetes request to: '" + getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl() + "'");
}

KubernetesCommand<?> command = getEndpointConfiguration().getMessageConverter().convertOutbound(message, getEndpointConfiguration(), context);
command.execute(this, context);

log.info("Kubernetes request was sent to endpoint: '" + getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl() + "'");
logger.info("Kubernetes request was sent to endpoint: '" + getEndpointConfiguration().getKubernetesClientConfig().getMasterUrl() + "'");

correlationManager.store(correlationKey, command);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
import org.citrusframework.exceptions.CitrusRuntimeException;
import org.citrusframework.kubernetes.message.KubernetesMessageHeaders;
import io.fabric8.kubernetes.api.model.KubernetesResource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.StringUtils;

import java.util.*;
Expand All @@ -32,9 +30,6 @@
*/
public abstract class AbstractKubernetesCommand<R extends KubernetesResource, T extends KubernetesCommand<R>> implements KubernetesCommand<R> {

/** Logger */
protected Logger log = LoggerFactory.getLogger(getClass());

/** Self reference for generics support */
private final T self;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,18 @@
import io.fabric8.kubernetes.client.Watch;
import io.fabric8.kubernetes.client.Watcher;
import io.fabric8.kubernetes.client.dsl.ClientNonNamespaceOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Christoph Deppisch
* @since 2.7
*/
public abstract class AbstractWatchCommand<R extends KubernetesResource, T extends KubernetesCommand<R>> extends AbstractClientCommand<ClientNonNamespaceOperation, R, T> {

/** Logger */
private final Logger logger = LoggerFactory.getLogger(getClass());

/** Watch handle */
private Watch watch;

Expand All @@ -61,7 +66,7 @@ public void eventReceived(Action action, R resource) {
if (results.isEmpty() && cachedResult == null) {
results.add(new WatchEventResult<>(resource, action));
} else {
log.debug("Ignoring watch result: " + action.name());
logger.debug("Ignoring watch result: " + action.name());
}
}

Expand Down Expand Up @@ -89,7 +94,7 @@ public WatchEventResult<R> getCommandResult() {
try {
watch.close();
} catch (KubernetesClientException e) {
log.warn("Failed to gracefully close watch", e);
logger.warn("Failed to gracefully close watch", e);
}

watchEventResult.setWatch(watch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class AbstractKubernetesIT extends TestNGCitrusSpringSupport {

/** Logger */
private static final Logger log = LoggerFactory.getLogger(AbstractKubernetesIT.class);
private static final Logger logger = LoggerFactory.getLogger(AbstractKubernetesIT.class);

/** Kubernetes' connection state, checks connectivity only once per test run */
private static boolean connected = false;
Expand All @@ -54,7 +54,7 @@ public void checkKubernetesEnvironment() {

connected = future.get(5000, TimeUnit.MILLISECONDS);
} catch (Exception e) {
log.warn("Skipping Kubernetes test execution as no proper Kubernetes environment is available on host system!", e);
logger.warn("Skipping Kubernetes test execution as no proper Kubernetes environment is available on host system!", e);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
public abstract class AbstractSeleniumAction extends AbstractTestAction implements SeleniumAction {

/** Logger */
protected Logger log = LoggerFactory.getLogger(getClass());
private final Logger logger = LoggerFactory.getLogger(getClass());

/** Selenium browser instance */
private final SeleniumBrowser browser;
Expand All @@ -45,8 +45,8 @@ public AbstractSeleniumAction(String name, Builder<?, ?> builder) {

@Override
public void doExecute(TestContext context) {
if (log.isDebugEnabled()) {
log.debug(String.format("Executing Selenium browser command '%s'", getName()));
if (logger.isDebugEnabled()) {
logger.debug(String.format("Executing Selenium browser command '%s'", getName()));
}

SeleniumBrowser browserToUse = browser;
Expand All @@ -61,7 +61,7 @@ public void doExecute(TestContext context) {

execute(browserToUse, context);

log.info(String.format("Selenium browser command execution successful: '%s'", getName()));
logger.info(String.format("Selenium browser command execution successful: '%s'", getName()));
}

protected abstract void execute(SeleniumBrowser browser, TestContext context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.citrusframework.selenium.endpoint.SeleniumHeaders;
import org.citrusframework.validation.matcher.ValidationMatcherUtils;
import org.openqa.selenium.Alert;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;

Expand All @@ -34,6 +36,9 @@
*/
public class AlertAction extends AbstractSeleniumAction {

/** Logger */
private static final Logger logger = LoggerFactory.getLogger(AlertAction.class);

/** Accept or dismiss dialog */
private final boolean accept;

Expand All @@ -58,7 +63,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
}

if (StringUtils.hasText(text)) {
log.info("Validating alert text");
logger.info("Validating alert text");

String alertText = context.replaceDynamicContentInString(text);

Expand All @@ -70,7 +75,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) {
"expected '%s', but was '%s'", alertText, alert.getText()));

}
log.info("Alert text validation successful - All values Ok");
logger.info("Alert text validation successful - All values Ok");
}

context.setVariable(SeleniumHeaders.SELENIUM_ALERT_TEXT, alert.getText());
Expand Down
Loading

0 comments on commit 5f2907a

Please sign in to comment.