diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/actions/DockerExecuteAction.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/actions/DockerExecuteAction.java index 830babe42f..e61fdf4c86 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/actions/DockerExecuteAction.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/actions/DockerExecuteAction.java @@ -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. @@ -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) { @@ -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)) { @@ -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); } diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/client/DockerClient.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/client/DockerClient.java index 3fd0fd344b..211e6b6e10 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/client/DockerClient.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/client/DockerClient.java @@ -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 correlationManager; @@ -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); diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ContainerInspect.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ContainerInspect.java index 79492aa53f..a6e645618f 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ContainerInspect.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ContainerInspect.java @@ -31,7 +31,7 @@ public class ContainerInspect extends AbstractDockerCommand { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ContainerInspect.class); + private static final Logger logger = LoggerFactory.getLogger(ContainerInspect.class); /** * Default constructor initializing the command name. @@ -47,7 +47,7 @@ public void execute(DockerClient dockerClient, TestContext context) { setCommandResult(response); - log.debug(response.toString()); + logger.debug(response.toString()); } /** diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ImageInspect.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ImageInspect.java index b494fc4b2f..c90650bc48 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ImageInspect.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/ImageInspect.java @@ -31,7 +31,7 @@ public class ImageInspect extends AbstractDockerCommand { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ImageInspect.class); + private static final Logger logger = LoggerFactory.getLogger(ImageInspect.class); /** * Default constructor initializing the command name. @@ -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()); } /** diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Info.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Info.java index 48d380841a..b9793fe416 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Info.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Info.java @@ -29,7 +29,7 @@ public class Info extends AbstractDockerCommand { /** Logger */ - private static Logger log = LoggerFactory.getLogger(Info.class); + private static final Logger logger = LoggerFactory.getLogger(Info.class); /** * Default constructor initializing the command name. @@ -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()); } /** diff --git a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Version.java b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Version.java index 270d07767b..f9d64fde1f 100644 --- a/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Version.java +++ b/connectors/citrus-docker/src/main/java/org/citrusframework/docker/command/Version.java @@ -30,7 +30,7 @@ public class Version extends AbstractDockerCommand { /** Logger */ - private static Logger log = LoggerFactory.getLogger(Version.class); + private static final Logger logger = LoggerFactory.getLogger(Version.class); /** * Default constructor initializing the command name. @@ -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()); } /** diff --git a/connectors/citrus-docker/src/test/java/org/citrusframework/docker/integration/AbstractDockerIT.java b/connectors/citrus-docker/src/test/java/org/citrusframework/docker/integration/AbstractDockerIT.java index 6a1e34a8b9..274a8e41fd 100644 --- a/connectors/citrus-docker/src/test/java/org/citrusframework/docker/integration/AbstractDockerIT.java +++ b/connectors/citrus-docker/src/test/java/org/citrusframework/docker/integration/AbstractDockerIT.java @@ -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; @@ -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); } } } diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/KubernetesExecuteAction.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/KubernetesExecuteAction.java index 8beb7c2163..199ba07ba1 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/KubernetesExecuteAction.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/actions/KubernetesExecuteAction.java @@ -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. @@ -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) { @@ -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(); @@ -159,7 +159,7 @@ 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)) { @@ -167,7 +167,7 @@ private void validateCommandResult(KubernetesCommand command, TestContext contex .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); diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/client/KubernetesClient.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/client/KubernetesClient.java index eb26c19448..a6e2486bc6 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/client/KubernetesClient.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/client/KubernetesClient.java @@ -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 correlationManager; @@ -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); } diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractKubernetesCommand.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractKubernetesCommand.java index 418dfaeb5e..940c5b4a76 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractKubernetesCommand.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractKubernetesCommand.java @@ -33,7 +33,7 @@ public abstract class AbstractKubernetesCommand> implements KubernetesCommand { /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); /** Self reference for generics support */ private final T self; diff --git a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractWatchCommand.java b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractWatchCommand.java index 74c32dd7c2..37ec818fc2 100644 --- a/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractWatchCommand.java +++ b/connectors/citrus-kubernetes/src/main/java/org/citrusframework/kubernetes/command/AbstractWatchCommand.java @@ -61,7 +61,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()); } } @@ -89,7 +89,7 @@ public WatchEventResult 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); diff --git a/connectors/citrus-kubernetes/src/test/java/org/citrusframework/kubernetes/integration/AbstractKubernetesIT.java b/connectors/citrus-kubernetes/src/test/java/org/citrusframework/kubernetes/integration/AbstractKubernetesIT.java index 270a36ea71..ea194f182a 100644 --- a/connectors/citrus-kubernetes/src/test/java/org/citrusframework/kubernetes/integration/AbstractKubernetesIT.java +++ b/connectors/citrus-kubernetes/src/test/java/org/citrusframework/kubernetes/integration/AbstractKubernetesIT.java @@ -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; @@ -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); } } } diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AbstractSeleniumAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AbstractSeleniumAction.java index b2b1b85270..818492f24e 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AbstractSeleniumAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AbstractSeleniumAction.java @@ -32,7 +32,7 @@ public abstract class AbstractSeleniumAction extends AbstractTestAction implements SeleniumAction { /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); /** Selenium browser instance */ private final SeleniumBrowser browser; @@ -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; @@ -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); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AlertAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AlertAction.java index 7a8e90838c..33aedc85ae 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AlertAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/AlertAction.java @@ -58,7 +58,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); @@ -70,7 +70,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()); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/CloseWindowAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/CloseWindowAction.java index dfb7ac91a7..e1ef8da1b8 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/CloseWindowAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/CloseWindowAction.java @@ -54,13 +54,13 @@ protected void execute(SeleniumBrowser browser, TestContext context) { throw new CitrusRuntimeException("Failed to find window for handle " + context.getVariable(windowName)); } - log.info("Current window: " + browser.getWebDriver().getWindowHandle()); - log.info("Window to close: " + context.getVariable(windowName)); + logger.info("Current window: " + browser.getWebDriver().getWindowHandle()); + logger.info("Window to close: " + context.getVariable(windowName)); if (browser.getWebDriver().getWindowHandle().equals((context.getVariable(windowName)))) { browser.getWebDriver().close(); - log.info("Switch back to main window!"); + logger.info("Switch back to main window!"); if (context.getVariables().containsKey(SeleniumHeaders.SELENIUM_LAST_WINDOW)) { browser.getWebDriver().switchTo().window(context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW)); context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, context.getVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW)); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/JavaScriptAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/JavaScriptAction.java index 54a4f87eba..a87c588e9f 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/JavaScriptAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/JavaScriptAction.java @@ -79,7 +79,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { } } } else { - log.warn("Skip javascript action because web driver is missing javascript features"); + logger.warn("Skip javascript action because web driver is missing javascript features"); } } catch (WebDriverException e) { throw new CitrusRuntimeException("Failed to execute JavaScript code", e); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/MakeScreenshotAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/MakeScreenshotAction.java index 870159e40a..1be0f29847 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/MakeScreenshotAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/MakeScreenshotAction.java @@ -54,7 +54,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { if (browser.getWebDriver() instanceof TakesScreenshot) { screenshot = ((TakesScreenshot) browser.getWebDriver()).getScreenshotAs(OutputType.FILE); } else { - log.warn("Skip screenshot action because web driver is missing screenshot features"); + logger.warn("Skip screenshot action because web driver is missing screenshot features"); } if (screenshot != null) { @@ -76,7 +76,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { FileCopyUtils.copy(screenshot, new File(targetDir, testName + "_" + screenshot.getName())); } catch (IOException e) { - log.error("Failed to save screenshot to target storage", e); + logger.error("Failed to save screenshot to target storage", e); } } else { browser.storeFile(new FileSystemResource(screenshot)); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/OpenWindowAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/OpenWindowAction.java index 38ff1ea819..87f6dccdc1 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/OpenWindowAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/OpenWindowAction.java @@ -64,7 +64,7 @@ protected void execute(SeleniumBrowser browser, TestContext context) { if (!StringUtils.isEmpty(newWindow)) { browser.getWebDriver().switchTo().window(newWindow); - log.info("Open window: " + newWindow); + logger.info("Open window: " + newWindow); context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, newWindow); context.setVariable(windowName, newWindow); } else { diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StartBrowserAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StartBrowserAction.java index d3b286e45a..129cfee43a 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StartBrowserAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StartBrowserAction.java @@ -44,15 +44,15 @@ public StartBrowserAction(Builder builder) { @Override protected void execute(SeleniumBrowser browser, TestContext context) { if (!allowAlreadyStarted && browser.isStarted()) { - log.warn("There are some open web browsers. They will be stopped."); + logger.warn("There are some open web browsers. They will be stopped."); browser.stop(); } else if (browser.isStarted()) { - log.info("Browser already started - skip start action"); + logger.info("Browser already started - skip start action"); context.setVariable(SeleniumHeaders.SELENIUM_BROWSER, browser.getName()); return; } - log.info("Opening browser of type {}", browser.getEndpointConfiguration().getBrowserType()); + logger.info("Opening browser of type {}", browser.getEndpointConfiguration().getBrowserType()); browser.start(); if (StringUtils.hasText(getBrowser().getEndpointConfiguration().getStartPageUrl())) { diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StopBrowserAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StopBrowserAction.java index 6c32179a31..c22381f439 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StopBrowserAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/StopBrowserAction.java @@ -35,7 +35,7 @@ public StopBrowserAction(Builder builder) { @Override protected void execute(SeleniumBrowser browser, TestContext context) { - log.info("Stopping browser of type {}", browser.getEndpointConfiguration().getBrowserType()); + logger.info("Stopping browser of type {}", browser.getEndpointConfiguration().getBrowserType()); browser.stop(); context.getVariables().remove(SeleniumHeaders.SELENIUM_BROWSER); diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/SwitchWindowAction.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/SwitchWindowAction.java index 8d624158d8..dcdc3a3d96 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/SwitchWindowAction.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/actions/SwitchWindowAction.java @@ -58,11 +58,11 @@ protected void execute(SeleniumBrowser browser, TestContext context) { context.setVariable(SeleniumHeaders.SELENIUM_LAST_WINDOW, lastWindow); browser.getWebDriver().switchTo().window(targetWindow); - log.info("Switch window focus to " + windowName); + logger.info("Switch window focus to " + windowName); context.setVariable(SeleniumHeaders.SELENIUM_ACTIVE_WINDOW, targetWindow); } else { - log.info("Skip switch window action as window is already focused"); + logger.info("Skip switch window action as window is already focused"); } } diff --git a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/endpoint/SeleniumBrowser.java b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/endpoint/SeleniumBrowser.java index 463f9ac8e5..1c31b2f860 100644 --- a/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/endpoint/SeleniumBrowser.java +++ b/connectors/citrus-selenium/src/main/java/org/citrusframework/selenium/endpoint/SeleniumBrowser.java @@ -68,7 +68,7 @@ public class SeleniumBrowser extends AbstractEndpoint implements Producer { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SeleniumBrowser.class); + private static final Logger logger = LoggerFactory.getLogger(SeleniumBrowser.class); /** Selenium web driver */ private WebDriver webDriver; @@ -98,7 +98,7 @@ public void send(Message message, TestContext context) { SeleniumAction action = message.getPayload(SeleniumAction.class); action.execute(context); - LOG.info("Selenium action successfully executed"); + logger.info("Selenium action successfully executed"); } /** @@ -115,11 +115,11 @@ public void start() { } if (!CollectionUtils.isEmpty(getEndpointConfiguration().getEventListeners())) { - LOG.info("Add event listeners to web driver: " + getEndpointConfiguration().getEventListeners().size()); + logger.info("Add event listeners to web driver: " + getEndpointConfiguration().getEventListeners().size()); webDriver = new EventFiringDecorator(getEndpointConfiguration().getEventListeners().toArray(new WebDriverListener[0])).decorate(webDriver); } } else { - LOG.debug("Browser already started"); + logger.debug("Browser already started"); } } @@ -128,21 +128,21 @@ public void start() { */ public void stop() { if (isStarted()) { - LOG.info("Stopping browser " + webDriver.getCurrentUrl()); + logger.info("Stopping browser " + webDriver.getCurrentUrl()); try { - LOG.info("Trying to close the browser " + webDriver + " ..."); + logger.info("Trying to close the browser " + webDriver + " ..."); webDriver.quit(); } catch (UnreachableBrowserException e) { // It happens for Firefox. It's ok: browser is already closed. - LOG.warn("Browser is unreachable", e); + logger.warn("Browser is unreachable", e); } catch (WebDriverException e) { - LOG.error("Failed to close browser", e); + logger.error("Failed to close browser", e); } webDriver = null; } else { - LOG.warn("Browser already stopped"); + logger.warn("Browser already stopped"); } } @@ -168,7 +168,7 @@ public String storeFile(Resource file) { try { File newFile = new File(temporaryStorage.toFile(), file.getFilename()); - LOG.info("Store file " + file + " to " + newFile); + logger.info("Store file " + file + " to " + newFile); FileUtils.copyFile(file.getFile(), newFile); @@ -291,7 +291,7 @@ private Path createTemporaryStorage() { Path tempDir = Files.createTempDirectory("selenium"); tempDir.toFile().deleteOnExit(); - LOG.info("Download storage location is: " + tempDir); + logger.info("Download storage location is: " + tempDir); return tempDir; } catch (IOException e) { throw new CitrusRuntimeException("Could not create temporary storage", e); diff --git a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/AbstractDatabaseConnectingTestAction.java b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/AbstractDatabaseConnectingTestAction.java index ee64b63daa..9879b1f156 100644 --- a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/AbstractDatabaseConnectingTestAction.java +++ b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/AbstractDatabaseConnectingTestAction.java @@ -29,8 +29,6 @@ import org.citrusframework.common.Named; import org.citrusframework.context.TestContext; import org.citrusframework.util.SqlUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.jdbc.core.JdbcTemplate; @@ -45,8 +43,6 @@ * @author Christoph Deppisch */ public abstract class AbstractDatabaseConnectingTestAction extends JdbcDaoSupport implements TestAction, Named, Described, TestActorAware { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(this.getClass()); /** Text describing the test action */ private String description; diff --git a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecutePLSQLAction.java b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecutePLSQLAction.java index 7f1fb07b22..e0e651c164 100644 --- a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecutePLSQLAction.java +++ b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecutePLSQLAction.java @@ -81,8 +81,8 @@ public String decorate(String line) { } if (getTransactionManager() != null) { - if (log.isDebugEnabled()) { - log.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); + if (logger.isDebugEnabled()) { + logger.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); } TransactionTemplate transactionTemplate = new TransactionTemplate(getTransactionManager()); @@ -107,16 +107,16 @@ protected void executeStatements(List statements, TestContext context) { try { final String toExecute = context.replaceDynamicContentInString(stmt.trim()); - if (log.isDebugEnabled()) { - log.debug("Executing PLSQL statement: " + toExecute); + if (logger.isDebugEnabled()) { + logger.debug("Executing PLSQL statement: " + toExecute); } getJdbcTemplate().execute(toExecute); - log.info("PLSQL statement execution successful"); + logger.info("PLSQL statement execution successful"); } catch (DataAccessException e) { if (ignoreErrors) { - log.warn("Ignoring error while executing PLSQL statement: " + e.getMessage()); + logger.warn("Ignoring error while executing PLSQL statement: " + e.getMessage()); } else { throw new CitrusRuntimeException("Failed to execute PLSQL statement", e); } @@ -133,8 +133,8 @@ private List createStatementsFromScript(TestContext context) { List stmts = new ArrayList<>(); String resolvedScript = context.replaceDynamicContentInString(script); - if (log.isDebugEnabled()) { - log.debug("Found inline PLSQL script " + resolvedScript); + if (logger.isDebugEnabled()) { + logger.debug("Found inline PLSQL script " + resolvedScript); } StringTokenizer tok = new StringTokenizer(resolvedScript, PLSQL_STMT_ENDING); diff --git a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLAction.java b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLAction.java index ee2041dece..dfb56162fd 100644 --- a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLAction.java +++ b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLAction.java @@ -58,8 +58,8 @@ public void doExecute(TestContext context) { } if (getTransactionManager() != null) { - if (log.isDebugEnabled()) { - log.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); + if (logger.isDebugEnabled()) { + logger.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); } TransactionTemplate transactionTemplate = new TransactionTemplate(getTransactionManager()); @@ -90,16 +90,16 @@ protected void executeStatements(List statements, TestContext context) { toExecute = context.replaceDynamicContentInString(stmt.trim()); } - if (log.isDebugEnabled()) { - log.debug("Executing SQL statement: " + toExecute); + if (logger.isDebugEnabled()) { + logger.debug("Executing SQL statement: " + toExecute); } getJdbcTemplate().execute(toExecute); - log.info("SQL statement execution successful"); + logger.info("SQL statement execution successful"); } catch (Exception e) { if (ignoreErrors) { - log.error("Ignoring error while executing SQL statement: " + e.getLocalizedMessage()); + logger.error("Ignoring error while executing SQL statement: " + e.getLocalizedMessage()); } else { throw new CitrusRuntimeException(e); } diff --git a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLQueryAction.java b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLQueryAction.java index 8e8182e6fb..98235eb2fc 100644 --- a/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLQueryAction.java +++ b/connectors/citrus-sql/src/main/java/org/citrusframework/actions/ExecuteSQLQueryAction.java @@ -73,7 +73,7 @@ public class ExecuteSQLQueryAction extends AbstractDatabaseConnectingTestAction public static final String DEFAULT_RESULT_SET_VALIDATOR = "sqlResultSetScriptValidator"; /** Logger */ - private static final Logger log = LoggerFactory.getLogger(ExecuteSQLQueryAction.class); + private static final Logger logger = LoggerFactory.getLogger(ExecuteSQLQueryAction.class); /** * Default constructor. @@ -103,8 +103,8 @@ public void doExecute(TestContext context) { final List> allResultRows = new ArrayList>(); if (getTransactionManager() != null) { - if (log.isDebugEnabled()) { - log.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); + if (logger.isDebugEnabled()) { + logger.debug("Using transaction manager: " + getTransactionManager().getClass().getName()); } TransactionTemplate transactionTemplate = new TransactionTemplate(getTransactionManager()); @@ -130,7 +130,7 @@ public void doExecute(TestContext context) { context.setVariable(column.getKey().toUpperCase(), columnValues.get(0) == null ? NULL_VALUE : columnValues.get(0)); } } catch (DataAccessException e) { - log.error("Failed to execute SQL statement", e); + logger.error("Failed to execute SQL statement", e); throw new CitrusRuntimeException(e); } } @@ -153,13 +153,13 @@ protected void executeStatements(List statements, List> results = getJdbcTemplate().queryForList(toExecute); - log.info("SQL query execution successful"); + logger.info("SQL query execution successful"); allResultRows.addAll(results); fillColumnValuesMap(results, columnValuesMap); @@ -230,14 +230,14 @@ private SqlResultSetScriptValidator getScriptValidator(TestContext context) { if (validators.isEmpty()) { Map defaultValidators = SqlResultSetScriptValidator.lookup(); if (defaultValidators.size() > 1) { - log.warn("Too many default SQL result set script validators in classpath, please explicitly add one to the test action for verification"); + logger.warn("Too many default SQL result set script validators in classpath, please explicitly add one to the test action for verification"); } else if (defaultValidators.size() == 1) { return defaultValidators.getOrDefault(DEFAULT_RESULT_SET_VALIDATOR, defaultValidators.values().iterator().next()); } } else if (validators.size() == 1) { return validators.values().iterator().next(); } else { - log.warn("Too many SQL result set script validators defined in project, please explicitly add one to the test action for verification"); + logger.warn("Too many SQL result set script validators defined in project, please explicitly add one to the test action for verification"); } } } @@ -295,7 +295,7 @@ private void performValidation(final Map> columnValuesMap, return; } performControlResultSetValidation(columnValuesMap, context); - log.info("SQL query validation successful: All values OK"); + logger.info("SQL query validation successful: All values OK"); } private void performControlResultSetValidation(final Map> columnValuesMap, TestContext context) @@ -344,8 +344,8 @@ protected void validateSqlStatement(String stmt) { protected void validateSingleValue(String columnName, String controlValue, String resultValue, TestContext context) { // check if value is ignored if (controlValue.equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - if (log.isDebugEnabled()) { - log.debug("Ignoring column value '" + columnName + "(resultValue)'"); + if (logger.isDebugEnabled()) { + logger.debug("Ignoring column value '" + columnName + "(resultValue)'"); } return; } @@ -357,8 +357,8 @@ protected void validateSingleValue(String columnName, String controlValue, Strin if (resultValue == null) { if (isCitrusNullValue(controlValue)) { - if (log.isDebugEnabled()) { - log.debug("Validating database value for column: ''" + + if (logger.isDebugEnabled()) { + logger.debug("Validating database value for column: ''" + columnName + "'' value as expected: NULL - value OK"); } return; @@ -369,8 +369,8 @@ protected void validateSingleValue(String columnName, String controlValue, Strin } if (resultValue.equals(controlValue)) { - if (log.isDebugEnabled()) { - log.debug("Validation successful for column: '" + columnName + + if (logger.isDebugEnabled()) { + logger.debug("Validation successful for column: '" + columnName + "' expected value: " + controlValue + " - value OK"); } } else { diff --git a/connectors/citrus-sql/src/main/java/org/citrusframework/util/SqlUtils.java b/connectors/citrus-sql/src/main/java/org/citrusframework/util/SqlUtils.java index 818cb26910..010d1297c2 100644 --- a/connectors/citrus-sql/src/main/java/org/citrusframework/util/SqlUtils.java +++ b/connectors/citrus-sql/src/main/java/org/citrusframework/util/SqlUtils.java @@ -34,7 +34,7 @@ public abstract class SqlUtils { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SqlUtils.class); + private static final Logger logger = LoggerFactory.getLogger(SqlUtils.class); /** Constant representing SQL comment */ public static final String SQL_COMMENT = "--"; @@ -75,8 +75,8 @@ public static List createStatementsFromFileResource(Resource sqlResource List stmts = new ArrayList<>(); try { - if (log.isDebugEnabled()) { - log.debug("Create statements from SQL file: " + sqlResource.getFile().getAbsolutePath()); + if (logger.isDebugEnabled()) { + logger.debug("Create statements from SQL file: " + sqlResource.getFile().getAbsolutePath()); } reader = new BufferedReader(new InputStreamReader(sqlResource.getInputStream())); @@ -96,8 +96,8 @@ public static List createStatementsFromFileResource(Resource sqlResource String stmt = buffer.toString().trim(); - if (log.isDebugEnabled()) { - log.debug("Found statement: " + stmt); + if (logger.isDebugEnabled()) { + logger.debug("Found statement: " + stmt); } stmts.add(stmt); @@ -118,7 +118,7 @@ public static List createStatementsFromFileResource(Resource sqlResource try { reader.close(); } catch (IOException e) { - log.warn("Warning: Error while closing reader instance", e); + logger.warn("Warning: Error while closing reader instance", e); } } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/CitrusSettings.java b/core/citrus-api/src/main/java/org/citrusframework/CitrusSettings.java index 27b164f31c..4f67ec3cd9 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/CitrusSettings.java +++ b/core/citrus-api/src/main/java/org/citrusframework/CitrusSettings.java @@ -24,7 +24,7 @@ public final class CitrusSettings { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusSettings.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusSettings.class); private CitrusSettings() { // prevent instantiation @@ -53,19 +53,19 @@ private CitrusSettings() { Properties applicationProperties = new Properties(); applicationProperties.load(in); - LOG.debug("Loading Citrus application properties"); + logger.debug("Loading Citrus application properties"); for (Map.Entry property : applicationProperties.entrySet()) { if (StringUtils.isEmpty(System.getProperty(property.getKey().toString()))) { - LOG.debug(String.format("Setting application property %s=%s", property.getKey(), property.getValue())); + logger.debug(String.format("Setting application property %s=%s", property.getKey(), property.getValue())); System.setProperty(property.getKey().toString(), property.getValue().toString()); } } } catch (Exception e) { - if (LOG.isTraceEnabled()) { - LOG.trace("Unable to locate Citrus application properties", e); + if (logger.isTraceEnabled()) { + logger.trace("Unable to locate Citrus application properties", e); } else { - LOG.info("Unable to locate Citrus application properties"); + logger.info("Unable to locate Citrus application properties"); } } } @@ -152,18 +152,18 @@ private CitrusSettings() { public static final String PRETTY_PRINT_ENV = "CITRUS_MESSAGE_PRETTY_PRINT"; public static final String PRETTY_PRINT_DEFAULT = Boolean.TRUE.toString(); - /** Flag to enable/disable log modifier */ - public static final String LOG_MODIFIER_PROPERTY = "citrus.log.modifier"; + /** Flag to enable/disable logger modifier */ + public static final String LOG_MODIFIER_PROPERTY = "citrus.logger.modifier"; public static final String LOG_MODIFIER_ENV = "CITRUS_LOG_MODIFIER"; public static final String LOG_MODIFIER_DEFAULT = Boolean.TRUE.toString(); - /** Default log modifier mask value */ - public static final String LOG_MASK_VALUE_PROPERTY = "citrus.log.mask.value"; + /** Default logger modifier mask value */ + public static final String LOG_MASK_VALUE_PROPERTY = "citrus.logger.mask.value"; public static final String LOG_MASK_VALUE_ENV = "CITRUS_LOG_MASK_VALUE"; public static final String LOG_MASK_VALUE_DEFAULT = "****"; - /** Default log modifier keywords */ - public static final String LOG_MASK_KEYWORDS_PROPERTY = "citrus.log.mask.keywords"; + /** Default logger modifier keywords */ + public static final String LOG_MASK_KEYWORDS_PROPERTY = "citrus.logger.mask.keywords"; public static final String LOG_MASK_KEYWORDS_ENV = "CITRUS_LOG_MASK_KEYWORDS"; public static final String LOG_MASK_KEYWORDS_DEFAULT = "password,secret,secretKey"; @@ -227,7 +227,7 @@ public static boolean isPrettyPrintEnabled() { } /** - * Gets the log modifier enabled/disabled setting. + * Gets the logger modifier enabled/disabled setting. * @return */ public static boolean isLogModifierEnabled() { @@ -236,7 +236,7 @@ public static boolean isLogModifierEnabled() { } /** - * Get log mask value. + * Get logger mask value. * @return */ public static String getLogMaskValue() { @@ -245,7 +245,7 @@ public static String getLogMaskValue() { } /** - * Get log mask keywords. + * Get logger mask keywords. * @return */ public static Set getLogMaskKeywords() { diff --git a/core/citrus-api/src/main/java/org/citrusframework/CitrusVersion.java b/core/citrus-api/src/main/java/org/citrusframework/CitrusVersion.java index 0f11044dac..acfb97428f 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/CitrusVersion.java +++ b/core/citrus-api/src/main/java/org/citrusframework/CitrusVersion.java @@ -14,7 +14,7 @@ public final class CitrusVersion { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CitrusVersion.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusVersion.class); /** Citrus version */ private static String version; @@ -27,11 +27,11 @@ public final class CitrusVersion { version = versionProperties.get("citrus.version").toString(); if (version.equals("${project.version}")) { - log.warn("Citrus version has not been filtered with Maven project properties yet"); + logger.warn("Citrus version has not been filtered with Maven project properties yet"); version = ""; } } catch (IOException e) { - log.warn("Unable to read Citrus version information", e); + logger.warn("Unable to read Citrus version information", e); version = ""; } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/TestActionBuilder.java b/core/citrus-api/src/main/java/org/citrusframework/TestActionBuilder.java index f011cbaa4d..9139c43471 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/TestActionBuilder.java +++ b/core/citrus-api/src/main/java/org/citrusframework/TestActionBuilder.java @@ -33,7 +33,7 @@ public interface TestActionBuilder { /** Logger */ - Logger LOG = LoggerFactory.getLogger(TestActionBuilder.class); + Logger logger = LoggerFactory.getLogger(TestActionBuilder.class); /** Endpoint builder resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/action/builder"; @@ -64,8 +64,8 @@ interface DelegatingTestActionBuilder extends TestActionBu static Map> lookup() { Map> builders = TYPE_RESOLVER.resolveAll(); - if (LOG.isDebugEnabled()) { - builders.forEach((k, v) -> LOG.debug(String.format("Found test action builder '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + builders.forEach((k, v) -> logger.debug(String.format("Found test action builder '%s' as %s", k, v.getClass()))); } return builders; } @@ -83,7 +83,7 @@ static Optional> lookup(String builder) { try { return Optional.of(TYPE_RESOLVER.resolve(builder)); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, builder)); + logger.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, builder)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/annotations/CitrusEndpointAnnotations.java b/core/citrus-api/src/main/java/org/citrusframework/annotations/CitrusEndpointAnnotations.java index df5668456a..ab2ef07e36 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/annotations/CitrusEndpointAnnotations.java +++ b/core/citrus-api/src/main/java/org/citrusframework/annotations/CitrusEndpointAnnotations.java @@ -21,7 +21,7 @@ public abstract class CitrusEndpointAnnotations { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusEndpointAnnotations.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusEndpointAnnotations.class); /** * Prevent instantiation. @@ -39,7 +39,7 @@ private CitrusEndpointAnnotations() { */ public static void injectEndpoints(final Object target, final TestContext context) { ReflectionUtils.doWithFields(target.getClass(), field -> { - LOG.debug(String.format("Injecting Citrus endpoint on test class field '%s'", field.getName())); + logger.debug(String.format("Injecting Citrus endpoint on test class field '%s'", field.getName())); CitrusEndpoint endpointAnnotation = field.getAnnotation(CitrusEndpoint.class); for (Annotation annotation : field.getAnnotations()) { diff --git a/core/citrus-api/src/main/java/org/citrusframework/common/TestLoader.java b/core/citrus-api/src/main/java/org/citrusframework/common/TestLoader.java index 7d65a243a8..5257ebf741 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/common/TestLoader.java +++ b/core/citrus-api/src/main/java/org/citrusframework/common/TestLoader.java @@ -34,7 +34,7 @@ public interface TestLoader { /** Logger */ - Logger LOG = LoggerFactory.getLogger(TestLoader.class); + Logger logger = LoggerFactory.getLogger(TestLoader.class); /** Test loader resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/test/loader"; @@ -85,8 +85,8 @@ public interface TestLoader { static Map lookup() { Map loader = TYPE_RESOLVER.resolveAll(); - if (LOG.isDebugEnabled()) { - loader.forEach((k, v) -> LOG.debug(String.format("Found test loader '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + loader.forEach((k, v) -> logger.debug(String.format("Found test loader '%s' as %s", k, v.getClass()))); } return loader; } @@ -102,7 +102,7 @@ static Optional lookup(String loader) { try { return Optional.of(TYPE_RESOLVER.resolve(loader)); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve test loader from resource '%s/%s'", RESOURCE_PATH, loader)); + logger.warn(String.format("Failed to resolve test loader from resource '%s/%s'", RESOURCE_PATH, loader)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/config/annotation/AnnotationConfigParser.java b/core/citrus-api/src/main/java/org/citrusframework/config/annotation/AnnotationConfigParser.java index 6026310c21..b3ac4da951 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/config/annotation/AnnotationConfigParser.java +++ b/core/citrus-api/src/main/java/org/citrusframework/config/annotation/AnnotationConfigParser.java @@ -36,7 +36,7 @@ public interface AnnotationConfigParser { /** Logger */ - Logger LOG = LoggerFactory.getLogger(AnnotationConfigParser.class); + Logger logger = LoggerFactory.getLogger(AnnotationConfigParser.class); /** Endpoint parser resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/endpoint/parser"; @@ -63,8 +63,8 @@ static Map lookup() { if (parsers.isEmpty()) { parsers.putAll(TYPE_RESOLVER.resolveAll("", TypeResolver.TYPE_PROPERTY_WILDCARD)); - if (LOG.isDebugEnabled()) { - parsers.forEach((k, v) -> LOG.debug(String.format("Found annotation config parser '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + parsers.forEach((k, v) -> logger.debug(String.format("Found annotation config parser '%s' as %s", k, v.getClass()))); } } return parsers; @@ -91,7 +91,7 @@ static Optional lookup(String parser) { return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve annotation config parser from resource '%s/%s'", RESOURCE_PATH, parser)); + logger.warn(String.format("Failed to resolve annotation config parser from resource '%s/%s'", RESOURCE_PATH, parser)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/context/TestContext.java b/core/citrus-api/src/main/java/org/citrusframework/context/TestContext.java index 9c7960f14b..ebde4ff674 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/context/TestContext.java +++ b/core/citrus-api/src/main/java/org/citrusframework/context/TestContext.java @@ -43,7 +43,7 @@ import org.citrusframework.exceptions.VariableNullValueException; import org.citrusframework.functions.FunctionRegistry; import org.citrusframework.functions.FunctionUtils; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.message.DefaultMessageStore; import org.citrusframework.message.Message; import org.citrusframework.message.MessageDirection; @@ -79,7 +79,7 @@ public class TestContext implements ReferenceResolverAware, TestActionListenerAw /** * Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TestContext.class); + private static final Logger logger = LoggerFactory.getLogger(TestContext.class); /** * Local variables @@ -252,8 +252,8 @@ public void setVariable(final String variableName, Object value) { throw new VariableNullValueException("Trying to set variable: " + VariableUtils.cutOffVariablesPrefix(variableName) + ", but variable value is null"); } - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Setting variable: %s with value: '%s'", VariableUtils.cutOffVariablesPrefix(variableName), value)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Setting variable: %s with value: '%s'", VariableUtils.cutOffVariablesPrefix(variableName), value)); } variables.put(VariableUtils.cutOffVariablesPrefix(variableName), value); @@ -820,8 +820,8 @@ private void logMessage(String operation, Message message, MessageDirection dire } else if (MessageDirection.INBOUND.equals(direction)) { messageListeners.onInboundMessage(message, this); } - } else if (LOG.isDebugEnabled()) { - LOG.debug(String.format("%s message:%n%s", operation, Optional.ofNullable(message).map(Message::toString).orElse(""))); + } else if (logger.isDebugEnabled()) { + logger.debug(String.format("%s message:%n%s", operation, Optional.ofNullable(message).map(Message::toString).orElse(""))); } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/context/resolver/TypeAliasResolver.java b/core/citrus-api/src/main/java/org/citrusframework/context/resolver/TypeAliasResolver.java index aecc821e7a..de62ac7066 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/context/resolver/TypeAliasResolver.java +++ b/core/citrus-api/src/main/java/org/citrusframework/context/resolver/TypeAliasResolver.java @@ -38,7 +38,7 @@ public interface TypeAliasResolver { /** Logger */ - Logger LOG = LoggerFactory.getLogger(TypeAliasResolver.class); + Logger logger = LoggerFactory.getLogger(TypeAliasResolver.class); /** Type alias resolver resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/context/resolver"; @@ -57,8 +57,8 @@ public interface TypeAliasResolver { if (resolvers.isEmpty()) { resolvers.putAll(TYPE_RESOLVER.resolveAll("", TypeResolver.DEFAULT_TYPE_PROPERTY, "name")); - if (LOG.isDebugEnabled()) { - resolvers.forEach((k, v) -> LOG.debug(String.format("Found type alias resolver '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + resolvers.forEach((k, v) -> logger.debug(String.format("Found type alias resolver '%s' as %s", k, v.getClass()))); } } return resolvers; @@ -75,7 +75,7 @@ public interface TypeAliasResolver { try { return Optional.of(TYPE_RESOLVER.resolve(resolver)); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve type alias resolver from resource '%s/%s'", RESOURCE_PATH, resolver)); + logger.warn(String.format("Failed to resolve type alias resolver from resource '%s/%s'", RESOURCE_PATH, resolver)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/endpoint/DefaultEndpointFactory.java b/core/citrus-api/src/main/java/org/citrusframework/endpoint/DefaultEndpointFactory.java index 98ec6054d5..4b164945d4 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/endpoint/DefaultEndpointFactory.java +++ b/core/citrus-api/src/main/java/org/citrusframework/endpoint/DefaultEndpointFactory.java @@ -45,7 +45,7 @@ public class DefaultEndpointFactory implements EndpointFactory { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DefaultEndpointFactory.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultEndpointFactory.class); /** Endpoint cache for endpoint reuse */ private final Map endpointCache = new ConcurrentHashMap<>(); @@ -133,8 +133,8 @@ public Endpoint create(String uri, TestContext context) { synchronized (endpointCache) { if (endpointCache.containsKey(cachedEndpointName)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Found cached endpoint for uri '%s'", cachedEndpointName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Found cached endpoint for uri '%s'", cachedEndpointName)); } return endpointCache.get(cachedEndpointName); } else { diff --git a/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointBuilder.java b/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointBuilder.java index d321e0d3b6..774f75b382 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointBuilder.java +++ b/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointBuilder.java @@ -43,7 +43,7 @@ public interface EndpointBuilder { /** Logger */ - Logger LOG = LoggerFactory.getLogger(EndpointBuilder.class); + Logger logger = LoggerFactory.getLogger(EndpointBuilder.class); /** Endpoint builder resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/endpoint/builder"; @@ -116,8 +116,8 @@ default T build(Properties endpointProperties, ReferenceResolver referenceResolv static Map> lookup() { Map> builders = new HashMap<>(TYPE_RESOLVER.resolveAll("", TypeResolver.TYPE_PROPERTY_WILDCARD)); - if (LOG.isDebugEnabled()) { - builders.forEach((k, v) -> LOG.debug(String.format("Found endpoint builder '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + builders.forEach((k, v) -> logger.debug(String.format("Found endpoint builder '%s' as %s", k, v.getClass()))); } return builders; } @@ -143,7 +143,7 @@ static Optional> lookup(String builder) { return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve endpoint builder from resource '%s/%s'", RESOURCE_PATH, builder)); + logger.warn(String.format("Failed to resolve endpoint builder from resource '%s/%s'", RESOURCE_PATH, builder)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointComponent.java b/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointComponent.java index c250ade95b..d9b9e5dcf8 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointComponent.java +++ b/core/citrus-api/src/main/java/org/citrusframework/endpoint/EndpointComponent.java @@ -36,7 +36,7 @@ public interface EndpointComponent { /** Logger */ - Logger LOG = LoggerFactory.getLogger(EndpointComponent.class); + Logger logger = LoggerFactory.getLogger(EndpointComponent.class); String ENDPOINT_NAME = "endpointName"; @@ -75,8 +75,8 @@ public interface EndpointComponent { static Map lookup() { Map components = TYPE_RESOLVER.resolveAll(); - if (LOG.isDebugEnabled()) { - components.forEach((k, v) -> LOG.debug(String.format("Found endpoint component '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + components.forEach((k, v) -> logger.debug(String.format("Found endpoint component '%s' as %s", k, v.getClass()))); } return components; } @@ -93,7 +93,7 @@ static Optional lookup(String component) { EndpointComponent instance = TYPE_RESOLVER.resolve(component); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve endpoint component from resource '%s/%s'", RESOURCE_PATH, component)); + logger.warn(String.format("Failed to resolve endpoint component from resource '%s/%s'", RESOURCE_PATH, component)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/functions/Function.java b/core/citrus-api/src/main/java/org/citrusframework/functions/Function.java index cb7aaa95b3..fa914dca01 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/functions/Function.java +++ b/core/citrus-api/src/main/java/org/citrusframework/functions/Function.java @@ -33,7 +33,7 @@ public interface Function { /** Logger */ - Logger LOG = LoggerFactory.getLogger(Function.class); + Logger logger = LoggerFactory.getLogger(Function.class); /** Function resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/function"; @@ -49,8 +49,8 @@ static Map lookup() { if (functions.isEmpty()) { functions.putAll(new ResourcePathTypeResolver().resolveAll(RESOURCE_PATH)); - if (LOG.isDebugEnabled()) { - functions.forEach((k, v) -> LOG.debug(String.format("Found function '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + functions.forEach((k, v) -> logger.debug(String.format("Found function '%s' as %s", k, v.getClass()))); } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/log/LogMessageModifier.java b/core/citrus-api/src/main/java/org/citrusframework/log/LogMessageModifier.java index 02d7bdc504..e4aadfabd3 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/log/LogMessageModifier.java +++ b/core/citrus-api/src/main/java/org/citrusframework/log/LogMessageModifier.java @@ -17,7 +17,7 @@ * limitations under the License. */ -package org.citrusframework.log; +package org.citrusframework.logger; import java.util.Collections; import java.util.LinkedHashMap; @@ -30,7 +30,7 @@ import org.springframework.util.CollectionUtils; /** - * Special modifier adds message related modifications on log output on headers and body. + * Special modifier adds message related modifications on logger output on headers and body. * * @author Christoph Deppisch */ diff --git a/core/citrus-api/src/main/java/org/citrusframework/log/LogModifier.java b/core/citrus-api/src/main/java/org/citrusframework/log/LogModifier.java index 22956d6c40..2739182ed8 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/log/LogModifier.java +++ b/core/citrus-api/src/main/java/org/citrusframework/log/LogModifier.java @@ -17,11 +17,11 @@ * limitations under the License. */ -package org.citrusframework.log; +package org.citrusframework.logger; /** * Modifier masks output that gets printed to an output stream. Usually used - * to mask sensitive data like passwords and secrets when printed to the log output. + * to mask sensitive data like passwords and secrets when printed to the logger output. * * @author Christoph Deppisch */ @@ -29,8 +29,8 @@ public interface LogModifier { /** - * Mask given log statement and apply custom modifications before - * the log is printed to the output stream. + * Mask given logger statement and apply custom modifications before + * the logger is printed to the output stream. * @param statement * @return */ diff --git a/core/citrus-api/src/main/java/org/citrusframework/main/TestEngine.java b/core/citrus-api/src/main/java/org/citrusframework/main/TestEngine.java index e1ba8a18bb..ab2369e371 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/main/TestEngine.java +++ b/core/citrus-api/src/main/java/org/citrusframework/main/TestEngine.java @@ -28,7 +28,7 @@ public interface TestEngine { /** Logger */ - Logger LOG = LoggerFactory.getLogger(TestEngine.class); + Logger logger = LoggerFactory.getLogger(TestEngine.class); /** Endpoint parser resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/engine"; @@ -50,7 +50,7 @@ public interface TestEngine { static TestEngine lookup(TestRunConfiguration configuration) { try { TestEngine testEngine = TYPE_RESOLVER.resolve(configuration.getEngine(), configuration); - LOG.debug(String.format("Using Citrus engine '%s' as %s", configuration.getEngine(), testEngine)); + logger.debug(String.format("Using Citrus engine '%s' as %s", configuration.getEngine(), testEngine)); return testEngine; } catch (CitrusRuntimeException e) { throw new CitrusRuntimeException(String.format("Failed to resolve Citrus engine from resource '%s/%s'", RESOURCE_PATH, configuration.getEngine()), e); diff --git a/core/citrus-api/src/main/java/org/citrusframework/message/AbstractMessageProcessor.java b/core/citrus-api/src/main/java/org/citrusframework/message/AbstractMessageProcessor.java index 447ab78263..df3d4bad84 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/message/AbstractMessageProcessor.java +++ b/core/citrus-api/src/main/java/org/citrusframework/message/AbstractMessageProcessor.java @@ -29,7 +29,7 @@ public abstract class AbstractMessageProcessor implements MessageProcessor, MessageDirectionAware, MessageTypeSelector { /** Logger */ - private Logger log = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** Inbound/Outbound direction */ private MessageDirection direction = MessageDirection.UNBOUND; @@ -39,7 +39,7 @@ public void process(Message message, TestContext context) { if (supportsMessageType(message.getType())) { processMessage(message, context); } else { - log.debug(String.format("Message processor '%s' skipped for message type: %s", getName(), message.getType())); + logger.debug(String.format("Message processor '%s' skipped for message type: %s", getName(), message.getType())); } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/message/Message.java b/core/citrus-api/src/main/java/org/citrusframework/message/Message.java index a1a78def73..674f7943f0 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/message/Message.java +++ b/core/citrus-api/src/main/java/org/citrusframework/message/Message.java @@ -22,7 +22,7 @@ import java.util.Map; import org.citrusframework.context.TestContext; -import org.citrusframework.log.LogMessageModifier; +import org.citrusframework.logger.LogMessageModifier; import org.springframework.util.CollectionUtils; /** @@ -55,7 +55,7 @@ default String print(String body, Map headers, List head } /** - * Prints message content and applies log modifier provided in given test context. + * Prints message content and applies logger modifier provided in given test context. * @return */ default String print(TestContext context) { diff --git a/core/citrus-api/src/main/java/org/citrusframework/message/MessageProcessor.java b/core/citrus-api/src/main/java/org/citrusframework/message/MessageProcessor.java index bec29c555d..46d8a812b0 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/message/MessageProcessor.java +++ b/core/citrus-api/src/main/java/org/citrusframework/message/MessageProcessor.java @@ -17,7 +17,7 @@ public interface MessageProcessor extends MessageTransformer { /** Logger */ - Logger LOG = LoggerFactory.getLogger(MessageProcessor.class); + Logger logger = LoggerFactory.getLogger(MessageProcessor.class); /** Message processor resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/message/processor"; @@ -37,7 +37,7 @@ static > Optional instance = TYPE_RESOLVER.resolve(processor); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve message processor from resource '%s/%s'", RESOURCE_PATH, processor)); + logger.warn(String.format("Failed to resolve message processor from resource '%s/%s'", RESOURCE_PATH, processor)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/message/MessageSelector.java b/core/citrus-api/src/main/java/org/citrusframework/message/MessageSelector.java index 13bb969957..928ae17e4c 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/message/MessageSelector.java +++ b/core/citrus-api/src/main/java/org/citrusframework/message/MessageSelector.java @@ -16,7 +16,7 @@ public interface MessageSelector { /** Logger */ - Logger LOG = LoggerFactory.getLogger(MessageSelector.class); + Logger logger = LoggerFactory.getLogger(MessageSelector.class); /** Message selector resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/message/selector"; @@ -35,8 +35,8 @@ static Map lookup() { if (factories.isEmpty()) { factories.putAll(TYPE_RESOLVER.resolveAll()); - if (LOG.isDebugEnabled()) { - factories.forEach((k, v) -> LOG.debug(String.format("Found value matcher '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + factories.forEach((k, v) -> logger.debug(String.format("Found value matcher '%s' as %s", k, v.getClass()))); } } return factories; diff --git a/core/citrus-api/src/main/java/org/citrusframework/message/ScriptPayloadBuilder.java b/core/citrus-api/src/main/java/org/citrusframework/message/ScriptPayloadBuilder.java index 2245686df0..b6470c944b 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/message/ScriptPayloadBuilder.java +++ b/core/citrus-api/src/main/java/org/citrusframework/message/ScriptPayloadBuilder.java @@ -34,7 +34,7 @@ public interface ScriptPayloadBuilder extends MessagePayloadBuilder { /** Logger */ - Logger LOG = LoggerFactory.getLogger(ScriptPayloadBuilder.class); + Logger logger = LoggerFactory.getLogger(ScriptPayloadBuilder.class); /** Message processor resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/script/message/builder"; @@ -54,7 +54,7 @@ static Optional lookup(String type) { T instance = TYPE_RESOLVER.resolve(type); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve script payload builder from resource '%s/%s'", RESOURCE_PATH, type)); + logger.warn(String.format("Failed to resolve script payload builder from resource '%s/%s'", RESOURCE_PATH, type)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/spi/ResourcePathTypeResolver.java b/core/citrus-api/src/main/java/org/citrusframework/spi/ResourcePathTypeResolver.java index 35200df402..832fff5eab 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/spi/ResourcePathTypeResolver.java +++ b/core/citrus-api/src/main/java/org/citrusframework/spi/ResourcePathTypeResolver.java @@ -42,7 +42,7 @@ public class ResourcePathTypeResolver implements TypeResolver { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ResourcePathTypeResolver.class); + private static final Logger logger = LoggerFactory.getLogger(ResourcePathTypeResolver.class); /** Supported static instance field in target - used as a fallback to the default constructor */ private static final String INSTANCE = "INSTANCE"; @@ -99,7 +99,7 @@ public T resolve(String resourcePath, String property, Object ... initargs) throw new CitrusRuntimeException(String.format("Failed to resolve classpath resource of type '%s'", type), e1); } - LOG.warn(String.format("Neither static instance nor accessible default constructor (%s) is given on type '%s'", + logger.warn(String.format("Neither static instance nor accessible default constructor (%s) is given on type '%s'", Arrays.toString(getParameterTypes(initargs)), type)); throw new CitrusRuntimeException(String.format("Failed to resolve classpath resource of type '%s'", type), e); } @@ -117,7 +117,7 @@ public Map resolveAll(String resourcePath, String property, Strin .forEach(file -> { Optional resourceName = Optional.ofNullable(file.getFilename()); if (resourceName.isEmpty()) { - LOG.warn(String.format("Skip unsupported resource '%s' for resource lookup", file)); + logger.warn(String.format("Skip unsupported resource '%s' for resource lookup", file)); return; } @@ -138,7 +138,7 @@ public Map resolveAll(String resourcePath, String property, Strin } }); } catch (IOException e) { - LOG.warn(String.format("Failed to resolve resources in '%s'", path), e); + logger.warn(String.format("Failed to resolve resources in '%s'", path), e); } return resources; @@ -166,7 +166,7 @@ private List getZipEntries() { zipEntriesAsString.add(entry.getName()); } } catch (IOException e) { - LOG.warn(String.format("Failed to open '%s'", root), e); + logger.warn(String.format("Failed to open '%s'", root), e); } } return zipEntriesAsString; diff --git a/core/citrus-api/src/main/java/org/citrusframework/util/DefaultTypeConverter.java b/core/citrus-api/src/main/java/org/citrusframework/util/DefaultTypeConverter.java index 0b576a293e..470540a23f 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/util/DefaultTypeConverter.java +++ b/core/citrus-api/src/main/java/org/citrusframework/util/DefaultTypeConverter.java @@ -32,7 +32,7 @@ public class DefaultTypeConverter implements TypeConverter { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DefaultTypeConverter.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultTypeConverter.class); public static DefaultTypeConverter INSTANCE = new DefaultTypeConverter(); @@ -56,7 +56,7 @@ public final T convertIfNecessary(Object target, Class type) { try { return (T) new StreamSource(((InputStreamSource)target).getInputStream()); } catch (IOException e) { - LOG.warn("Failed to create stream source from object", e); + logger.warn("Failed to create stream source from object", e); } } } @@ -160,7 +160,7 @@ public final T convertIfNecessary(Object target, Class type) { try { return convertStringToType(String.valueOf(target), type); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Unable to convert String object to type '%s' - try fallback strategies", type), e); + logger.warn(String.format("Unable to convert String object to type '%s' - try fallback strategies", type), e); } } @@ -184,7 +184,7 @@ public final T convertIfNecessary(Object target, Class type) { return convertAfter(target, type); } catch (Exception e) { if (String.class.equals(type)) { - LOG.warn(String.format("Using default toString representation because object type conversion failed with: %s", e.getMessage())); + logger.warn(String.format("Using default toString representation because object type conversion failed with: %s", e.getMessage())); return (T) target.toString(); } @@ -229,7 +229,7 @@ protected T convertBefore(Object target, Class type) { */ protected T convertAfter(Object target, Class type) { if (String.class.equals(type)) { - LOG.warn(String.format("Using default toString representation for object type %s", target.getClass())); + logger.warn(String.format("Using default toString representation for object type %s", target.getClass())); return (T) target.toString(); } diff --git a/core/citrus-api/src/main/java/org/citrusframework/util/TypeConverter.java b/core/citrus-api/src/main/java/org/citrusframework/util/TypeConverter.java index 89463ea803..e4feef3fff 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/util/TypeConverter.java +++ b/core/citrus-api/src/main/java/org/citrusframework/util/TypeConverter.java @@ -14,7 +14,7 @@ public interface TypeConverter { /** Logger */ - Logger LOG = LoggerFactory.getLogger(TypeConverter.class); + Logger logger = LoggerFactory.getLogger(TypeConverter.class); /** Type converter resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/type/converter"; @@ -39,8 +39,8 @@ static Map lookup() { converters.put(DEFAULT, DefaultTypeConverter.INSTANCE); } - if (LOG.isDebugEnabled()) { - converters.forEach((k, v) -> LOG.debug(String.format("Found type converter '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + converters.forEach((k, v) -> logger.debug(String.format("Found type converter '%s' as %s", k, v.getClass()))); } } @@ -75,21 +75,21 @@ static TypeConverter lookupDefault(TypeConverter defaultTypeConverter) { Map converters = lookup(); if (converters.size() == 1) { Map.Entry converterEntry = converters.entrySet().iterator().next(); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Using type converter '%s'", converterEntry.getKey())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Using type converter '%s'", converterEntry.getKey())); } return converterEntry.getValue(); } else if (converters.containsKey(name)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Using type converter '%s'", name)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Using type converter '%s'", name)); } return converters.get(name); } if (!CitrusSettings.TYPE_CONVERTER_DEFAULT.equals(name)) { - LOG.warn(String.format("Missing type converter for name '%s' - using default type converter", name)); + logger.warn(String.format("Missing type converter for name '%s' - using default type converter", name)); } return defaultTypeConverter; diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/AbstractMessageValidator.java b/core/citrus-api/src/main/java/org/citrusframework/validation/AbstractMessageValidator.java index a488752007..b0b2447e31 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/AbstractMessageValidator.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/AbstractMessageValidator.java @@ -22,8 +22,6 @@ import org.citrusframework.exceptions.ValidationException; import org.citrusframework.message.Message; import org.citrusframework.validation.context.ValidationContext; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Base abstract implementation for message validators. Calls method to finds a proper validation context @@ -33,9 +31,6 @@ */ public abstract class AbstractMessageValidator implements MessageValidator { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(this.getClass()); - @Override public final void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, List validationContexts) throws ValidationException { diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/DefaultEmptyMessageValidator.java b/core/citrus-api/src/main/java/org/citrusframework/validation/DefaultEmptyMessageValidator.java index 886789d55a..b26e90e83d 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/DefaultEmptyMessageValidator.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/DefaultEmptyMessageValidator.java @@ -20,6 +20,8 @@ import org.citrusframework.exceptions.ValidationException; import org.citrusframework.message.Message; import org.citrusframework.validation.context.ValidationContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.StringUtils; /** @@ -30,11 +32,13 @@ */ public class DefaultEmptyMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(DefaultEmptyMessageValidator.class); + @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { if (controlMessage == null || controlMessage.getPayload() == null) { - log.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } @@ -42,12 +46,12 @@ public void validateMessage(Message receivedMessage, Message controlMessage, throw new ValidationException("Empty message validation failed - control message is not empty!"); } - log.debug("Start to verify empty message payload ..."); + logger.debug("Start to verify empty message payload ..."); if (StringUtils.hasText(receivedMessage.getPayload(String.class))) { throw new ValidationException("Validation failed - received message content is not empty!") ; } - log.info("Message payload is empty as expected: All values OK"); + logger.info("Message payload is empty as expected: All values OK"); } } diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/HeaderValidator.java b/core/citrus-api/src/main/java/org/citrusframework/validation/HeaderValidator.java index f3e55130ce..b96f27470d 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/HeaderValidator.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/HeaderValidator.java @@ -35,7 +35,7 @@ public interface HeaderValidator { /** Logger */ - Logger LOG = LoggerFactory.getLogger(HeaderValidator.class); + Logger logger = LoggerFactory.getLogger(HeaderValidator.class); /** Header validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/header/validator"; @@ -54,8 +54,8 @@ static Map lookup() { if (validators.isEmpty()) { validators.putAll(TYPE_RESOLVER.resolveAll("", TypeResolver.DEFAULT_TYPE_PROPERTY, "name")); - if (LOG.isDebugEnabled()) { - validators.forEach((k, v) -> LOG.debug(String.format("Found header validator '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + validators.forEach((k, v) -> logger.debug(String.format("Found header validator '%s' as %s", k, v.getClass()))); } } return validators; @@ -73,7 +73,7 @@ static Optional lookup(String validator) { HeaderValidator instance = TYPE_RESOLVER.resolve(validator); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve header validator from resource '%s/%s'", RESOURCE_PATH, validator)); + logger.warn(String.format("Failed to resolve header validator from resource '%s/%s'", RESOURCE_PATH, validator)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidator.java b/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidator.java index 8b4607e62f..ba7e99a2dd 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidator.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidator.java @@ -41,7 +41,7 @@ public interface MessageValidator { /** Logger */ - Logger LOG = LoggerFactory.getLogger(MessageValidator.class); + Logger logger = LoggerFactory.getLogger(MessageValidator.class); /** Message validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/message/validator"; @@ -57,8 +57,8 @@ public interface MessageValidator { static Map> lookup() { Map> validators = TYPE_RESOLVER.resolveAll("", TypeResolver.DEFAULT_TYPE_PROPERTY, "name"); - if (LOG.isDebugEnabled()) { - validators.forEach((k, v) -> LOG.debug(String.format("Found message validator '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + validators.forEach((k, v) -> logger.debug(String.format("Found message validator '%s' as %s", k, v.getClass()))); } return validators; @@ -76,7 +76,7 @@ static Optional> lookup(String val MessageValidator instance = TYPE_RESOLVER.resolve(validator); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve validator from resource '%s/%s'", RESOURCE_PATH, validator)); + logger.warn(String.format("Failed to resolve validator from resource '%s/%s'", RESOURCE_PATH, validator)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidatorRegistry.java b/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidatorRegistry.java index 5141aea11d..4afcb9f835 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidatorRegistry.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/MessageValidatorRegistry.java @@ -41,7 +41,7 @@ public class MessageValidatorRegistry { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(MessageValidatorRegistry.class); + private static final Logger logger = LoggerFactory.getLogger(MessageValidatorRegistry.class); /** The default bean id in Spring application context*/ public static final String BEAN_NAME = "citrusMessageValidatorRegistry"; @@ -95,12 +95,12 @@ public List> findMessageValidators } if (isEmptyOrDefault(matchingValidators)) { - LOG.warn(String.format("Unable to find proper message validator. Message type is '%s' and message payload is '%s'", messageType, message.getPayload(String.class))); + logger.warn(String.format("Unable to find proper message validator. Message type is '%s' and message payload is '%s'", messageType, message.getPayload(String.class))); throw new CitrusRuntimeException("Failed to find proper message validator for message"); } - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Found %s message validators for message", matchingValidators.size())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Found %s message validators for message", matchingValidators.size())); } return matchingValidators; @@ -185,8 +185,8 @@ public MessageValidator getMessageValidator(String * @param messageValidator */ public void addMessageValidator(String name, MessageValidator messageValidator) { - if (this.messageValidators.containsKey(name) && LOG.isDebugEnabled()) { - LOG.debug(String.format("Overwriting message validator '%s' in registry", name)); + if (this.messageValidators.containsKey(name) && logger.isDebugEnabled()) { + logger.debug(String.format("Overwriting message validator '%s' in registry", name)); } this.messageValidators.put(name, messageValidator); @@ -198,8 +198,8 @@ public void addMessageValidator(String name, MessageValidator schemaValidator) { - if (this.schemaValidators.containsKey(name) && LOG.isDebugEnabled()) { - LOG.debug(String.format("Overwriting message validator '%s' in registry", name)); + if (this.schemaValidators.containsKey(name) && logger.isDebugEnabled()) { + logger.debug(String.format("Overwriting message validator '%s' in registry", name)); } this.schemaValidators.put(name, schemaValidator); diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/SchemaValidator.java b/core/citrus-api/src/main/java/org/citrusframework/validation/SchemaValidator.java index 20523deb4d..57cfa607ee 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/SchemaValidator.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/SchemaValidator.java @@ -20,7 +20,7 @@ public interface SchemaValidator { /** Logger */ - Logger LOG = LoggerFactory.getLogger(MessageValidator.class); + Logger logger = LoggerFactory.getLogger(MessageValidator.class); /** Schema validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/message/schemaValidator"; @@ -36,8 +36,8 @@ public interface SchemaValidator { static Map> lookup() { Map> validators = TYPE_RESOLVER.resolveAll("", TypeResolver.DEFAULT_TYPE_PROPERTY, "name"); - if (LOG.isDebugEnabled()) { - validators.forEach((k, v) -> LOG.debug(String.format("Found message validator '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + validators.forEach((k, v) -> logger.debug(String.format("Found message validator '%s' as %s", k, v.getClass()))); } return validators; @@ -55,7 +55,7 @@ static Optional> lookup(Strin SchemaValidator instance = TYPE_RESOLVER.resolve(validator); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve validator from resource '%s/%s'", RESOURCE_PATH, validator)); + logger.warn(String.format("Failed to resolve validator from resource '%s/%s'", RESOURCE_PATH, validator)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/ValueMatcher.java b/core/citrus-api/src/main/java/org/citrusframework/validation/ValueMatcher.java index d6ab607a78..2d13661f76 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/ValueMatcher.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/ValueMatcher.java @@ -17,7 +17,7 @@ public interface ValueMatcher { /** Logger */ - Logger LOG = LoggerFactory.getLogger(MessageValidator.class); + Logger logger = LoggerFactory.getLogger(MessageValidator.class); /** Message validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/value/matcher"; @@ -36,8 +36,8 @@ static Map lookup() { if (validators.isEmpty()) { validators.putAll(TYPE_RESOLVER.resolveAll()); - if (LOG.isDebugEnabled()) { - validators.forEach((k, v) -> LOG.debug(String.format("Found value matcher '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + validators.forEach((k, v) -> logger.debug(String.format("Found value matcher '%s' as %s", k, v.getClass()))); } } return validators; @@ -55,7 +55,7 @@ static Optional lookup(String validator) { ValueMatcher instance = TYPE_RESOLVER.resolve(validator); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve value matcher from resource '%s/%s'", RESOURCE_PATH, validator)); + logger.warn(String.format("Failed to resolve value matcher from resource '%s/%s'", RESOURCE_PATH, validator)); } return Optional.empty(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/validation/matcher/ValidationMatcher.java b/core/citrus-api/src/main/java/org/citrusframework/validation/matcher/ValidationMatcher.java index 789218cb22..523cdbb0f7 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/validation/matcher/ValidationMatcher.java +++ b/core/citrus-api/src/main/java/org/citrusframework/validation/matcher/ValidationMatcher.java @@ -35,7 +35,7 @@ public interface ValidationMatcher { /** Logger */ - Logger LOG = LoggerFactory.getLogger(ValidationMatcher.class); + Logger logger = LoggerFactory.getLogger(ValidationMatcher.class); /** Message validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/validation/matcher"; @@ -51,8 +51,8 @@ static Map lookup() { if (matcher.isEmpty()) { matcher.putAll(new ResourcePathTypeResolver().resolveAll(RESOURCE_PATH)); - if (LOG.isDebugEnabled()) { - matcher.forEach((k, v) -> LOG.debug(String.format("Found validation matcher '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + matcher.forEach((k, v) -> logger.debug(String.format("Found validation matcher '%s' as %s", k, v.getClass()))); } } return matcher; diff --git a/core/citrus-api/src/main/java/org/citrusframework/variable/SegmentVariableExtractorRegistry.java b/core/citrus-api/src/main/java/org/citrusframework/variable/SegmentVariableExtractorRegistry.java index ae6d60d5b9..f56247ad0f 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/variable/SegmentVariableExtractorRegistry.java +++ b/core/citrus-api/src/main/java/org/citrusframework/variable/SegmentVariableExtractorRegistry.java @@ -23,7 +23,7 @@ public class SegmentVariableExtractorRegistry { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(SegmentVariableExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(SegmentVariableExtractor.class); /** Segment variable extractor resource lookup path */ private static final String RESOURCE_PATH = "META-INF/citrus/variable/extractor/segment"; @@ -42,7 +42,7 @@ static Collection lookup() { Map extractors = TYPE_RESOLVER.resolveAll(); return extractors.values(); } catch (CitrusRuntimeException e) { - log.warn(String.format("Failed to resolve segment variable extractor from resource '%s'", RESOURCE_PATH)); + logger.warn(String.format("Failed to resolve segment variable extractor from resource '%s'", RESOURCE_PATH)); } return Collections.emptyList(); diff --git a/core/citrus-api/src/main/java/org/citrusframework/variable/VariableExtractor.java b/core/citrus-api/src/main/java/org/citrusframework/variable/VariableExtractor.java index ea2af9e445..06a7d25b9e 100644 --- a/core/citrus-api/src/main/java/org/citrusframework/variable/VariableExtractor.java +++ b/core/citrus-api/src/main/java/org/citrusframework/variable/VariableExtractor.java @@ -37,7 +37,7 @@ public interface VariableExtractor extends MessageProcessor { /** Logger */ - Logger LOG = LoggerFactory.getLogger(VariableExtractor.class); + Logger logger = LoggerFactory.getLogger(VariableExtractor.class); /** Variable extractor resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/variable/extractor"; @@ -57,7 +57,7 @@ static > Optional instance = TYPE_RESOLVER.resolve(extractor); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve variable extractor from resource '%s/%s'", RESOURCE_PATH, extractor)); + logger.warn(String.format("Failed to resolve variable extractor from resource '%s/%s'", RESOURCE_PATH, extractor)); } return Optional.empty(); diff --git a/core/citrus-api/src/test/java/org/citrusframework/log/LogMessageModifierTest.java b/core/citrus-api/src/test/java/org/citrusframework/log/LogMessageModifierTest.java index 7785f54a96..aba6ce353b 100644 --- a/core/citrus-api/src/test/java/org/citrusframework/log/LogMessageModifierTest.java +++ b/core/citrus-api/src/test/java/org/citrusframework/log/LogMessageModifierTest.java @@ -17,7 +17,7 @@ * limitations under the License. */ -package org.citrusframework.log; +package org.citrusframework.logger; import java.util.Collections; diff --git a/core/citrus-base/src/main/java/org/citrusframework/CitrusContext.java b/core/citrus-base/src/main/java/org/citrusframework/CitrusContext.java index 798e45d61a..49f4da6cb0 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/CitrusContext.java +++ b/core/citrus-base/src/main/java/org/citrusframework/CitrusContext.java @@ -13,8 +13,8 @@ import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.functions.DefaultFunctionRegistry; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.DefaultLogModifier; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.DefaultLogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.message.MessageProcessors; import org.citrusframework.report.*; import org.citrusframework.spi.ReferenceRegistry; diff --git a/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java b/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java index ddccf5179a..99cf77eafb 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java +++ b/core/citrus-base/src/main/java/org/citrusframework/CitrusContextProvider.java @@ -16,7 +16,7 @@ public interface CitrusContextProvider { /** Logger */ - Logger LOG = LoggerFactory.getLogger(CitrusContextProvider.class); + Logger logger = LoggerFactory.getLogger(CitrusContextProvider.class); /** Endpoint parser resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/context/provider"; @@ -42,20 +42,20 @@ static CitrusContextProvider lookup() { TYPE_RESOLVER.resolveAll("", TypeResolver.TYPE_PROPERTY_WILDCARD); if (provider.isEmpty()) { - LOG.debug("Using default Citrus context provider"); + logger.debug("Using default Citrus context provider"); return new DefaultCitrusContextProvider(); } if (provider.size() > 1) { - LOG.warn(String.format("Found %d Citrus context provider implementations. Please choose one of them.", provider.size())); + logger.warn(String.format("Found %d Citrus context provider implementations. Please choose one of them.", provider.size())); } - if (LOG.isDebugEnabled()) { - provider.forEach((k, v) -> LOG.debug(String.format("Found Citrus context provider '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + provider.forEach((k, v) -> logger.debug(String.format("Found Citrus context provider '%s' as %s", k, v.getClass()))); } CitrusContextProvider contextProvider = provider.values().iterator().next(); - LOG.debug(String.format("Using Citrus context provider '%s' as %s", provider.keySet().iterator().next(), contextProvider)); + logger.debug(String.format("Using Citrus context provider '%s' as %s", provider.keySet().iterator().next(), contextProvider)); return contextProvider; } @@ -72,7 +72,7 @@ static Optional lookup(String name) { CitrusContextProvider instance = TYPE_RESOLVER.resolve(name); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve Citrus context provider from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn(String.format("Failed to resolve Citrus context provider from resource '%s/%s'", RESOURCE_PATH, name)); } return Optional.empty(); diff --git a/core/citrus-base/src/main/java/org/citrusframework/DefaultTestCase.java b/core/citrus-base/src/main/java/org/citrusframework/DefaultTestCase.java index b2860bd097..402122fb0f 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/DefaultTestCase.java +++ b/core/citrus-base/src/main/java/org/citrusframework/DefaultTestCase.java @@ -13,6 +13,8 @@ import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.exceptions.TestCaseFailedException; import org.citrusframework.util.TestUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Default test case implementation holding a list of test actions to execute. Test case also holds variable definitions and @@ -21,6 +23,9 @@ */ public class DefaultTestCase extends AbstractActionContainer implements TestCase, TestGroupAware, TestParameterAware { + /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(DefaultTestCase.class); + /** Further chain of test actions to be executed in any case (success, error) * Usually used to clean up database in any case of test result */ private List> finalActions = new ArrayList<>(); @@ -57,8 +62,8 @@ public void start(final TestContext context) { context.getTestListeners().onTestStart(this); try { - if (log.isDebugEnabled()) { - log.debug("Initializing test case"); + if (logger.isDebugEnabled()) { + logger.debug("Initializing test case"); } debugVariables("Global", context); @@ -115,7 +120,7 @@ public void afterTest(final TestContext context) { sequenceAfterTest.execute(context); } } catch (final Exception | AssertionError e) { - log.warn("After test failed with errors", e); + logger.warn("After test failed with errors", e); } } } @@ -198,7 +203,7 @@ public void finish(final TestContext context) { */ private void executeFinalActions(TestContext context) { if (!finalActions.isEmpty()) { - log.debug("Entering finally block in test case"); + logger.debug("Entering finally block in test case"); /* walk through the finally chain and execute the actions in there */ for (final TestActionBuilder actionBuilder : finalActions) { @@ -227,10 +232,10 @@ private void executeFinalActions(TestContext context) { */ private void debugVariables(String scope, TestContext context) { /* Debug print global variables */ - if (context.hasVariables() && log.isDebugEnabled()) { - log.debug(String.format("%s variables:", scope)); + if (context.hasVariables() && logger.isDebugEnabled()) { + logger.debug(String.format("%s variables:", scope)); for (final Map.Entry entry : context.getVariables().entrySet()) { - log.debug(String.format("%s = %s", entry.getKey(), entry.getValue())); + logger.debug(String.format("%s = %s", entry.getKey(), entry.getValue())); } } } @@ -246,8 +251,8 @@ private void initializeTestParameters(Map parameters, TestContex context.setVariable(CitrusSettings.TEST_PACKAGE_VARIABLE, packageName); for (final Map.Entry paramEntry : parameters.entrySet()) { - if (log.isDebugEnabled()) { - log.debug(String.format("Initializing test parameter '%s' as variable", paramEntry.getKey())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Initializing test parameter '%s' as variable", paramEntry.getKey())); } context.setVariable(paramEntry.getKey(), paramEntry.getValue()); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/AbstractAsyncTestAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/AbstractAsyncTestAction.java index 87b44e1c36..82f200a7d8 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/AbstractAsyncTestAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/AbstractAsyncTestAction.java @@ -37,7 +37,7 @@ public abstract class AbstractAsyncTestAction extends AbstractTestAction implements Completable { /** Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractAsyncTestAction.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractAsyncTestAction.class); /** Future finished indicator */ private Future finished; @@ -51,7 +51,7 @@ public final void doExecute(TestContext context) { doExecuteAsync(context); result.complete(null); } catch (Exception | Error e) { - log.warn("Async test action execution raised error", e); + logger.warn("Async test action execution raised error", e); if (e instanceof CitrusRuntimeException) { context.addException((CitrusRuntimeException) e); diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/AntRunAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/AntRunAction.java index 06495d656d..570eb00dd2 100755 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/AntRunAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/AntRunAction.java @@ -69,7 +69,7 @@ public class AntRunAction extends AbstractTestAction { private final BuildListener buildListener; /** Logger */ - private static Logger log = LoggerFactory.getLogger(AntRunAction.class); + private static final Logger logger = LoggerFactory.getLogger(AntRunAction.class); /** * Default constructor. @@ -97,7 +97,7 @@ public void doExecute(TestContext context) { for (Entry entry : properties.entrySet()) { String propertyValue = entry.getValue() != null ? context.replaceDynamicContentInString(entry.getValue().toString()) : ""; - log.debug("Set build property: " + entry.getKey() + "=" + propertyValue); + logger.debug("Set build property: " + entry.getKey() + "=" + propertyValue); project.setProperty(entry.getKey().toString(), propertyValue); } @@ -107,30 +107,17 @@ public void doExecute(TestContext context) { project.addBuildListener(buildListener); } - DefaultLogger consoleLogger = new DefaultLogger() { - @Override - protected void printMessage(String message, PrintStream stream, int priority) { - if (stream.equals(System.err)) { - log.error(message); - } else { - log.info(message); - } - } - }; - - consoleLogger.setErrorPrintStream(System.err); - consoleLogger.setOutputPrintStream(System.out); - consoleLogger.setMessageOutputLevel(Project.MSG_DEBUG); + DefaultLogger consoleLogger = getDefaultConsoleLogger(); project.addBuildListener(consoleLogger); - log.info("Executing ANT build: " + buildFileResource); + logger.info("Executing ANT build: " + buildFileResource); if (StringUtils.hasText(targets)) { - log.info("Executing ANT targets: " + targets); + logger.info("Executing ANT targets: " + targets); project.executeTargets(parseTargets()); } else { - log.info("Executing ANT target: " + target); + logger.info("Executing ANT target: " + target); project.executeTarget(target); } } catch (BuildException e) { @@ -139,7 +126,25 @@ protected void printMessage(String message, PrintStream stream, int priority) { throw new CitrusRuntimeException("Failed to read ANT build file", e); } - log.info("Executed ANT build: " + buildFileResource); + logger.info("Executed ANT build: " + buildFileResource); + } + + private static DefaultLogger getDefaultConsoleLogger() { + DefaultLogger consoleLogger = new DefaultLogger() { + @Override + protected void printMessage(String message, PrintStream stream, int priority) { + if (stream.equals(System.err)) { + logger.error(message); + } else { + logger.info(message); + } + } + }; + + consoleLogger.setErrorPrintStream(System.err); + consoleLogger.setOutputPrintStream(System.out); + consoleLogger.setMessageOutputLevel(Project.MSG_DEBUG); + return consoleLogger; } /** @@ -165,7 +170,7 @@ private Stack parseTargets() { private void loadBuildPropertyFile(Project project, TestContext context) { if (StringUtils.hasText(propertyFilePath)) { String propertyFileResource = context.replaceDynamicContentInString(propertyFilePath); - log.info("Reading build property file: " + propertyFileResource); + logger.info("Reading build property file: " + propertyFileResource); Properties fileProperties; try { fileProperties = PropertiesLoaderUtils.loadProperties(new PathMatchingResourcePatternResolver().getResource(propertyFileResource)); @@ -173,8 +178,8 @@ private void loadBuildPropertyFile(Project project, TestContext context) { for (Entry entry : fileProperties.entrySet()) { String propertyValue = entry.getValue() != null ? context.replaceDynamicContentInString(entry.getValue().toString()) : ""; - if (log.isDebugEnabled()) { - log.debug("Set build property from file resource: " + entry.getKey() + "=" + propertyValue); + if (logger.isDebugEnabled()) { + logger.debug("Set build property from file resource: " + entry.getKey() + "=" + propertyValue); } project.setProperty(entry.getKey().toString(), propertyValue); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/CreateVariablesAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/CreateVariablesAction.java index e5f471dd1d..7e334d27bb 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/CreateVariablesAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/CreateVariablesAction.java @@ -39,7 +39,7 @@ public class CreateVariablesAction extends AbstractTestAction { private final Map variables; /** Logger */ - private static Logger log = LoggerFactory.getLogger(CreateVariablesAction.class); + private static final Logger logger = LoggerFactory.getLogger(CreateVariablesAction.class); /** * Default constructor. @@ -65,7 +65,7 @@ public void doExecute(TestContext context) { //check if value is variable or function (and resolve it if yes) value = context.replaceDynamicContentInString(value); - log.info("Setting variable: " + key + " to value: " + value); + logger.info("Setting variable: " + key + " to value: " + value); context.setVariable(key, value); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/EchoAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/EchoAction.java index 1cfbc9a2df..5bd357ee37 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/EchoAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/EchoAction.java @@ -35,7 +35,7 @@ public class EchoAction extends AbstractTestAction { private final String message; /** Logger */ - private static Logger log = LoggerFactory.getLogger(EchoAction.class); + private static final Logger logger = LoggerFactory.getLogger(EchoAction.class); /** * Default constructor using the builder. @@ -50,9 +50,9 @@ private EchoAction(EchoAction.Builder builder) { @Override public void doExecute(TestContext context) { if (message == null) { - log.info("Citrus test " + new Date(System.currentTimeMillis())); + logger.info("Citrus test " + new Date(System.currentTimeMillis())); } else { - log.info(context.getLogModifier().mask(context.replaceDynamicContentInString(message))); + logger.info(context.getLogModifier().mask(context.replaceDynamicContentInString(message))); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java index 8017a87830..4383100671 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/InputAction.java @@ -43,7 +43,7 @@ public class InputAction extends AbstractTestAction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(InputAction.class); + private static final Logger logger = LoggerFactory.getLogger(InputAction.class); /** Prompted message displayed to the user before input */ private final String message; @@ -78,7 +78,7 @@ public void doExecute(TestContext context) { if (context.getVariables().containsKey(variable)) { input = context.getVariable(variable); - log.info("Variable " + variable + " is already set (='" + input + "'). Skip waiting for user input"); + logger.info("Variable " + variable + " is already set (='" + input + "'). Skip waiting for user input"); return; } @@ -93,7 +93,7 @@ public void doExecute(TestContext context) { try { do { - log.info(display); + logger.info(display); BufferedReader stdin = getInputReader(); input = stdin.readLine(); @@ -127,7 +127,7 @@ private boolean checkAnswer(String input) { } } - log.info("User input is not valid - must be one of " + validAnswers); + logger.info("User input is not valid - must be one of " + validAnswers); return false; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/JavaAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/JavaAction.java index 6e5b1a136f..000df256a3 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/JavaAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/JavaAction.java @@ -54,7 +54,7 @@ public class JavaAction extends AbstractTestAction { private final List constructorArgs; /** Logger */ - private static Logger log = LoggerFactory.getLogger(JavaAction.class); + private static final Logger logger = LoggerFactory.getLogger(JavaAction.class); /** * Default constructor. @@ -125,7 +125,7 @@ private void invokeMethod(Object instance, Class[] methodTypes, Object[] meth StringUtils.arrayToCommaDelimitedString(methodTypes) + ")' for class '" + instance.getClass() + "'"); } - log.info("Invoking method '" + methodToRun.toString() + "' on instance '" + instance.getClass() + "'"); + logger.info("Invoking method '" + methodToRun.toString() + "' on instance '" + instance.getClass() + "'"); methodToRun.invoke(instance, methodObjects); } @@ -152,7 +152,7 @@ private Object getObjectInstanceFromClass(TestContext context) throws ClassNotFo "is set for Java reflection call"); } - log.info("Instantiating class for name '" + className + "'"); + logger.info("Instantiating class for name '" + className + "'"); Class classToRun = Class.forName(className); diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/LoadPropertiesAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/LoadPropertiesAction.java index b16a2a532b..ea19f55b84 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/LoadPropertiesAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/LoadPropertiesAction.java @@ -42,7 +42,7 @@ public class LoadPropertiesAction extends AbstractTestAction { private final String filePath; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(LoadPropertiesAction.class); + private static final Logger logger = LoggerFactory.getLogger(LoadPropertiesAction.class); /** * Default constructor. @@ -57,8 +57,8 @@ public LoadPropertiesAction(Builder builder) { public void doExecute(TestContext context) { Resource resource = FileUtils.getFileResource(filePath, context); - if (LOG.isDebugEnabled()) { - LOG.debug("Reading property file " + resource.getFilename()); + if (logger.isDebugEnabled()) { + logger.debug("Reading property file " + resource.getFilename()); } Properties props = FileUtils.loadAsProperties(resource); @@ -67,12 +67,12 @@ public void doExecute(TestContext context) { for (Entry entry : props.entrySet()) { String key = entry.getKey().toString(); - if (LOG.isDebugEnabled()) { - LOG.debug("Loading property: " + key + "=" + props.getProperty(key) + " into variables"); + if (logger.isDebugEnabled()) { + logger.debug("Loading property: " + key + "=" + props.getProperty(key) + " into variables"); } - if (LOG.isDebugEnabled() && context.getVariables().containsKey(key)) { - LOG.debug("Overwriting property " + key + " old value:" + context.getVariable(key) + if (logger.isDebugEnabled() && context.getVariables().containsKey(key)) { + logger.debug("Overwriting property " + key + " old value:" + context.getVariable(key) + " new value:" + props.getProperty(key)); } @@ -85,7 +85,7 @@ public void doExecute(TestContext context) { context.resolveDynamicValuesInMap(unresolved).forEach(context::setVariable); - LOG.info("Loaded property file " + resource.getFilename()); + logger.info("Loaded property file " + resource.getFilename()); } /** diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/PurgeEndpointAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/PurgeEndpointAction.java index 372c6fa7a1..0be9dc38dd 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/PurgeEndpointAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/PurgeEndpointAction.java @@ -66,7 +66,7 @@ public class PurgeEndpointAction extends AbstractTestAction { private final long sleepTime; /** Logger */ - private static Logger log = LoggerFactory.getLogger(PurgeEndpointAction.class); + private static final Logger logger = LoggerFactory.getLogger(PurgeEndpointAction.class); /** * Default constructor. @@ -85,8 +85,8 @@ public PurgeEndpointAction(Builder builder) { @Override public void doExecute(TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Purging message endpoints ..."); + if (logger.isDebugEnabled()) { + logger.debug("Purging message endpoints ..."); } for (Endpoint endpoint : endpoints) { @@ -97,7 +97,7 @@ public void doExecute(TestContext context) { purgeEndpoint(resolveEndpointName(endpointName), context); } - log.info("Purged message endpoints"); + logger.info("Purged message endpoints"); } /** @@ -108,8 +108,8 @@ public void doExecute(TestContext context) { * @param context */ private void purgeEndpoint(Endpoint endpoint, TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Try to purge message endpoint " + endpoint.getName()); + if (logger.isDebugEnabled()) { + logger.debug("Try to purge message endpoint " + endpoint.getName()); } int messagesPurged = 0; @@ -124,26 +124,26 @@ private void purgeEndpoint(Endpoint endpoint, TestContext context) { message = (receiveTimeout >= 0) ? messageConsumer.receive(context, receiveTimeout) : messageConsumer.receive(context); } } catch (ActionTimeoutException e) { - if (log.isDebugEnabled()) { - log.debug("Stop purging due to timeout - " + e.getMessage()); + if (logger.isDebugEnabled()) { + logger.debug("Stop purging due to timeout - " + e.getMessage()); } break; } if (message != null) { - log.debug("Removed message from endpoint " + endpoint.getName()); + logger.debug("Removed message from endpoint " + endpoint.getName()); messagesPurged++; try { Thread.sleep(sleepTime); } catch (InterruptedException e) { - log.warn("Interrupted during wait", e); + logger.warn("Interrupted during wait", e); } } } while (message != null); - if (log.isDebugEnabled()) { - log.debug("Purged " + messagesPurged + " messages from endpoint"); + if (logger.isDebugEnabled()) { + logger.debug("Purged " + messagesPurged + " messages from endpoint"); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveMessageAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveMessageAction.java index d873e3e1da..3a14b6485e 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveMessageAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveMessageAction.java @@ -118,7 +118,7 @@ public class ReceiveMessageAction extends AbstractTestAction { private final String messageType; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ReceiveMessageAction.class); + private static final Logger logger = LoggerFactory.getLogger(ReceiveMessageAction.class); /** * Default constructor. @@ -186,8 +186,8 @@ private Message receive(TestContext context) { * @return */ private Message receiveSelected(TestContext context, String selectorString) { - if (LOG.isDebugEnabled()) { - LOG.debug("Setting message selector: '" + selectorString + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Setting message selector: '" + selectorString + "'"); } Endpoint messageEndpoint = getOrCreateEndpoint(context); @@ -203,7 +203,7 @@ private Message receiveSelected(TestContext context, String selectorString) { context, messageEndpoint.getEndpointConfiguration().getTimeout()); } } else { - LOG.warn(String.format("Unable to receive selective with consumer implementation: '%s'", consumer.getClass())); + logger.warn(String.format("Unable to receive selective with consumer implementation: '%s'", consumer.getClass())); return receive(context); } } @@ -215,8 +215,8 @@ private Message receiveSelected(TestContext context, String selectorString) { protected void validateMessage(Message message, TestContext context) { messageProcessors.forEach(processor -> processor.process(message, context)); - if (LOG.isDebugEnabled()) { - LOG.debug("Received message:\n" + message.print(context)); + if (logger.isDebugEnabled()) { + logger.debug("Received message:\n" + message.print(context)); } // extract variables from received message content @@ -235,8 +235,8 @@ protected void validateMessage(Message message, TestContext context) { } else { Message controlMessage = createControlMessage(context, messageType); - if (LOG.isDebugEnabled()) { - LOG.debug("Control message:\n" + controlMessage.print(context)); + if (logger.isDebugEnabled()) { + logger.debug("Control message:\n" + controlMessage.print(context)); } if (StringUtils.hasText(controlMessage.getName())) { @@ -271,7 +271,7 @@ protected void validateMessage(Message message, TestContext context) { || ScriptValidationContext.class.isAssignableFrom(item.getClass()))) { throw new CitrusRuntimeException(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts)); } else { - LOG.warn(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts)); + logger.warn(String.format("Unable to find proper message validator for message type '%s' and validation contexts '%s'", messageType, validationContexts)); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveTimeoutAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveTimeoutAction.java index e000703e74..08abbb83e2 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveTimeoutAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/ReceiveTimeoutAction.java @@ -56,7 +56,7 @@ public class ReceiveTimeoutAction extends AbstractTestAction { private final String messageSelector; /** Logger */ - private static final Logger log = LoggerFactory.getLogger(ReceiveTimeoutAction.class); + private static final Logger logger = LoggerFactory.getLogger(ReceiveTimeoutAction.class); /** * Default constructor. @@ -86,16 +86,16 @@ public void doExecute(TestContext context) { } if (receivedMessage != null) { - if (log.isDebugEnabled()) { - log.debug("Received message:\n" + receivedMessage.print(context)); + if (logger.isDebugEnabled()) { + logger.debug("Received message:\n" + receivedMessage.print(context)); } throw new CitrusRuntimeException("Message timeout validation failed! " + "Received message while waiting for timeout on destination"); } } catch (ActionTimeoutException e) { - log.info("No messages received on destination. Message timeout validation OK!"); - log.info(e.getMessage()); + logger.info("No messages received on destination. Message timeout validation OK!"); + logger.info(e.getMessage()); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/SendMessageAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/SendMessageAction.java index 8ddc07ab6b..4476c8b56a 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/SendMessageAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/SendMessageAction.java @@ -98,7 +98,7 @@ public class SendMessageAction extends AbstractTestAction implements Completable private CompletableFuture finished; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SendMessageAction.class); + private static final Logger logger = LoggerFactory.getLogger(SendMessageAction.class); /** * Default constructor. @@ -142,7 +142,7 @@ public void doExecute(final TestContext context) { } if (forkMode) { - LOG.debug("Forking message sending action ..."); + logger.debug("Forking message sending action ..."); SimpleAsyncTaskExecutor taskExecutor = new SimpleAsyncTaskExecutor(); taskExecutor.execute(() -> { diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/SleepAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/SleepAction.java index 552e022cf3..dfb338445e 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/SleepAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/SleepAction.java @@ -38,7 +38,7 @@ public class SleepAction extends AbstractTestAction { private final TimeUnit timeUnit; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SleepAction.class); + private static final Logger logger = LoggerFactory.getLogger(SleepAction.class); /** * Default constructor. @@ -56,7 +56,7 @@ public void doExecute(TestContext context) { String duration = context.resolveDynamicValue(time); try { - LOG.info(String.format("Sleeping %s %s", duration, timeUnit)); + logger.info(String.format("Sleeping %s %s", duration, timeUnit)); if (duration.indexOf(".") > 0) { switch (timeUnit) { @@ -77,7 +77,7 @@ public void doExecute(TestContext context) { timeUnit.sleep(Long.parseLong(duration)); } - LOG.info(String.format("Returning after %s %s", duration, timeUnit)); + logger.info(String.format("Returning after %s %s", duration, timeUnit)); } catch (InterruptedException e) { throw new CitrusRuntimeException(e); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/StartServerAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/StartServerAction.java index 27526edd98..9165aa0823 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/StartServerAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/StartServerAction.java @@ -40,7 +40,7 @@ public class StartServerAction extends AbstractTestAction { private final List servers; /** Logger */ - private static Logger log = LoggerFactory.getLogger(StartServerAction.class); + private static final Logger logger = LoggerFactory.getLogger(StartServerAction.class); /** * Default constructor. @@ -55,7 +55,7 @@ public StartServerAction(Builder builder) { public void doExecute(TestContext context) { for (Server server : servers) { server.start(); - log.info("Started server: " + server.getName()); + logger.info("Started server: " + server.getName()); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/StopServerAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/StopServerAction.java index c948c9821d..96c67fa403 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/StopServerAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/StopServerAction.java @@ -40,7 +40,7 @@ public class StopServerAction extends AbstractTestAction { private final List servers; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(StopServerAction.class); + private static final Logger logger = LoggerFactory.getLogger(StopServerAction.class); /** * Default constructor. @@ -55,7 +55,7 @@ public StopServerAction(Builder builder) { public void doExecute(TestContext context) { for (Server server : servers) { server.stop(); - LOG.info("Stopped server: " + server.getName()); + logger.info("Stopped server: " + server.getName()); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimeAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimeAction.java index a428027ff1..be3b8fd74d 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimeAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimeAction.java @@ -39,7 +39,7 @@ public class StopTimeAction extends AbstractTestAction { private final String suffix; /** Logger */ - private static Logger log = LoggerFactory.getLogger(StopTimeAction.class); + private static final Logger logger = LoggerFactory.getLogger(StopTimeAction.class); /** * Default constructor. @@ -62,12 +62,12 @@ public void doExecute(TestContext context) { context.setVariable(timeLineId + timeLineSuffix, time); if (description != null) { - log.info("TimeWatcher " + timeLineId + " after " + time + " ms (" + description + ")"); + logger.info("TimeWatcher " + timeLineId + " after " + time + " ms (" + description + ")"); } else { - log.info("TimeWatcher " + timeLineId + " after " + time + " ms"); + logger.info("TimeWatcher " + timeLineId + " after " + time + " ms"); } } else { - log.info("Starting TimeWatcher: " + timeLineId); + logger.info("Starting TimeWatcher: " + timeLineId); context.setVariable(timeLineId, System.currentTimeMillis()); context.setVariable(timeLineId + timeLineSuffix, 0L); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimerAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimerAction.java index 01f92e62e7..1a7f0afab6 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimerAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/StopTimerAction.java @@ -27,7 +27,7 @@ */ public class StopTimerAction extends AbstractTestAction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(StopTimerAction.class); + private static final Logger logger = LoggerFactory.getLogger(StopTimerAction.class); private final String timerId; @@ -48,10 +48,10 @@ public String getTimerId() { public void doExecute(TestContext context) { if (timerId != null) { boolean success = context.stopTimer(timerId); - log.info(String.format("Stopping timer %s - stop successful: %s", timerId, success)); + logger.info(String.format("Stopping timer %s - stop successful: %s", timerId, success)); } else { context.stopTimers(); - log.info("Stopping all timers"); + logger.info("Stopping all timers"); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/TraceVariablesAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/TraceVariablesAction.java index 1ac6c86588..c63c07e69e 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/TraceVariablesAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/TraceVariablesAction.java @@ -38,7 +38,7 @@ public class TraceVariablesAction extends AbstractTestAction { private final List variableNames; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TraceVariablesAction.class); + private static final Logger logger = LoggerFactory.getLogger(TraceVariablesAction.class); /** * Default constructor. @@ -51,7 +51,7 @@ public TraceVariablesAction(Builder builder) { @Override public void doExecute(TestContext context) { - LOG.info("Trace variables"); + logger.info("Trace variables"); Iterator it; if (variableNames != null && variableNames.size() > 0) { @@ -64,7 +64,7 @@ public void doExecute(TestContext context) { String key = it.next(); String value = context.getVariable(key); - LOG.info("Variable " + context.getLogModifier().mask(key + " = " + value)); + logger.info("Variable " + context.getLogModifier().mask(key + " = " + value)); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/actions/TransformAction.java b/core/citrus-base/src/main/java/org/citrusframework/actions/TransformAction.java index feed5818aa..39344fca8e 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/actions/TransformAction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/actions/TransformAction.java @@ -67,7 +67,7 @@ public class TransformAction extends AbstractTestAction { private final String targetVariable; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TransformAction.class); + private static final Logger logger = LoggerFactory.getLogger(TransformAction.class); /** * Default constructor. @@ -87,8 +87,8 @@ public TransformAction(Builder builder) { @Override public void doExecute(TestContext context) { try { - if (LOG.isDebugEnabled()) { - LOG.debug("Starting XSLT transformation"); + if (logger.isDebugEnabled()) { + logger.debug("Starting XSLT transformation"); } //parse XML document and define XML source for transformation @@ -124,7 +124,7 @@ public void doExecute(TestContext context) { transformer.transform(xmlSource, result); context.setVariable(targetVariable, result.toString()); - LOG.info("Finished XSLT transformation"); + logger.info("Finished XSLT transformation"); } catch (IOException | TransformerException e) { throw new CitrusRuntimeException(e); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/annotations/CitrusAnnotations.java b/core/citrus-base/src/main/java/org/citrusframework/annotations/CitrusAnnotations.java index 14ce1cdf76..4d326ebeb9 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/annotations/CitrusAnnotations.java +++ b/core/citrus-base/src/main/java/org/citrusframework/annotations/CitrusAnnotations.java @@ -44,7 +44,7 @@ public abstract class CitrusAnnotations { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusAnnotations.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusAnnotations.class); /** * Prevent instantiation. @@ -105,7 +105,7 @@ public static void injectCitrusFramework(final Object testCase, final Citrus cit ReflectionUtils.doWithFields(testCase.getClass(), new ReflectionUtils.FieldCallback() { @Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { - LOG.trace(String.format("Injecting Citrus framework instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting Citrus framework instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, testCase, citrusFramework); } }, new ReflectionUtils.FieldFilter() { @@ -132,7 +132,7 @@ public boolean matches(Field field) { */ public static void injectCitrusContext(final Object target, final CitrusContext context) { ReflectionUtils.doWithFields(target.getClass(), field -> { - LOG.trace(String.format("Injecting Citrus context instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting Citrus context instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, context); }, field -> { if (field.isAnnotationPresent(CitrusResource.class) && CitrusContext.class.isAssignableFrom(field.getType())) { @@ -156,7 +156,7 @@ public static void injectTestContext(final Object target, final TestContext cont ReflectionUtils.doWithFields(target.getClass(), field -> { Class type = field.getType(); if (TestContext.class.isAssignableFrom(type)) { - LOG.trace(String.format("Injecting test context instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting test context instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, context); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); @@ -183,7 +183,7 @@ public static void injectTestRunner(final Object target, final TestCaseRunner ru ReflectionUtils.doWithFields(target.getClass(), field -> { Class type = field.getType(); if (TestCaseRunner.class.isAssignableFrom(type)) { - LOG.trace(String.format("Injecting test runner instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting test runner instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, runner); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); @@ -213,7 +213,7 @@ private static void injectTestActionRunner(final Object target, final TestAction ReflectionUtils.doWithFields(target.getClass(), field -> { Class type = field.getType(); if (TestActionRunner.class.isAssignableFrom(type)) { - LOG.trace(String.format("Injecting test action runner instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting test action runner instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, runner); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); @@ -240,7 +240,7 @@ private static void injectGherkinTestActionRunner(final Object target, final Ghe ReflectionUtils.doWithFields(target.getClass(), field -> { Class type = field.getType(); if (GherkinTestActionRunner.class.isAssignableFrom(type)) { - LOG.trace(String.format("Injecting test action runner instance on test class field '%s'", field.getName())); + logger.trace(String.format("Injecting test action runner instance on test class field '%s'", field.getName())); ReflectionUtils.setField(field, target, runner); } else { throw new CitrusRuntimeException("Not able to provide a Citrus resource injection for type " + type); diff --git a/core/citrus-base/src/main/java/org/citrusframework/condition/ActionCondition.java b/core/citrus-base/src/main/java/org/citrusframework/condition/ActionCondition.java index 492db43832..89d8cc2e8d 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/condition/ActionCondition.java +++ b/core/citrus-base/src/main/java/org/citrusframework/condition/ActionCondition.java @@ -30,7 +30,7 @@ public class ActionCondition extends AbstractCondition { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ActionCondition.class); + private static final Logger logger = LoggerFactory.getLogger(ActionCondition.class); /** Action to execute */ private TestAction action; @@ -63,7 +63,7 @@ public boolean isSatisfied(TestContext context) { action.execute(context); } catch (Exception e) { this.caughtException = e; - log.warn(String.format("Nested action did not perform as expected - %s", Optional.ofNullable(e.getMessage()) + logger.warn(String.format("Nested action did not perform as expected - %s", Optional.ofNullable(e.getMessage()) .map(msg -> e.getClass().getName() + ": " + msg) .orElse(e.getClass().getName()))); return false; diff --git a/core/citrus-base/src/main/java/org/citrusframework/condition/FileCondition.java b/core/citrus-base/src/main/java/org/citrusframework/condition/FileCondition.java index a4d365095b..808fe74fd3 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/condition/FileCondition.java +++ b/core/citrus-base/src/main/java/org/citrusframework/condition/FileCondition.java @@ -37,7 +37,7 @@ public class FileCondition extends AbstractCondition { private File file; /** Logger */ - private static Logger log = LoggerFactory.getLogger(FileCondition.class); + private static final Logger logger = LoggerFactory.getLogger(FileCondition.class); /** * Default constructor. @@ -48,8 +48,8 @@ public FileCondition() { @Override public boolean isSatisfied(TestContext context) { - if (log.isDebugEnabled()) { - log.debug(String.format("Checking file path '%s'", file != null ? file.getPath() : filePath)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Checking file path '%s'", file != null ? file.getPath() : filePath)); } if (file != null) { @@ -58,7 +58,7 @@ public boolean isSatisfied(TestContext context) { try { return FileUtils.getFileResource(context.replaceDynamicContentInString(filePath), context).getFile().isFile(); } catch (IOException e) { - log.warn(String.format("Failed to access file resource '%s'", e.getMessage())); + logger.warn(String.format("Failed to access file resource '%s'", e.getMessage())); return false; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/condition/HttpCondition.java b/core/citrus-base/src/main/java/org/citrusframework/condition/HttpCondition.java index 93953bf574..300ad89852 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/condition/HttpCondition.java +++ b/core/citrus-base/src/main/java/org/citrusframework/condition/HttpCondition.java @@ -46,7 +46,7 @@ public class HttpCondition extends AbstractCondition { private String method = "HEAD"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(HttpCondition.class); + private static final Logger logger = LoggerFactory.getLogger(HttpCondition.class); /** * Default constructor. @@ -77,8 +77,8 @@ public String getErrorMessage(TestContext context) { */ private int invokeUrl(TestContext context) { URL contextUrl = getUrl(context); - if (log.isDebugEnabled()) { - log.debug(String.format("Probing Http request url '%s'", contextUrl.toExternalForm())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Probing Http request url '%s'", contextUrl.toExternalForm())); } int responseCode = -1; @@ -91,7 +91,7 @@ private int invokeUrl(TestContext context) { responseCode = httpURLConnection.getResponseCode(); } catch (IOException e) { - log.warn(String.format("Could not access Http url '%s' - %s", contextUrl.toExternalForm(), e.getMessage())); + logger.warn(String.format("Could not access Http url '%s' - %s", contextUrl.toExternalForm(), e.getMessage())); } finally { if (httpURLConnection != null) { httpURLConnection.disconnect(); diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractActionContainer.java b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractActionContainer.java index 3fc706d19d..0028f8a764 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractActionContainer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractActionContainer.java @@ -40,7 +40,7 @@ public abstract class AbstractActionContainer extends AbstractTestAction implements TestActionContainer, Completable { /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** List of nested actions */ protected List> actions = new ArrayList<>(); @@ -107,8 +107,8 @@ public boolean isDone(TestContext context) { for (TestAction action : new ArrayList<>(executedActions)) { if (action instanceof Completable && !((Completable) action).isDone(context)) { - if (log.isDebugEnabled()) { - log.debug(Optional.ofNullable(action.getName()).filter(name -> name.trim().length() > 0) + if (logger.isDebugEnabled()) { + logger.debug(Optional.ofNullable(action.getName()).filter(name -> name.trim().length() > 0) .orElse(action.getClass().getName()) + " not completed yet"); } return false; diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractSuiteActionContainer.java b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractSuiteActionContainer.java index b5d217cee1..0764836bb0 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractSuiteActionContainer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractSuiteActionContainer.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; import org.springframework.util.StringUtils; @@ -33,6 +35,9 @@ */ public abstract class AbstractSuiteActionContainer extends AbstractActionContainer { + /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(AbstractSuiteActionContainer.class); + /** List of suite names that match for this container */ private List suiteNames = new ArrayList<>(); @@ -56,19 +61,19 @@ public boolean shouldExecute(String suiteName, String[] includedGroups) { if (StringUtils.hasText(suiteName) && !CollectionUtils.isEmpty(suiteNames) && ! suiteNames.contains(suiteName)) { - log.warn(String.format(baseErrorMessage, "suite name", getName())); + logger.warn(String.format(baseErrorMessage, "suite name", getName())); return false; } if (!checkTestGroups(includedGroups)) { - log.warn(String.format(baseErrorMessage, "test groups", getName())); + logger.warn(String.format(baseErrorMessage, "test groups", getName())); return false; } for (Map.Entry envEntry : env.entrySet()) { if (!System.getenv().containsKey(envEntry.getKey()) || (StringUtils.hasText(envEntry.getValue()) && !System.getenv().get(envEntry.getKey()).equals(envEntry.getValue()))) { - log.warn(String.format(baseErrorMessage, "env properties", getName())); + logger.warn(String.format(baseErrorMessage, "env properties", getName())); return false; } } @@ -76,7 +81,7 @@ public boolean shouldExecute(String suiteName, String[] includedGroups) { for (Map.Entry systemProperty : systemProperties.entrySet()) { if (!System.getProperties().containsKey(systemProperty.getKey()) || (StringUtils.hasText(systemProperty.getValue()) && !System.getProperties().get(systemProperty.getKey()).equals(systemProperty.getValue()))) { - log.warn(String.format(baseErrorMessage, "system properties", getName())); + logger.warn(String.format(baseErrorMessage, "system properties", getName())); return false; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractTestBoundaryActionContainer.java b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractTestBoundaryActionContainer.java index 26a64ac230..027fc3b3d5 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/AbstractTestBoundaryActionContainer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/AbstractTestBoundaryActionContainer.java @@ -21,6 +21,8 @@ import java.util.List; import java.util.Map; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.PatternMatchUtils; import org.springframework.util.StringUtils; @@ -33,6 +35,9 @@ */ public abstract class AbstractTestBoundaryActionContainer extends AbstractActionContainer { + /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(AbstractTestBoundaryActionContainer.class); + /** Test case name pattern that this sequence container matches with */ private String namePattern; @@ -60,27 +65,27 @@ public boolean shouldExecute(String testName, String packageName, String[] inclu if (StringUtils.hasText(packageNamePattern)) { if (!PatternMatchUtils.simpleMatch(packageNamePattern, packageName)) { - log.warn(String.format(baseErrorMessage, "test package", getName())); + logger.warn(String.format(baseErrorMessage, "test package", getName())); return false; } } if (StringUtils.hasText(namePattern)) { if (!PatternMatchUtils.simpleMatch(namePattern, testName)) { - log.warn(String.format(baseErrorMessage, "test name", getName())); + logger.warn(String.format(baseErrorMessage, "test name", getName())); return false; } } if (!checkTestGroups(includedGroups)) { - log.warn(String.format(baseErrorMessage, "test groups", getName())); + logger.warn(String.format(baseErrorMessage, "test groups", getName())); return false; } for (Map.Entry envEntry : env.entrySet()) { if (!System.getenv().containsKey(envEntry.getKey()) || (StringUtils.hasText(envEntry.getValue()) && !System.getenv().get(envEntry.getKey()).equals(envEntry.getValue()))) { - log.warn(String.format(baseErrorMessage, "env properties", getName())); + logger.warn(String.format(baseErrorMessage, "env properties", getName())); return false; } } @@ -88,7 +93,7 @@ public boolean shouldExecute(String testName, String packageName, String[] inclu for (Map.Entry systemProperty : systemProperties.entrySet()) { if (!System.getProperties().containsKey(systemProperty.getKey()) || (StringUtils.hasText(systemProperty.getValue()) && !System.getProperties().get(systemProperty.getKey()).equals(systemProperty.getValue()))) { - log.warn(String.format(baseErrorMessage, "system properties", getName())); + logger.warn(String.format(baseErrorMessage, "system properties", getName())); return false; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Assert.java b/core/citrus-base/src/main/java/org/citrusframework/container/Assert.java index 84be485c74..4f77cc1213 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Assert.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Assert.java @@ -47,7 +47,7 @@ public class Assert extends AbstractActionContainer { private final String message; /** Logger */ - private static Logger log = LoggerFactory.getLogger(Assert.class); + private static final Logger logger = LoggerFactory.getLogger(Assert.class); /** * Default constructor. @@ -62,14 +62,14 @@ public Assert(Builder builder) { @Override public void doExecute(TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Assert container asserting exceptions of type " + exception); + if (logger.isDebugEnabled()) { + logger.debug("Assert container asserting exceptions of type " + exception); } try { executeAction(this.action.build(), context); } catch (Exception e) { - log.debug("Validating caught exception ..."); + logger.debug("Validating caught exception ..."); if (!exception.isAssignableFrom(e.getClass())) { throw new ValidationException("Validation failed for asserted exception type - expected: '" + @@ -85,10 +85,10 @@ public void doExecute(TestContext context) { } } - if (log.isDebugEnabled()) { - log.debug("Asserted exception is as expected: " + e.getClass() + ": " + e.getLocalizedMessage()); + if (logger.isDebugEnabled()) { + logger.debug("Asserted exception is as expected: " + e.getClass() + ": " + e.getLocalizedMessage()); } - log.info("Assert exception validation successful: All values OK"); + logger.info("Assert exception validation successful: All values OK"); return; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Async.java b/core/citrus-base/src/main/java/org/citrusframework/container/Async.java index aaf83e3bfc..aff4bcff9b 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Async.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Async.java @@ -37,7 +37,7 @@ public class Async extends AbstractActionContainer { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(Async.class); + private static final Logger logger = LoggerFactory.getLogger(Async.class); private final List> errorActions; private final List> successActions; @@ -51,7 +51,7 @@ public Async(Builder builder) { @Override public void doExecute(TestContext context) { - LOG.debug("Async container forking action execution ..."); + logger.debug("Async container forking action execution ..."); AbstractAsyncTestAction asyncTestAction = new AbstractAsyncTestAction() { @Override @@ -63,7 +63,7 @@ public void doExecuteAsync(TestContext context) { @Override public void onError(TestContext context, Throwable error) { - LOG.info("Apply error actions after async container ..."); + logger.info("Apply error actions after async container ..."); for (TestActionBuilder actionBuilder : errorActions) { TestAction action = actionBuilder.build(); action.execute(context); @@ -72,7 +72,7 @@ public void onError(TestContext context, Throwable error) { @Override public void onSuccess(TestContext context) { - LOG.info("Apply success actions after async container ..."); + logger.info("Apply success actions after async container ..."); for (TestActionBuilder actionBuilder : successActions) { TestAction action = actionBuilder.build(); action.execute(context); diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Catch.java b/core/citrus-base/src/main/java/org/citrusframework/container/Catch.java index 8d311ea2b1..db418b02f5 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Catch.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Catch.java @@ -33,7 +33,7 @@ public class Catch extends AbstractActionContainer { private final String exception; /** Logger */ - private static Logger log = LoggerFactory.getLogger(Catch.class); + private static final Logger logger = LoggerFactory.getLogger(Catch.class); /** * Default constructor. @@ -46,8 +46,8 @@ public Catch(Builder builder) { @Override public void doExecute(TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Catch container catching exceptions of type " + exception); + if (logger.isDebugEnabled()) { + logger.debug("Catch container catching exceptions of type " + exception); } for (TestActionBuilder actionBuilder: actions) { @@ -55,7 +55,7 @@ public void doExecute(TestContext context) { executeAction(actionBuilder.build(), context); } catch (Exception e) { if (exception != null && exception.equals(e.getClass().getName())) { - log.info("Caught exception " + e.getClass() + ": " + e.getLocalizedMessage()); + logger.info("Caught exception " + e.getClass() + ": " + e.getLocalizedMessage()); continue; } throw new CitrusRuntimeException(e); diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Conditional.java b/core/citrus-base/src/main/java/org/citrusframework/container/Conditional.java index 1e7f3f8d5b..86b1caa8d6 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Conditional.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Conditional.java @@ -34,7 +34,7 @@ public class Conditional extends AbstractActionContainer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(Conditional.class); + private static final Logger logger = LoggerFactory.getLogger(Conditional.class); /** Boolean condition expression string */ private final String condition; @@ -55,13 +55,13 @@ public Conditional(Builder builder) { @Override public void doExecute(final TestContext context) { if (checkCondition(context)) { - log.debug("Condition [ {} ] evaluates to true, executing nested actions", condition); + logger.debug("Condition [ {} ] evaluates to true, executing nested actions", condition); for (TestActionBuilder actionBuilder : actions) { executeAction(actionBuilder.build(), context); } } else { - log.debug("Condition [ {} ] evaluates to false, not executing nested actions", condition); + logger.debug("Condition [ {} ] evaluates to false, not executing nested actions", condition); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Parallel.java b/core/citrus-base/src/main/java/org/citrusframework/container/Parallel.java index ae50d4eb9f..b745ef2805 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Parallel.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Parallel.java @@ -45,7 +45,7 @@ public class Parallel extends AbstractActionContainer { private final List exceptions = new ArrayList<>(); /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(Parallel.class); + private static final Logger logger = LoggerFactory.getLogger(Parallel.class); /** * Default constructor. @@ -67,7 +67,7 @@ public void doExecute(TestContext context) { try { threads.pop().join(); } catch (InterruptedException e) { - LOG.error("Unable to join thread", e); + logger.error("Unable to join thread", e); } } @@ -106,10 +106,10 @@ public void run() { try { action.execute(context); } catch (CitrusRuntimeException e) { - LOG.error("Parallel test action raised error", e); + logger.error("Parallel test action raised error", e); exceptionHandler.accept(e); } catch (Exception | AssertionError e) { - LOG.error("Parallel test action raised error", e); + logger.error("Parallel test action raised error", e); exceptionHandler.accept(new CitrusRuntimeException(e)); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/RepeatOnErrorUntilTrue.java b/core/citrus-base/src/main/java/org/citrusframework/container/RepeatOnErrorUntilTrue.java index 755cb8fba6..933bfd0158 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/RepeatOnErrorUntilTrue.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/RepeatOnErrorUntilTrue.java @@ -38,7 +38,7 @@ public class RepeatOnErrorUntilTrue extends AbstractIteratingActionContainer { private final Long autoSleep; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(RepeatOnErrorUntilTrue.class); + private static final Logger logger = LoggerFactory.getLogger(RepeatOnErrorUntilTrue.class); /** * Default constructor. @@ -61,7 +61,7 @@ public void executeIteration(TestContext context) { } catch (CitrusRuntimeException e) { exception = e; - LOG.info("Caught exception of type " + e.getClass().getName() + " '" + + logger.info("Caught exception of type " + e.getClass().getName() + " '" + e.getMessage() + "' - performing retry #" + index); doAutoSleep(); @@ -70,7 +70,7 @@ public void executeIteration(TestContext context) { } if (exception != null) { - LOG.info("All retries failed - raising exception " + exception.getClass().getName()); + logger.info("All retries failed - raising exception " + exception.getClass().getName()); throw exception; } } @@ -80,15 +80,15 @@ public void executeIteration(TestContext context) { */ private void doAutoSleep() { if (autoSleep > 0) { - LOG.info("Sleeping " + autoSleep + " milliseconds"); + logger.info("Sleeping " + autoSleep + " milliseconds"); try { Thread.sleep(autoSleep); } catch (InterruptedException e) { - LOG.error("Error during doc generation", e); + logger.error("Error during doc generation", e); } - LOG.info("Returning after " + autoSleep + " milliseconds"); + logger.info("Returning after " + autoSleep + " milliseconds"); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Sequence.java b/core/citrus-base/src/main/java/org/citrusframework/container/Sequence.java index 63c22ae8fa..0d606c27fc 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Sequence.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Sequence.java @@ -31,7 +31,7 @@ public class Sequence extends AbstractActionContainer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(Sequence.class); + private static final Logger logger = LoggerFactory.getLogger(Sequence.class); /** * Default constructor. @@ -46,7 +46,7 @@ public void doExecute(TestContext context) { executeAction(actionBuilder.build(), context); } - log.debug("Action sequence finished successfully"); + logger.debug("Action sequence finished successfully"); } /** diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterSuite.java b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterSuite.java index c210b7ff5a..df0a94effb 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterSuite.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterSuite.java @@ -33,17 +33,17 @@ public class SequenceAfterSuite extends AbstractSuiteActionContainer implements AfterSuite { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SequenceAfterSuite.class); + private static final Logger logger = LoggerFactory.getLogger(SequenceAfterSuite.class); @Override public void doExecute(TestContext context) { boolean success = true; - log.info("Entering after suite block"); + logger.info("Entering after suite block"); - if (log.isDebugEnabled()) { - log.debug("Executing " + actions.size() + " actions after suite"); - log.debug(""); + if (logger.isDebugEnabled()) { + logger.debug("Executing " + actions.size() + " actions after suite"); + logger.debug(""); } for (TestActionBuilder actionBuilder : actions) { @@ -52,8 +52,8 @@ public void doExecute(TestContext context) { /* Executing test action and validate its success */ action.execute(context); } catch (Exception e) { - log.error("After suite action failed " + action.getName() + "Nested exception is: ", e); - log.error("Continue after suite actions"); + logger.error("After suite action failed " + action.getName() + "Nested exception is: ", e); + logger.error("Continue after suite actions"); success = false; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterTest.java b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterTest.java index 528f9802ad..95da484509 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterTest.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceAfterTest.java @@ -33,7 +33,7 @@ public class SequenceAfterTest extends AbstractTestBoundaryActionContainer implements AfterTest { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SequenceAfterTest.class); + private static final Logger logger = LoggerFactory.getLogger(SequenceAfterTest.class); @Override public void doExecute(TestContext context) { @@ -41,11 +41,11 @@ public void doExecute(TestContext context) { return; } - LOG.info("Entering after test block"); + logger.info("Entering after test block"); - if (LOG.isDebugEnabled()) { - LOG.debug("Executing " + actions.size() + " actions after test"); - LOG.debug(""); + if (logger.isDebugEnabled()) { + logger.debug("Executing " + actions.size() + " actions after test"); + logger.debug(""); } for (TestActionBuilder actionBuilder : actions) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeSuite.java b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeSuite.java index 2c459f1b32..d0d30c3b7d 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeSuite.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeSuite.java @@ -33,15 +33,15 @@ public class SequenceBeforeSuite extends AbstractSuiteActionContainer implements BeforeSuite { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SequenceBeforeSuite.class); + private static final Logger logger = LoggerFactory.getLogger(SequenceBeforeSuite.class); @Override public void doExecute(TestContext context) { - LOG.info("Entering before suite block"); + logger.info("Entering before suite block"); - if (LOG.isDebugEnabled()) { - LOG.debug("Executing " + actions.size() + " actions before suite"); - LOG.debug(""); + if (logger.isDebugEnabled()) { + logger.debug("Executing " + actions.size() + " actions before suite"); + logger.debug(""); } for (TestActionBuilder actionBuilder : actions) { @@ -50,7 +50,7 @@ public void doExecute(TestContext context) { /* Executing test action and validate its success */ action.execute(context); } catch (Exception e) { - LOG.error("Task failed " + action.getName() + "Nested exception is: ", e); + logger.error("Task failed " + action.getName() + "Nested exception is: ", e); throw new CitrusRuntimeException(e); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeTest.java b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeTest.java index 64158c76b3..8373deaa79 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeTest.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/SequenceBeforeTest.java @@ -33,7 +33,7 @@ public class SequenceBeforeTest extends AbstractTestBoundaryActionContainer implements BeforeTest { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SequenceBeforeTest.class); + private static final Logger logger = LoggerFactory.getLogger(SequenceBeforeTest.class); @Override public void doExecute(TestContext context) { @@ -41,11 +41,11 @@ public void doExecute(TestContext context) { return; } - LOG.info("Entering before test block"); + logger.info("Entering before test block"); - if (LOG.isDebugEnabled()) { - LOG.debug("Executing " + actions.size() + " actions before test"); - LOG.debug(""); + if (logger.isDebugEnabled()) { + logger.debug("Executing " + actions.size() + " actions before test"); + logger.debug(""); } for (TestActionBuilder actionBuilder : actions) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Template.java b/core/citrus-base/src/main/java/org/citrusframework/container/Template.java index c213d2365c..7853c365b4 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Template.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Template.java @@ -73,7 +73,7 @@ public class Template extends AbstractTestAction { private final boolean globalContext; /** Logger */ - private static final Logger log = LoggerFactory.getLogger(Template.class); + private static final Logger logger = LoggerFactory.getLogger(Template.class); /** * Default constructor @@ -92,8 +92,8 @@ public Template(AbstractTemplateBuilder builder) { @Override public void doExecute(TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Executing template '" + getName() + "' with " + actions.size() + " embedded actions"); + if (logger.isDebugEnabled()) { + logger.debug("Executing template '" + getName() + "' with " + actions.size() + " embedded actions"); } TestContext innerContext; @@ -132,8 +132,8 @@ public void doExecute(TestContext context) { paramValue = FunctionUtils.resolveFunction(paramValue, context); } - if (log.isDebugEnabled()) { - log.debug("Setting parameter for template " + param + "=" + paramValue); + if (logger.isDebugEnabled()) { + logger.debug("Setting parameter for template " + param + "=" + paramValue); } innerContext.setVariable(param, paramValue); @@ -143,7 +143,7 @@ public void doExecute(TestContext context) { action.build().execute(innerContext); } - log.info("Template was executed successfully"); + logger.info("Template was executed successfully"); } /** diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/TemplateLoader.java b/core/citrus-base/src/main/java/org/citrusframework/container/TemplateLoader.java index 1e28cb9518..26034207bf 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/TemplateLoader.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/TemplateLoader.java @@ -15,7 +15,7 @@ public interface TemplateLoader extends ReferenceResolverAware { /** Logger */ - Logger LOG = LoggerFactory.getLogger(Function.class); + Logger logger = LoggerFactory.getLogger(Function.class); /** Function resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/template/loader"; @@ -37,7 +37,7 @@ static Optional lookup(String name) { TemplateLoader instance = TYPE_RESOLVER.resolve(name); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve template loader from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn(String.format("Failed to resolve template loader from resource '%s/%s'", RESOURCE_PATH, name)); } return Optional.empty(); diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Timer.java b/core/citrus-base/src/main/java/org/citrusframework/container/Timer.java index fa3ac3bb59..ed5f4b91e4 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Timer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Timer.java @@ -34,7 +34,7 @@ */ public class Timer extends AbstractActionContainer implements StopTimer { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(Timer.class); + private static final Logger logger = LoggerFactory.getLogger(Timer.class); private final static AtomicInteger nextSerialNumber = new AtomicInteger(0); @@ -87,13 +87,13 @@ public void run() { try { indexCount++; updateIndexCountInTestContext(context); - log.debug(String.format("Timer event fired #%s - executing nested actions", indexCount)); + logger.debug(String.format("Timer event fired #%s - executing nested actions", indexCount)); for (TestActionBuilder actionBuilder : actions) { executeAction(actionBuilder.build(), context); } if (indexCount >= repeatCount) { - log.debug(String.format("Timer complete: %s iterations reached", repeatCount)); + logger.debug(String.format("Timer complete: %s iterations reached", repeatCount)); stopTimer(); } } catch (Exception e) { @@ -111,7 +111,7 @@ private void handleException(Exception e) { } else { timerException = new CitrusRuntimeException(e); } - log.error(String.format("Timer stopped as a result of nested action error (%s)", e.getMessage())); + logger.error(String.format("Timer stopped as a result of nested action error (%s)", e.getMessage())); stopTimer(); if (fork) { @@ -125,7 +125,7 @@ private void handleException(Exception e) { try { Thread.sleep(interval); } catch (InterruptedException e) { - log.warn("Interrupted while waiting for timer to complete", e); + logger.warn("Interrupted while waiting for timer to complete", e); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/container/Wait.java b/core/citrus-base/src/main/java/org/citrusframework/container/Wait.java index 3694905e9e..892f4907f3 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/container/Wait.java +++ b/core/citrus-base/src/main/java/org/citrusframework/container/Wait.java @@ -47,7 +47,7 @@ public class Wait extends AbstractTestAction { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(Wait.class); + private static final Logger logger = LoggerFactory.getLogger(Wait.class); /** Condition to be met */ private final Condition condition; @@ -84,8 +84,8 @@ public void doExecute(final TestContext context) { while (timeLeft > 0) { timeLeft -= intervalMs; - if (log.isDebugEnabled()) { - log.debug(String.format("Waiting for condition %s", condition.getName())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Waiting for condition %s", condition.getName())); } ExecutorService executor = Executors.newSingleThreadExecutor(); @@ -94,12 +94,12 @@ public void doExecute(final TestContext context) { try { conditionSatisfied = future.get(intervalMs, TimeUnit.MILLISECONDS); } catch (InterruptedException | TimeoutException | ExecutionException e) { - log.warn(String.format("Condition check interrupted with '%s'", e.getClass().getSimpleName())); + logger.warn(String.format("Condition check interrupted with '%s'", e.getClass().getSimpleName())); } executor.shutdown(); if (Boolean.TRUE.equals(conditionSatisfied)) { - log.info(condition.getSuccessMessage(context)); + logger.info(condition.getSuccessMessage(context)); return; } @@ -108,7 +108,7 @@ public void doExecute(final TestContext context) { try { Thread.sleep(sleepTime); } catch (InterruptedException e) { - log.warn("Interrupted during wait!", e); + logger.warn("Interrupted during wait!", e); } } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/context/TestContextFactory.java b/core/citrus-base/src/main/java/org/citrusframework/context/TestContextFactory.java index 8062500020..2765421a92 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/context/TestContextFactory.java +++ b/core/citrus-base/src/main/java/org/citrusframework/context/TestContextFactory.java @@ -27,8 +27,8 @@ import org.citrusframework.endpoint.DefaultEndpointFactory; import org.citrusframework.endpoint.EndpointFactory; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.DefaultLogModifier; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.DefaultLogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.message.MessageProcessors; import org.citrusframework.report.MessageListeners; import org.citrusframework.report.TestActionListeners; diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/AbstractEndpointAdapter.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/AbstractEndpointAdapter.java index fa0cf7672a..1fb09fe219 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/AbstractEndpointAdapter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/AbstractEndpointAdapter.java @@ -39,7 +39,7 @@ public abstract class AbstractEndpointAdapter implements EndpointAdapter { private TestContextFactory testContextFactory; /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); @Override public final Message handleMessage(Message request) { @@ -47,12 +47,12 @@ public final Message handleMessage(Message request) { if ((replyMessage == null || replyMessage.getPayload() == null)) { if (fallbackEndpointAdapter != null) { - log.debug("Did not receive reply message - " + logger.debug("Did not receive reply message - " + "delegating to fallback endpoint adapter"); replyMessage = fallbackEndpointAdapter.handleMessage(request); } else { - log.debug("Did not receive reply message - no response is simulated"); + logger.debug("Did not receive reply message - no response is simulated"); } } @@ -113,7 +113,7 @@ public void setTestContextFactory(TestContextFactory testContextFactory) { */ public TestContextFactory getTestContextFactory() { if (testContextFactory == null) { - log.warn("Could not identify proper test context factory from Spring bean application context - constructing own test context factory. " + + logger.warn("Could not identify proper test context factory from Spring bean application context - constructing own test context factory. " + "This restricts test context capabilities to an absolute minimum! You could do better when enabling the root application context for this server instance."); testContextFactory = TestContextFactory.newInstance(); diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectConsumer.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectConsumer.java index a1308aa052..733818203c 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectConsumer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectConsumer.java @@ -18,7 +18,7 @@ public class DirectConsumer extends AbstractSelectiveMessageConsumer { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(DirectConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(DirectConsumer.class); /** Endpoint configuration */ private final DirectEndpointConfiguration endpointConfiguration; @@ -44,8 +44,8 @@ public Message receive(String selector, TestContext context, long timeout) { destinationQueueName = getDestinationQueueName(); } - if (log.isDebugEnabled()) { - log.debug(String.format("Receiving message from queue: '%s'", destinationQueueName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Receiving message from queue: '%s'", destinationQueueName)); } Message message; @@ -69,7 +69,7 @@ public Message receive(String selector, TestContext context, long timeout) { throw new MessageTimeoutException(timeout, destinationQueueName); } - log.info(String.format("Received message from queue: '%s'", destinationQueueName)); + logger.info(String.format("Received message from queue: '%s'", destinationQueueName)); return message; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectEndpointAdapter.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectEndpointAdapter.java index 57bccbbe34..bcd4a0454e 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectEndpointAdapter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectEndpointAdapter.java @@ -25,7 +25,7 @@ public class DirectEndpointAdapter extends AbstractEndpointAdapter { private final DirectSyncEndpointConfiguration endpointConfiguration; /** Logger */ - private static final Logger log = LoggerFactory.getLogger(DirectEndpointAdapter.class); + private static final Logger logger = LoggerFactory.getLogger(DirectEndpointAdapter.class); /** * Default constructor using endpoint. @@ -53,7 +53,7 @@ public DirectEndpointAdapter(DirectSyncEndpointConfiguration endpointConfigurati @Override public Message handleMessageInternal(Message request) { - log.debug("Forwarding request to message queue ..."); + logger.debug("Forwarding request to message queue ..."); TestContext context = getTestContext(); Message replyMessage = null; @@ -65,7 +65,7 @@ public Message handleMessageInternal(Message request) { replyMessage = producer.receive(context, endpointConfiguration.getTimeout()); } } catch (ActionTimeoutException e) { - log.warn(e.getMessage()); + logger.warn(e.getMessage()); } return replyMessage; diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectProducer.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectProducer.java index 82f5ab49d1..16327c67d0 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectProducer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectProducer.java @@ -14,7 +14,7 @@ */ public class DirectProducer implements Producer { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(DirectProducer.class); + private static final Logger logger = LoggerFactory.getLogger(DirectProducer.class); /** The producer name */ private final String name; @@ -36,12 +36,12 @@ public DirectProducer(String name, DirectEndpointConfiguration endpointConfigura public void send(Message message, TestContext context) { String destinationQueueName = getDestinationQueueName(); - if (log.isDebugEnabled()) { - log.debug(String.format("Sending message to queue: '%s'", destinationQueueName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Sending message to queue: '%s'", destinationQueueName)); } - if (log.isDebugEnabled()) { - log.debug("Message to send is:" + System.getProperty("line.separator") + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Message to send is:" + System.getProperty("line.separator") + message.toString()); } try { @@ -50,7 +50,7 @@ public void send(Message message, TestContext context) { throw new CitrusRuntimeException(String.format("Failed to send message to queue: '%s'", destinationQueueName), e); } - log.info(String.format("Message was sent to queue: '%s'", destinationQueueName)); + logger.info(String.format("Message was sent to queue: '%s'", destinationQueueName)); } /** diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncConsumer.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncConsumer.java index ba478268d2..2da2103f69 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncConsumer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncConsumer.java @@ -16,7 +16,7 @@ */ public class DirectSyncConsumer extends DirectConsumer implements ReplyProducer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DirectSyncConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(DirectSyncConsumer.class); /** Reply channel store */ private CorrelationManager correlationManager; @@ -53,13 +53,13 @@ public void send(Message message, TestContext context) { MessageQueue replyQueue = correlationManager.find(correlationKey, endpointConfiguration.getTimeout()); Assert.notNull(replyQueue, "Failed to find reply channel for message correlation key: " + correlationKey); - if (log.isDebugEnabled()) { - log.debug("Sending message to reply channel: '" + replyQueue + "'"); - log.debug("Message to send is:\n" + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to reply channel: '" + replyQueue + "'"); + logger.debug("Message to send is:\n" + message.toString()); } replyQueue.send(message); - log.info("Message was sent to reply channel: '" + replyQueue + "'"); + logger.info("Message was sent to reply channel: '" + replyQueue + "'"); } /** @@ -81,7 +81,7 @@ public void saveReplyMessageQueue(Message receivedMessage, TestContext context) correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, replyQueue); } else { - log.warn("Unable to retrieve reply message channel for message \n" + + logger.warn("Unable to retrieve reply message channel for message \n" + receivedMessage + "\n - no reply channel found in message headers!"); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncProducer.java b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncProducer.java index aa0f08af36..465dec9720 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncProducer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/endpoint/direct/DirectSyncProducer.java @@ -19,7 +19,7 @@ */ public class DirectSyncProducer extends DirectProducer implements ReplyConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DirectSyncProducer.class); + private static final Logger logger = LoggerFactory.getLogger(DirectSyncProducer.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -48,12 +48,12 @@ public void send(Message message, TestContext context) { String destinationQueueName = getDestinationQueueName(); - if (log.isDebugEnabled()) { - log.debug("Sending message to queue: '" + destinationQueueName + "'"); - log.debug("Message to send is:\n" + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to queue: '" + destinationQueueName + "'"); + logger.debug("Message to send is:\n" + message.toString()); } - log.info("Message was sent to queue: '" + destinationQueueName + "'"); + logger.info("Message was sent to queue: '" + destinationQueueName + "'"); MessageQueue replyQueue = getReplyQueue(message, context); getDestinationQueue(context).send(message); @@ -62,7 +62,7 @@ public void send(Message message, TestContext context) { if (replyMessage == null) { throw new ReplyMessageTimeoutException(endpointConfiguration.getTimeout(), destinationQueueName); } else { - log.info("Received synchronous response from reply queue"); + logger.info("Received synchronous response from reply queue"); } correlationManager.store(correlationKey, replyMessage); diff --git a/core/citrus-base/src/main/java/org/citrusframework/functions/DefaultFunctionLibrary.java b/core/citrus-base/src/main/java/org/citrusframework/functions/DefaultFunctionLibrary.java index 77efb1f0a1..63633a4003 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/functions/DefaultFunctionLibrary.java +++ b/core/citrus-base/src/main/java/org/citrusframework/functions/DefaultFunctionLibrary.java @@ -41,7 +41,7 @@ public class DefaultFunctionLibrary extends FunctionLibrary { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DefaultFunctionLibrary.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultFunctionLibrary.class); /** * Default constructor adding default function implementations. @@ -91,8 +91,8 @@ public DefaultFunctionLibrary() { private void lookupFunctions() { Function.lookup().forEach((k, m) -> { getMembers().put(k, m); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Register function '%s' as %s", k, m.getClass())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Register function '%s' as %s", k, m.getClass())); } }); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/functions/core/ChangeDateFunction.java b/core/citrus-base/src/main/java/org/citrusframework/functions/core/ChangeDateFunction.java index 2b8d85bd14..f6756776ff 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/functions/core/ChangeDateFunction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/functions/core/ChangeDateFunction.java @@ -38,7 +38,7 @@ public class ChangeDateFunction extends AbstractDateFunction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ChangeDateFunction.class); + private static final Logger logger = LoggerFactory.getLogger(ChangeDateFunction.class); /** * @see org.citrusframework.functions.Function#execute(java.util.List, org.citrusframework.context.TestContext) @@ -73,7 +73,7 @@ public String execute(List parameterList, TestContext context) { try { result = dateFormat.format(calendar.getTime()); } catch (RuntimeException e) { - log.error("Error while formatting dateParameter value ", e); + logger.error("Error while formatting dateParameter value ", e); throw new CitrusRuntimeException(e); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/functions/core/CurrentDateFunction.java b/core/citrus-base/src/main/java/org/citrusframework/functions/core/CurrentDateFunction.java index e3d7d76a3a..399c265a66 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/functions/core/CurrentDateFunction.java +++ b/core/citrus-base/src/main/java/org/citrusframework/functions/core/CurrentDateFunction.java @@ -35,7 +35,7 @@ public class CurrentDateFunction extends AbstractDateFunction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CurrentDateFunction.class); + private static final Logger logger = LoggerFactory.getLogger(CurrentDateFunction.class); /** * @see org.citrusframework.functions.Function#execute(java.util.List, org.citrusframework.context.TestContext) @@ -60,7 +60,7 @@ public String execute(List parameterList, TestContext context) { try { result = dateFormat.format(calendar.getTime()); } catch (RuntimeException e) { - log.error("Error while formatting date value ", e); + logger.error("Error while formatting date value ", e); throw new CitrusRuntimeException(e); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/log/DefaultLogModifier.java b/core/citrus-base/src/main/java/org/citrusframework/log/DefaultLogModifier.java index 0236e254eb..8317e5bf21 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/log/DefaultLogModifier.java +++ b/core/citrus-base/src/main/java/org/citrusframework/log/DefaultLogModifier.java @@ -17,7 +17,7 @@ * limitations under the License. */ -package org.citrusframework.log; +package org.citrusframework.logger; import java.util.Set; import java.util.regex.Pattern; @@ -26,7 +26,7 @@ import org.citrusframework.CitrusSettings; /** - * Default modifier implementation uses regular expressions to mask log output. + * Default modifier implementation uses regular expressions to mask logger output. * Regular expressions match on default keywords. * * @author Christoph Deppisch diff --git a/core/citrus-base/src/main/java/org/citrusframework/main/scan/ClassPathTestScanner.java b/core/citrus-base/src/main/java/org/citrusframework/main/scan/ClassPathTestScanner.java index 840cd17ba6..fe8694eba2 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/main/scan/ClassPathTestScanner.java +++ b/core/citrus-base/src/main/java/org/citrusframework/main/scan/ClassPathTestScanner.java @@ -44,7 +44,7 @@ public class ClassPathTestScanner extends AbstractTestScanner { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ClassPathTestScanner.class); + private static final Logger logger = LoggerFactory.getLogger(ClassPathTestScanner.class); /** Test annotation marking test classes and methods */ private final Class annotationType; @@ -104,7 +104,7 @@ protected boolean isIncluded(ClassMetadata metadata) { ReflectionUtils.doWithMethods(clazz, method -> hasTestMethod.set(true), method -> AnnotationUtils.findAnnotation(method, annotationType) != null); return hasTestMethod.get(); } catch (NoClassDefFoundError | ClassNotFoundException e) { - LOG.warn("Unable to access class: " + metadata.getClassName()); + logger.warn("Unable to access class: " + metadata.getClassName()); return false; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/main/scan/JarFileTestScanner.java b/core/citrus-base/src/main/java/org/citrusframework/main/scan/JarFileTestScanner.java index 4c893d3487..05dadbdffd 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/main/scan/JarFileTestScanner.java +++ b/core/citrus-base/src/main/java/org/citrusframework/main/scan/JarFileTestScanner.java @@ -38,7 +38,7 @@ public class JarFileTestScanner extends AbstractTestScanner { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(JarFileTestScanner.class); + private static final Logger logger = LoggerFactory.getLogger(JarFileTestScanner.class); /** Jar file resource to search in */ private final File artifact; @@ -57,7 +57,7 @@ public List findTestsInPackage(String packageToScan) { JarEntry entry = entries.nextElement(); String className = StringUtils.stripFilenameExtension(entry.getName()).replace( "/", "." ); if (new AntPathMatcher().matchStart(packageToScan.replace( ".", "/" ), entry.getName()) && isIncluded(className)) { - LOG.info("Found test class candidate in test jar file: " + entry.getName()); + logger.info("Found test class candidate in test jar file: " + entry.getName()); testClasses.add(new TestClass(className)); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/message/DefaultMessageQueue.java b/core/citrus-base/src/main/java/org/citrusframework/message/DefaultMessageQueue.java index 558cb8a12c..2aa317f13a 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/message/DefaultMessageQueue.java +++ b/core/citrus-base/src/main/java/org/citrusframework/message/DefaultMessageQueue.java @@ -30,7 +30,7 @@ public class DefaultMessageQueue implements MessageQueue { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DefaultMessageQueue.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultMessageQueue.class); /** Logger */ private static final Logger RETRY_LOG = LoggerFactory.getLogger("org.citrusframework.RetryLogger"); @@ -100,11 +100,11 @@ public void purge(MessageSelector selector) { Message message = (Message) o; if (selector.accept(message)) { if (this.queue.remove(message)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Purged message '%s' from in memory queue", message.getId())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Purged message '%s' from in memory queue", message.getId())); } } else { - log.warn(String.format("Failed to purge message '%s' from in memory queue", message.getId())); + logger.warn(String.format("Failed to purge message '%s' from in memory queue", message.getId())); } } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/message/ZipMessage.java b/core/citrus-base/src/main/java/org/citrusframework/message/ZipMessage.java index 9d6e2d3a42..d422bb768c 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/message/ZipMessage.java +++ b/core/citrus-base/src/main/java/org/citrusframework/message/ZipMessage.java @@ -35,7 +35,7 @@ public class ZipMessage extends DefaultMessage { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ZipMessage.class); + private static final Logger logger = LoggerFactory.getLogger(ZipMessage.class); /** Entries in this zip message */ private final List entries = new ArrayList<>(); @@ -119,7 +119,7 @@ public ZipMessage addEntry(Entry entry) { private void addToZip(String path, Entry entry, ZipOutputStream zos) throws IOException { String name = (path.endsWith("/") ? path : path + "/") + entry.getName(); if (entry.isDirectory()) { - log.debug("Adding directory to zip: " + name); + logger.debug("Adding directory to zip: " + name); zos.putNextEntry(new ZipEntry(name.endsWith("/") ? name : name + "/")); for (Entry child : entry.getEntries()) { @@ -131,7 +131,7 @@ private void addToZip(String path, Entry entry, ZipOutputStream zos) throws IOEx } zos.closeEntry(); } else { - log.debug("Adding file to zip: " + name); + logger.debug("Adding file to zip: " + name); zos.putNextEntry(new ZipEntry(name)); zos.write(entry.getContent()); diff --git a/core/citrus-base/src/main/java/org/citrusframework/message/correlation/DefaultCorrelationManager.java b/core/citrus-base/src/main/java/org/citrusframework/message/correlation/DefaultCorrelationManager.java index c336df2a9d..51f2b58137 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/message/correlation/DefaultCorrelationManager.java +++ b/core/citrus-base/src/main/java/org/citrusframework/message/correlation/DefaultCorrelationManager.java @@ -31,15 +31,15 @@ public class DefaultCorrelationManager implements CorrelationManager { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DefaultCorrelationManager.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultCorrelationManager.class); /** Map of managed objects */ private ObjectStore objectStore = new DefaultObjectStore(); @Override public void saveCorrelationKey(String correlationKeyName, String correlationKey, TestContext context) { - if (log.isDebugEnabled()) { - log.debug(String.format("Saving correlation key for '%s'", correlationKeyName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Saving correlation key for '%s'", correlationKeyName)); } context.setVariable(correlationKeyName, correlationKey); @@ -47,8 +47,8 @@ public void saveCorrelationKey(String correlationKeyName, String correlationKey, @Override public String getCorrelationKey(String correlationKeyName, TestContext context) { - if (log.isDebugEnabled()) { - log.debug(String.format("Get correlation key for '%s'", correlationKeyName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Get correlation key for '%s'", correlationKeyName)); } if (context.getVariables().containsKey(correlationKeyName)) { @@ -61,12 +61,12 @@ public String getCorrelationKey(String correlationKeyName, TestContext context) @Override public void store(String correlationKey, T object) { if (object == null) { - log.warn(String.format("Ignore correlated null object for '%s'", correlationKey)); + logger.warn(String.format("Ignore correlated null object for '%s'", correlationKey)); return; } - if (log.isDebugEnabled()) { - log.debug(String.format("Saving correlated object for '%s'", correlationKey)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Saving correlated object for '%s'", correlationKey)); } objectStore.add(correlationKey, object); @@ -74,8 +74,8 @@ public void store(String correlationKey, T object) { @Override public T find(String correlationKey, long timeout) { - if (log.isDebugEnabled()) { - log.debug(String.format("Finding correlated object for '%s'", correlationKey)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Finding correlated object for '%s'", correlationKey)); } return objectStore.remove(correlationKey); diff --git a/core/citrus-base/src/main/java/org/citrusframework/message/correlation/PollingCorrelationManager.java b/core/citrus-base/src/main/java/org/citrusframework/message/correlation/PollingCorrelationManager.java index 9bc3c07d54..96ef3713eb 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/message/correlation/PollingCorrelationManager.java +++ b/core/citrus-base/src/main/java/org/citrusframework/message/correlation/PollingCorrelationManager.java @@ -37,7 +37,7 @@ public class PollingCorrelationManager extends DefaultCorrelationManager { private final PollableEndpointConfiguration endpointConfiguration; /** Logger */ - private static Logger log = LoggerFactory.getLogger(PollingCorrelationManager.class); + private static final Logger logger = LoggerFactory.getLogger(PollingCorrelationManager.class); /** Retry logger */ private static final Logger RETRY_LOG = LoggerFactory.getLogger("org.citrusframework.RetryLogger"); @@ -63,8 +63,8 @@ public T find(String correlationKey) { @Override public String getCorrelationKey(String correlationKeyName, TestContext context) { - if (log.isDebugEnabled()) { - log.debug(String.format("Get correlation key for '%s'", correlationKeyName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Get correlation key for '%s'", correlationKeyName)); } String correlationKey = null; @@ -126,7 +126,7 @@ public T find(String correlationKey, long timeout) { } /** - * Gets the retry log message + * Gets the retry logger message * @return */ public String getRetryLogMessage() { diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/AbstractOutputFileReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/AbstractOutputFileReporter.java index 475dd15b6f..4ca0906a3b 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/AbstractOutputFileReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/AbstractOutputFileReporter.java @@ -32,7 +32,7 @@ public abstract class AbstractOutputFileReporter extends AbstractTestReporter { /** Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractOutputFileReporter.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractOutputFileReporter.class); @Override public final void generate(TestResults testResults) { @@ -65,9 +65,9 @@ private void createReportFile(String reportFileName, String content) { try (Writer fileWriter = new FileWriter(new File(targetDirectory, reportFileName))) { fileWriter.append(content); fileWriter.flush(); - log.info("Generated test report: " + targetDirectory + File.separator + reportFileName); + logger.info("Generated test report: " + targetDirectory + File.separator + reportFileName); } catch (IOException e) { - log.error("Failed to create test report", e); + logger.error("Failed to create test report", e); } } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/AbstractTestReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/AbstractTestReporter.java index eddaf2fd7f..ea7361e749 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/AbstractTestReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/AbstractTestReporter.java @@ -26,7 +26,7 @@ public abstract class AbstractTestReporter implements TestReporter { /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** Should ignore errors when creating test report */ private boolean ignoreErrors = TestReporterSettings.isIgnoreErrors(); @@ -40,7 +40,7 @@ public final void generateReport(TestResults testResults) { generate(testResults); } catch (Exception e) { if (ignoreErrors) { - log.error("Failed to create test report", e); + logger.error("Failed to create test report", e); } else { throw e; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/FailureStackTestListener.java b/core/citrus-base/src/main/java/org/citrusframework/report/FailureStackTestListener.java index 43b9c20479..ae8d9617f4 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/FailureStackTestListener.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/FailureStackTestListener.java @@ -43,7 +43,7 @@ public class FailureStackTestListener extends AbstractTestListener { /** Logger */ - private static Logger log = LoggerFactory.getLogger(FailureStackTestListener.class); + private static final Logger logger = LoggerFactory.getLogger(FailureStackTestListener.class); @Override public void onTestFailure(TestCase test, Throwable cause) { @@ -82,7 +82,7 @@ public static List getFailureStack(final TestCase test) { reader.parse(new InputSource(testFileResource.getInputStream())); } catch (Exception e) { - log.warn("Failed to locate line numbers for failure stack trace", e); + logger.warn("Failed to locate line numbers for failure stack trace", e); } return failureStack; diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/HtmlReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/HtmlReporter.java index 5d2fd62fd5..96765fcd9f 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/HtmlReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/HtmlReporter.java @@ -46,7 +46,7 @@ public class HtmlReporter extends AbstractOutputFileReporter implements TestListener { /** Logger */ - private static Logger log = LoggerFactory.getLogger(HtmlReporter.class); + private static final Logger logger = LoggerFactory.getLogger(HtmlReporter.class); /** Map holding additional information of test cases */ private Map details = new HashMap<>(); @@ -76,7 +76,7 @@ public class HtmlReporter extends AbstractOutputFileReporter implements TestList public String getReportContent(TestResults testResults) { final StringBuilder reportDetails = new StringBuilder(); - log.debug("Generating HTML test report"); + logger.debug("Generating HTML test report"); try { final String testDetails = FileUtils.readToString(FileUtils.getFileResource(testDetailTemplate)); @@ -136,20 +136,20 @@ private String getLogoImageData() { os.write(contents); } } catch(IOException e) { - log.warn("Failed to add logo image data to HTML report", e); + logger.warn("Failed to add logo image data to HTML report", e); } finally { if (reader != null) { try { reader.close(); } catch(IOException ex) { - log.warn("Failed to close logo image resource for HTML report", ex); + logger.warn("Failed to close logo image resource for HTML report", ex); } } try { os.flush(); } catch(IOException ex) { - log.warn("Failed to flush logo image stream for HTML report", ex); + logger.warn("Failed to flush logo image stream for HTML report", ex); } } @@ -209,13 +209,13 @@ private String getCodeSnippetHtml(Throwable cause) { } } } catch (IOException e) { - log.error("Failed to construct HTML code snippet", e); + logger.error("Failed to construct HTML code snippet", e); } finally { if (reader != null) { try { reader.close(); } catch (IOException e) { - log.warn("Failed to close test file", e); + logger.warn("Failed to close test file", e); } } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/JUnitReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/JUnitReporter.java index b62f2707db..ebe3b80481 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/JUnitReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/JUnitReporter.java @@ -46,7 +46,7 @@ public class JUnitReporter extends AbstractTestReporter { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JUnitReporter.class); + private static final Logger logger = LoggerFactory.getLogger(JUnitReporter.class); /** Output directory */ private String outputDirectory = JUnitReporterSettings.getReportDirectory(); @@ -74,7 +74,7 @@ public void generate(TestResults testResults) { if (isEnabled()) { ReportTemplates reportTemplates = new ReportTemplates(); - log.debug("Generating JUnit test report"); + logger.debug("Generating JUnit test report"); try { List results = testResults.asList(); @@ -161,7 +161,7 @@ private void createReportFile(String reportFileName, String content, File target fileWriter.append(content); fileWriter.flush(); } catch (IOException e) { - log.error("Failed to create test report", e); + logger.error("Failed to create test report", e); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/LoggingReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/LoggingReporter.java index 0c9ec3d9a6..888e1a13c6 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/LoggingReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/LoggingReporter.java @@ -58,10 +58,10 @@ public class LoggingReporter extends AbstractTestReporter implements MessageList private static final Logger enabledOutboundMessageLogger = outboundMessageLogger; /** Logger */ - private static Logger log = LoggerFactory.getLogger(LoggingReporter.class); + private static Logger logger = LoggerFactory.getLogger(LoggingReporter.class); /** The standard logger used when the reporter is enabled */ - private static final Logger enabledLog = log; + private static final Logger enabledLog = logger; /** A {@link org.slf4j.helpers.NOPLogger} used in case the reporter is not enabled. */ private static final Logger noOpLogger = new NOPLoggerFactory().getLogger(LoggingReporter.class.getName()); @@ -276,7 +276,7 @@ private void newLine() { * @param line */ protected void info(String line) { - log.info(line); + logger.info(line); } /** @@ -285,7 +285,7 @@ protected void info(String line) { * @param cause */ protected void error(String line, Throwable cause) { - log.error(line, cause); + logger.error(line, cause); } /** @@ -294,7 +294,7 @@ protected void error(String line, Throwable cause) { */ protected void debug(String line) { if (isDebugEnabled()) { - log.debug(line); + logger.debug(line); } } @@ -303,7 +303,7 @@ protected void debug(String line) { * @return */ protected boolean isDebugEnabled() { - return log.isDebugEnabled(); + return logger.isDebugEnabled(); } /** @@ -311,17 +311,17 @@ protected boolean isDebugEnabled() { */ public void setEnabled(boolean enabled) { if (enabled) { - log = enabledLog; + logger = enabledLog; inboundMessageLogger = enabledInboundMessageLogger; outboundMessageLogger = enabledOutboundMessageLogger; } else { - log = noOpLogger; + logger = noOpLogger; inboundMessageLogger = noOpLogger; outboundMessageLogger = noOpLogger; } } protected boolean isEnabled() { - return log != noOpLogger; + return logger != noOpLogger; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/MessageTracingTestListener.java b/core/citrus-base/src/main/java/org/citrusframework/report/MessageTracingTestListener.java index cedb80ae05..dc323fdf45 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/MessageTracingTestListener.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/MessageTracingTestListener.java @@ -62,7 +62,7 @@ public class MessageTracingTestListener extends AbstractTestListener implements private final Object lockObject = new Object(); /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(MessageTracingTestListener.class); + private static final Logger logger = LoggerFactory.getLogger(MessageTracingTestListener.class); /** * {@inheritDoc} @@ -152,7 +152,7 @@ protected File getTraceFile(String testName) { File traceFile = new File(targetDirectory, filename); if (traceFile.exists()) { - LOG.warn(String.format("Trace file '%s' already exists. Normally a new file is created on each test execution ", traceFile.getName())); + logger.warn(String.format("Trace file '%s' already exists. Normally a new file is created on each test execution ", traceFile.getName())); } return traceFile; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/report/OutputStreamReporter.java b/core/citrus-base/src/main/java/org/citrusframework/report/OutputStreamReporter.java index be9a635a25..962fce7973 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/report/OutputStreamReporter.java +++ b/core/citrus-base/src/main/java/org/citrusframework/report/OutputStreamReporter.java @@ -29,7 +29,7 @@ public class OutputStreamReporter extends LoggingReporter { /** Logger */ - private static Logger log = LoggerFactory.getLogger(OutputStreamReporter.class); + private static final Logger logger = LoggerFactory.getLogger(OutputStreamReporter.class); /** Buffered writer to write logging events to */ private Writer logWriter; @@ -77,7 +77,7 @@ protected void error(String line, Throwable cause) { @Override protected boolean isDebugEnabled() { - return log.isDebugEnabled(); + return logger.isDebugEnabled(); } /** @@ -90,7 +90,7 @@ private synchronized void writeSafely(String level, String line) { logWriter.write(String.format(format, level ,line)); } catch (IOException e) { failedCounter.countDown(); - log.warn("Failed to write logging event to output stream", e); + logger.warn("Failed to write logging event to output stream", e); } } } @@ -114,7 +114,7 @@ public void setFormat(String format) { } /** - * Gets the log writer. + * Gets the logger writer. * * @return */ @@ -123,7 +123,7 @@ public Writer getLogWriter() { } /** - * Sets the log writer. + * Sets the logger writer. * @param writer */ protected void setLogWriter(Writer writer) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/server/AbstractServer.java b/core/citrus-base/src/main/java/org/citrusframework/server/AbstractServer.java index 28f7a4ea39..9d723f6f25 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/server/AbstractServer.java +++ b/core/citrus-base/src/main/java/org/citrusframework/server/AbstractServer.java @@ -75,7 +75,7 @@ public abstract class AbstractServer extends AbstractEndpoint private boolean debugLogging = false; /** Logger */ - private final Logger LOG = LoggerFactory.getLogger(getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** * Default constructor using endpoint configuration. @@ -86,8 +86,8 @@ public AbstractServer() { @Override public void start() { - if (LOG.isDebugEnabled()) { - LOG.debug("Starting server: " + getName() + " ..."); + if (logger.isDebugEnabled()) { + logger.debug("Starting server: " + getName() + " ..."); } startup(); @@ -100,14 +100,14 @@ public void start() { thread.setDaemon(false); thread.start(); - LOG.info("Started server: " + getName()); + logger.info("Started server: " + getName()); } @Override public void stop() { if (isRunning()) { - if (LOG.isDebugEnabled()) { - LOG.debug("Stopping server: " + getName() + " ..."); + if (logger.isDebugEnabled()) { + logger.debug("Stopping server: " + getName() + " ..."); } shutdown(); @@ -118,7 +118,7 @@ public void stop() { thread = null; - LOG.info("Stopped server: " + getName()); + logger.info("Stopped server: " + getName()); } } @@ -171,7 +171,7 @@ private TestContextFactory getTestContextFactory() { return referenceResolver.resolve(TestContextFactory.class); } - LOG.debug("Unable to create test context factory from Spring application context - " + + logger.debug("Unable to create test context factory from Spring application context - " + "using minimal test context factory"); return TestContextFactory.newInstance(); } @@ -190,7 +190,7 @@ public void join() { try { thread.join(); } catch (InterruptedException e) { - LOG.error("Error occured", e); + logger.error("Error occured", e); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/util/BooleanExpressionParser.java b/core/citrus-base/src/main/java/org/citrusframework/util/BooleanExpressionParser.java index d5627f0f59..d9b9ffa81a 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/util/BooleanExpressionParser.java +++ b/core/citrus-base/src/main/java/org/citrusframework/util/BooleanExpressionParser.java @@ -74,7 +74,7 @@ public String toString(){ /** * Logger */ - private static final Logger log = LoggerFactory.getLogger(BooleanExpressionParser.class); + private static final Logger logger = LoggerFactory.getLogger(BooleanExpressionParser.class); /** * Prevent instantiation. @@ -126,8 +126,8 @@ public static boolean evaluate(final String expression) { result = Boolean.valueOf(evaluateExpressionStack(operators, values)); - if (log.isDebugEnabled()) { - log.debug("Boolean expression {} evaluates to {}", expression, result); + if (logger.isDebugEnabled()) { + logger.debug("Boolean expression {} evaluates to {}", expression, result); } } catch (final NoSuchElementException e) { throw new CitrusRuntimeException("Unable to parse boolean expression '" + expression + "'. Maybe expression is incomplete!", e); diff --git a/core/citrus-base/src/main/java/org/citrusframework/util/FileUtils.java b/core/citrus-base/src/main/java/org/citrusframework/util/FileUtils.java index 0ac34d8eb5..b9048706d1 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/util/FileUtils.java +++ b/core/citrus-base/src/main/java/org/citrusframework/util/FileUtils.java @@ -54,7 +54,7 @@ public abstract class FileUtils { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(FileUtils.class); + private static final Logger logger = LoggerFactory.getLogger(FileUtils.class); public static final String FILE_EXTENSION_JAVA = ".java"; public static final String FILE_EXTENSION_XML = ".xml"; @@ -125,8 +125,8 @@ public static String readToString(Resource resource, Charset charset) throws IOE } } - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Reading file resource: '%s' (encoding is '%s')", resource.getFilename(), charset.displayName())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Reading file resource: '%s' (encoding is '%s')", resource.getFilename(), charset.displayName())); } return readToString(resource.getInputStream(), charset); } @@ -170,8 +170,8 @@ public static void writeToFile(String content, File file) { * @param file */ public static void writeToFile(String content, File file, Charset charset) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Writing file resource: '%s' (encoding is '%s')", file.getName(), charset.displayName())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Writing file resource: '%s' (encoding is '%s')", file.getName(), charset.displayName())); } if (!file.getParentFile().exists()) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/util/TestUtils.java b/core/citrus-base/src/main/java/org/citrusframework/util/TestUtils.java index 5d75ba4bab..d54cc05d42 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/util/TestUtils.java +++ b/core/citrus-base/src/main/java/org/citrusframework/util/TestUtils.java @@ -43,7 +43,7 @@ public abstract class TestUtils { public static final String WAIT_THREAD_PREFIX = "citrus-waiting-"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(TestUtils.class); + private static final Logger logger = LoggerFactory.getLogger(TestUtils.class); /** * Prevent instantiation. @@ -88,13 +88,13 @@ public static void waitForCompletion(final ScheduledExecutorService scheduledExe if (container.isDone(context)) { finished.complete(true); } else { - log.debug("Wait for test container to finish properly ..."); + logger.debug("Wait for test container to finish properly ..."); } } catch (Exception e) { - if (log.isDebugEnabled()) { - log.debug("Failed to wait for completion of nested test actions", e); + if (logger.isDebugEnabled()) { + logger.debug("Failed to wait for completion of nested test actions", e); } else { - log.warn(String.format("Failed to wait for completion of nested test actions because of %s", e.getMessage())); + logger.warn(String.format("Failed to wait for completion of nested test actions because of %s", e.getMessage())); } } }, 100L, timeout / 10, TimeUnit.MILLISECONDS); @@ -111,7 +111,7 @@ public static void waitForCompletion(final ScheduledExecutorService scheduledExe scheduledExecutor.shutdown(); scheduledExecutor.awaitTermination((timeout / 10) / 2, TimeUnit.MICROSECONDS); } catch (InterruptedException e) { - log.warn(String.format("Failed to await orderly termination of waiting tasks to complete, caused by %s", e.getMessage())); + logger.warn(String.format("Failed to await orderly termination of waiting tasks to complete, caused by %s", e.getMessage())); } if (!scheduledExecutor.isTerminated()) { diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultHeaderValidator.java b/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultHeaderValidator.java index c93d01827d..dd712a96ea 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultHeaderValidator.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultHeaderValidator.java @@ -36,7 +36,7 @@ public class DefaultHeaderValidator implements HeaderValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(DefaultHeaderValidator.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultHeaderValidator.class); /** Set of default header validators located via resource path lookup */ private static final Map DEFAULT_VALIDATORS = HeaderValidator.lookup(); @@ -79,8 +79,8 @@ public void validateHeader(String headerName, Object receivedValue, Object contr throw new ValidationException("Validation failed:", e); } - if (log.isDebugEnabled()) { - log.debug("Validating header element: " + headerName + "='" + expectedValue + "': OK."); + if (logger.isDebugEnabled()) { + logger.debug("Validating header element: " + headerName + "='" + expectedValue + "': OK."); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultMessageHeaderValidator.java b/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultMessageHeaderValidator.java index bef038409f..438e6cb758 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultMessageHeaderValidator.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/DefaultMessageHeaderValidator.java @@ -33,6 +33,8 @@ import org.citrusframework.message.MessageHeaderUtils; import org.citrusframework.message.MessageHeaders; import org.citrusframework.validation.context.HeaderValidationContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.util.CollectionUtils; /** @@ -43,6 +45,9 @@ */ public class DefaultMessageHeaderValidator extends AbstractMessageValidator { + /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(DefaultMessageHeaderValidator.class); + /** List of special header validators */ private List validators = new ArrayList<>(); @@ -56,7 +61,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes if (CollectionUtils.isEmpty(controlHeaders)) { return; } - log.debug("Start message header validation ..."); + logger.debug("Start message header validation ..."); for (Map.Entry entry : controlHeaders.entrySet()) { if (MessageHeaderUtils.isSpringInternalHeader(entry.getKey()) || @@ -85,7 +90,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes try { return context.getReferenceResolver().resolve(beanName, HeaderValidator.class); } catch (CitrusRuntimeException e) { - log.warn("Failed to resolve header validator for name: " + beanName); + logger.warn("Failed to resolve header validator for name: " + beanName); return null; } }) @@ -101,7 +106,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes ).validateHeader(headerName, receivedHeaders.get(headerName), controlValue, context, validationContext); } - log.info("Message header validation successful: All values OK"); + logger.info("Message header validation successful: All values OK"); } /** @@ -145,7 +150,7 @@ private String getHeaderName(String name, Map receivedHeaders, T validationContext.isHeaderNameIgnoreCase()) { String key = headerName; - log.debug(String.format("Finding case insensitive header for key '%s'", key)); + logger.debug(String.format("Finding case insensitive header for key '%s'", key)); headerName = receivedHeaders .entrySet() @@ -155,7 +160,7 @@ private String getHeaderName(String name, Map receivedHeaders, T .findFirst() .orElseThrow(() -> new ValidationException("Validation failed: No matching header for key '" + key + "'")); - log.info(String.format("Found matching case insensitive header name: %s", headerName)); + logger.info(String.format("Found matching case insensitive header name: %s", headerName)); } return headerName; diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/DelegatingPayloadVariableExtractor.java b/core/citrus-base/src/main/java/org/citrusframework/validation/DelegatingPayloadVariableExtractor.java index fbf0444401..88c67dcb4b 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/DelegatingPayloadVariableExtractor.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/DelegatingPayloadVariableExtractor.java @@ -45,7 +45,7 @@ public class DelegatingPayloadVariableExtractor implements VariableExtractor { private Map namespaces; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DelegatingPayloadVariableExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(DelegatingPayloadVariableExtractor.class); public DelegatingPayloadVariableExtractor() { this(new Builder()); @@ -61,8 +61,8 @@ public DelegatingPayloadVariableExtractor(Builder builder) { public void extractVariables(Message message, TestContext context) { if (CollectionUtils.isEmpty(pathExpressions)) {return;} - if (LOG.isDebugEnabled()) { - LOG.debug("Reading path elements."); + if (logger.isDebugEnabled()) { + logger.debug("Reading path elements."); } Map jsonPathExpressions = new LinkedHashMap<>(); diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/interceptor/AbstractMessageConstructionInterceptor.java b/core/citrus-base/src/main/java/org/citrusframework/validation/interceptor/AbstractMessageConstructionInterceptor.java index d5ed296020..80dd1dcaad 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/interceptor/AbstractMessageConstructionInterceptor.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/interceptor/AbstractMessageConstructionInterceptor.java @@ -34,7 +34,7 @@ public abstract class AbstractMessageConstructionInterceptor implements MessageConstructionInterceptor { /** Logger */ - private Logger log = LoggerFactory.getLogger(this.getClass()); + private final Logger logger = LoggerFactory.getLogger(getClass()); /** Inbound/Outbound direction */ private MessageDirection direction = MessageDirection.UNBOUND; @@ -44,7 +44,7 @@ public Message interceptMessageConstruction(Message message, String messageType, if (supportsMessageType(messageType)) { return interceptMessage(message, messageType, context); } else { - log.debug(String.format("Message interceptor type '%s' skipped for message type: %s", getName(), messageType)); + logger.debug(String.format("Message interceptor type '%s' skipped for message type: %s", getName(), messageType)); return message; } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/DefaultValidationMatcherLibrary.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/DefaultValidationMatcherLibrary.java index 7cfa77b064..7b693aa199 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/DefaultValidationMatcherLibrary.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/DefaultValidationMatcherLibrary.java @@ -31,7 +31,7 @@ public class DefaultValidationMatcherLibrary extends ValidationMatcherLibrary { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DefaultValidationMatcherLibrary.class); + private static final Logger logger = LoggerFactory.getLogger(DefaultValidationMatcherLibrary.class); /** * Default constructor adds default matcher implementations. @@ -71,8 +71,8 @@ public DefaultValidationMatcherLibrary() { private void lookupValidationMatchers() { ValidationMatcher.lookup().forEach((k, m) -> { getMembers().put(k, m); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Register message matcher '%s' as %s", k, m.getClass())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Register message matcher '%s' as %s", k, m.getClass())); } }); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/CreateVariableValidationMatcher.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/CreateVariableValidationMatcher.java index 4eb107e4c0..c940ce4eb8 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/CreateVariableValidationMatcher.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/CreateVariableValidationMatcher.java @@ -34,7 +34,7 @@ public class CreateVariableValidationMatcher implements ValidationMatcher { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CreateVariableValidationMatcher.class); + private static final Logger logger = LoggerFactory.getLogger(CreateVariableValidationMatcher.class); @Override public void validate(String fieldName, String value, List controlParameters, TestContext context) throws ValidationException { @@ -44,7 +44,7 @@ public void validate(String fieldName, String value, List controlParamet name = controlParameters.get(0); } - log.info("Setting variable: " + name + " to value: " + value); + logger.info("Setting variable: " + name + " to value: " + value); context.setVariable(name, value); } diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/DateRangeValidationMatcher.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/DateRangeValidationMatcher.java index 360fb1286f..6eb35dc22c 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/DateRangeValidationMatcher.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/DateRangeValidationMatcher.java @@ -42,13 +42,13 @@ public class DateRangeValidationMatcher implements ValidationMatcher { /** * Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DateRangeValidationMatcher.class); + private static final Logger logger = LoggerFactory.getLogger(DateRangeValidationMatcher.class); private static final String FALLBACK_DATE_PATTERN = "yyyy-MM-dd"; @Override public void validate(String fieldName, String value, List params, TestContext context) throws ValidationException { - LOG.debug(String.format( + logger.debug(String.format( "Validating date range for date '%s' using control data: %s", value, ValidationMatcherUtils.getParameterListAsString(params))); diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/IgnoreValidationMatcher.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/IgnoreValidationMatcher.java index c85fe8d5a9..be1c4d4f03 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/IgnoreValidationMatcher.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/IgnoreValidationMatcher.java @@ -31,12 +31,12 @@ public class IgnoreValidationMatcher implements ValidationMatcher { /** Logger */ - private static Logger log = LoggerFactory.getLogger(IgnoreValidationMatcher.class); + private static final Logger logger = LoggerFactory.getLogger(IgnoreValidationMatcher.class); @Override public void validate(String fieldName, String value, List controlParameters, TestContext context) throws ValidationException { - if (log.isDebugEnabled()) { - log.debug(String.format("Ignoring value for field '%s'", fieldName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Ignoring value for field '%s'", fieldName)); } } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/WeekdayValidationMatcher.java b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/WeekdayValidationMatcher.java index a07c8dd61b..af0a653bf9 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/WeekdayValidationMatcher.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/matcher/core/WeekdayValidationMatcher.java @@ -47,7 +47,7 @@ public class WeekdayValidationMatcher implements ValidationMatcher, ControlExpre /** * Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WeekdayValidationMatcher.class); + private static final Logger logger = LoggerFactory.getLogger(WeekdayValidationMatcher.class); @Override public void validate(String fieldName, String value, List controlParameters, TestContext context) throws ValidationException { @@ -72,7 +72,7 @@ public void validate(String fieldName, String value, List controlParamet cal.setTime(dateFormat.parse(value)); if (cal.get(Calendar.DAY_OF_WEEK) == Weekday.valueOf(weekday).getConstantValue()) { - LOG.info("Weekday validation matcher successful - All values OK"); + logger.info("Weekday validation matcher successful - All values OK"); } else { throw new ValidationException(this.getClass().getSimpleName() + " failed for field '" + fieldName + "'" + ". Received invalid week day '" + value + "', expected date to be a '" + weekday + "'"); diff --git a/core/citrus-base/src/main/java/org/citrusframework/validation/script/sql/SqlResultSetScriptValidator.java b/core/citrus-base/src/main/java/org/citrusframework/validation/script/sql/SqlResultSetScriptValidator.java index 7fcd74c956..e22db71348 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/validation/script/sql/SqlResultSetScriptValidator.java +++ b/core/citrus-base/src/main/java/org/citrusframework/validation/script/sql/SqlResultSetScriptValidator.java @@ -36,7 +36,7 @@ public interface SqlResultSetScriptValidator { /** Logger */ - Logger LOG = LoggerFactory.getLogger(SqlResultSetScriptValidator.class); + Logger logger = LoggerFactory.getLogger(SqlResultSetScriptValidator.class); /** Message validator resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/sql/result-set/validator"; @@ -52,8 +52,8 @@ public interface SqlResultSetScriptValidator { static Map lookup() { Map validators = TYPE_RESOLVER.resolveAll("", TypeResolver.DEFAULT_TYPE_PROPERTY, "name"); - if (LOG.isDebugEnabled()) { - validators.forEach((k, v) -> LOG.debug(String.format("Found SQL result set validator '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + validators.forEach((k, v) -> logger.debug(String.format("Found SQL result set validator '%s' as %s", k, v.getClass()))); } return validators; } diff --git a/core/citrus-base/src/main/java/org/citrusframework/variable/dictionary/AbstractDataDictionary.java b/core/citrus-base/src/main/java/org/citrusframework/variable/dictionary/AbstractDataDictionary.java index 0c3a89e86b..6611b59288 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/variable/dictionary/AbstractDataDictionary.java +++ b/core/citrus-base/src/main/java/org/citrusframework/variable/dictionary/AbstractDataDictionary.java @@ -36,7 +36,7 @@ public abstract class AbstractDataDictionary extends AbstractMessageProcessor implements DataDictionary { /** Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractDataDictionary.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractDataDictionary.class); /** Data dictionary name */ private String name = getClass().getSimpleName(); @@ -74,8 +74,8 @@ protected V convertIfNecessary(String value, V originalValue, TestContext co public void initialize() { if (mappingFile != null) { - if (log.isDebugEnabled()) { - log.debug("Reading data dictionary mapping " + mappingFile.getFilename()); + if (logger.isDebugEnabled()) { + logger.debug("Reading data dictionary mapping " + mappingFile.getFilename()); } Properties props; @@ -88,19 +88,19 @@ public void initialize() { for (Map.Entry entry : props.entrySet()) { String key = entry.getKey().toString(); - if (log.isDebugEnabled()) { - log.debug("Loading data dictionary mapping: " + key + "=" + props.getProperty(key)); + if (logger.isDebugEnabled()) { + logger.debug("Loading data dictionary mapping: " + key + "=" + props.getProperty(key)); } - if (log.isDebugEnabled() && mappings.containsKey(key)) { - log.debug("Overwriting data dictionary mapping " + key + " old value:" + mappings.get(key) + if (logger.isDebugEnabled() && mappings.containsKey(key)) { + logger.debug("Overwriting data dictionary mapping " + key + " old value:" + mappings.get(key) + " new value:" + props.getProperty(key)); } mappings.put(key, props.getProperty(key)); } - log.debug("Loaded data dictionary mapping " + mappingFile.getFilename()); + logger.debug("Loaded data dictionary mapping " + mappingFile.getFilename()); } } diff --git a/core/citrus-base/src/main/java/org/citrusframework/xml/Jaxb2Marshaller.java b/core/citrus-base/src/main/java/org/citrusframework/xml/Jaxb2Marshaller.java index 25e6c0739b..7c8eff6af9 100644 --- a/core/citrus-base/src/main/java/org/citrusframework/xml/Jaxb2Marshaller.java +++ b/core/citrus-base/src/main/java/org/citrusframework/xml/Jaxb2Marshaller.java @@ -51,7 +51,7 @@ public class Jaxb2Marshaller implements Marshaller, Unmarshaller { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(Jaxb2Marshaller.class); + private static final Logger logger = LoggerFactory.getLogger(Jaxb2Marshaller.class); private volatile JAXBContext jaxbContext; private final Schema schema; @@ -121,7 +121,7 @@ private jakarta.xml.bind.Marshaller createMarshaller() throws JAXBException { try { marshaller.setProperty(k, v); } catch (PropertyException e) { - log.warn(String.format("Unable to set marshaller property %s=%s", k, v)); + logger.warn(String.format("Unable to set marshaller property %s=%s", k, v)); } }); @@ -141,8 +141,8 @@ private jakarta.xml.bind.Unmarshaller createUnmarshaller() throws JAXBException private JAXBContext getOrCreateContext() throws JAXBException { if (jaxbContext == null) { synchronized (this) { - if (log.isDebugEnabled()) { - log.debug(String.format("Creating JAXBContext with bound classes %s", Arrays.toString(classesToBeBound))); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Creating JAXBContext with bound classes %s", Arrays.toString(classesToBeBound))); } if (classesToBeBound != null) { @@ -163,8 +163,8 @@ public void setProperty(String key, Object value) { } private Schema loadSchema(Resource... schemas) { - if (log.isDebugEnabled()) { - log.debug(String.format("Using marshaller validation schemas '%s'", StringUtils.arrayToCommaDelimitedString(schemas))); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Using marshaller validation schemas '%s'", StringUtils.arrayToCommaDelimitedString(schemas))); } try { diff --git a/core/citrus-base/src/test/java/org/citrusframework/actions/AbstractAsyncTestActionTest.java b/core/citrus-base/src/test/java/org/citrusframework/actions/AbstractAsyncTestActionTest.java index 5521a89244..0f832e5b50 100644 --- a/core/citrus-base/src/test/java/org/citrusframework/actions/AbstractAsyncTestActionTest.java +++ b/core/citrus-base/src/test/java/org/citrusframework/actions/AbstractAsyncTestActionTest.java @@ -35,7 +35,7 @@ public class AbstractAsyncTestActionTest extends UnitTestSupport { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(AbstractAsyncTestActionTest.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractAsyncTestActionTest.class); @Test public void testOnSuccess() throws Exception { @@ -44,7 +44,7 @@ public void testOnSuccess() throws Exception { new AbstractAsyncTestAction() { @Override public void doExecuteAsync(TestContext context) { - LOG.info("Success!"); + logger.info("Success!"); } @Override diff --git a/core/citrus-base/src/test/java/org/citrusframework/container/AsyncTest.java b/core/citrus-base/src/test/java/org/citrusframework/container/AsyncTest.java index 9fe5a36fd4..b67efe5cec 100644 --- a/core/citrus-base/src/test/java/org/citrusframework/container/AsyncTest.java +++ b/core/citrus-base/src/test/java/org/citrusframework/container/AsyncTest.java @@ -46,7 +46,7 @@ public class AsyncTest extends UnitTestSupport { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(AsyncTest.class); + private static final Logger logger = LoggerFactory.getLogger(AsyncTest.class); private final TestAction action = Mockito.mock(TestAction.class); private final TestAction success = Mockito.mock(TestAction.class); @@ -163,7 +163,7 @@ private void waitForDone(Async container, TestContext context, long timeout) thr if (container.isDone(context)) { done.complete(true); } else { - LOG.debug("Async action execution not finished yet ..."); + logger.debug("Async action execution not finished yet ..."); } }, 100, timeout / 10, TimeUnit.MILLISECONDS); diff --git a/core/citrus-base/src/test/java/org/citrusframework/container/TimerTest.java b/core/citrus-base/src/test/java/org/citrusframework/container/TimerTest.java index 6ae2c18ad8..79f6aeba6d 100644 --- a/core/citrus-base/src/test/java/org/citrusframework/container/TimerTest.java +++ b/core/citrus-base/src/test/java/org/citrusframework/container/TimerTest.java @@ -39,7 +39,7 @@ public class TimerTest extends UnitTestSupport { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TimerTest.class); + private static final Logger logger = LoggerFactory.getLogger(TimerTest.class); private TestAction action = Mockito.mock(TestAction.class); private int defaultRepeatCount = 3; @@ -134,7 +134,7 @@ private void allowForkedTimerToComplete(long sleepTime) { try { Thread.currentThread().sleep(sleepTime + 1000L); } catch (InterruptedException e) { - LOG.error("Interrupted while waiting for forked timer", e); + logger.error("Interrupted while waiting for forked timer", e); } } diff --git a/core/citrus-base/src/test/java/org/citrusframework/log/DefaultLogModifierTest.java b/core/citrus-base/src/test/java/org/citrusframework/log/DefaultLogModifierTest.java index 60247dd43c..244932e3bf 100644 --- a/core/citrus-base/src/test/java/org/citrusframework/log/DefaultLogModifierTest.java +++ b/core/citrus-base/src/test/java/org/citrusframework/log/DefaultLogModifierTest.java @@ -17,7 +17,7 @@ * limitations under the License. */ -package org.citrusframework.log; +package org.citrusframework.logger; import org.citrusframework.CitrusSettings; import org.testng.Assert; diff --git a/core/citrus-base/src/test/java/org/citrusframework/util/InvocationDummy.java b/core/citrus-base/src/test/java/org/citrusframework/util/InvocationDummy.java index fe8cae2850..343087ba5d 100644 --- a/core/citrus-base/src/test/java/org/citrusframework/util/InvocationDummy.java +++ b/core/citrus-base/src/test/java/org/citrusframework/util/InvocationDummy.java @@ -27,64 +27,64 @@ public class InvocationDummy { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(InvocationDummy.class); + private static final Logger logger = LoggerFactory.getLogger(InvocationDummy.class); public InvocationDummy() { - if (log.isDebugEnabled()) { - log.debug("Constructor without argument"); + if (logger.isDebugEnabled()) { + logger.debug("Constructor without argument"); } } public InvocationDummy(String arg) { - if (log.isDebugEnabled()) { - log.debug("Constructor with argument: " + arg); + if (logger.isDebugEnabled()) { + logger.debug("Constructor with argument: " + arg); } } public InvocationDummy(Integer arg1, String arg2, Boolean arg3) { - if (log.isDebugEnabled()) { - if (log.isDebugEnabled()) { - log.debug("Constructor with arguments:"); - log.debug("arg1: " + arg1); - log.debug("arg2: " + arg2); - log.debug("arg3: " + arg3); + if (logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { + logger.debug("Constructor with arguments:"); + logger.debug("arg1: " + arg1); + logger.debug("arg2: " + arg2); + logger.debug("arg3: " + arg3); } } } public void invoke() { - if (log.isDebugEnabled()) { - log.debug("Methode invoke no arguments"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke no arguments"); } } public void invoke(String text) { - if (log.isDebugEnabled()) { - log.debug("Methode invoke with string argument: '" + text + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with string argument: '" + text + "'"); } } public void invoke(String[] args) { for (int i = 0; i < args.length; i++) { - if (log.isDebugEnabled()) { - log.debug("Methode invoke with argument: " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with argument: " + args[i]); } } } public void invoke(Integer arg1, String arg2, Boolean arg3) { - if (log.isDebugEnabled()) { - log.debug("Method invoke with arguments:"); - log.debug("arg1: " + arg1); - log.debug("arg2: " + arg2); - log.debug("arg3: " + arg3); + if (logger.isDebugEnabled()) { + logger.debug("Method invoke with arguments:"); + logger.debug("arg1: " + arg1); + logger.debug("arg2: " + arg2); + logger.debug("arg3: " + arg3); } } public static void main(String[] args) { for (int i = 0; i < args.length; i++) { - if (log.isDebugEnabled()) { - log.debug("arg" + i + ": " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("arg" + i + ": " + args[i]); } } } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/CitrusSpringContext.java b/core/citrus-spring/src/main/java/org/citrusframework/CitrusSpringContext.java index 511d182e98..25d85bbaeb 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/CitrusSpringContext.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/CitrusSpringContext.java @@ -8,7 +8,7 @@ import org.citrusframework.container.BeforeSuite; import org.citrusframework.context.TestContextFactoryBean; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.report.MessageListeners; import org.citrusframework.report.TestActionListeners; import org.citrusframework.report.TestListeners; diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusNamespaceParserRegistry.java b/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusNamespaceParserRegistry.java index 182ad494f8..65dad1fbae 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusNamespaceParserRegistry.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusNamespaceParserRegistry.java @@ -35,7 +35,7 @@ public final class CitrusNamespaceParserRegistry { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusNamespaceParserRegistry.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusNamespaceParserRegistry.class); /** Resource path where to find custom parsers via lookup */ private static final String RESOURCE_PATH = "META-INF/citrus/action/parser"; @@ -121,7 +121,7 @@ public static BeanDefinitionParser getBeanParser(String name) { try { BEAN_PARSER.put(name, TYPE_RESOLVER.resolve(name)); } catch (Exception e) { - LOG.warn(String.format("Unable to locate bean parser for '%s'", name), e); + logger.warn(String.format("Unable to locate bean parser for '%s'", name), e); } } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusSpringConfig.java b/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusSpringConfig.java index 1536ec8e32..2d4c8785bd 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusSpringConfig.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/CitrusSpringConfig.java @@ -21,8 +21,8 @@ import org.citrusframework.endpoint.DefaultEndpointFactory; import org.citrusframework.endpoint.EndpointFactory; import org.citrusframework.functions.FunctionConfig; -import org.citrusframework.log.DefaultLogModifier; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.DefaultLogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.report.FailureStackTestListener; import org.citrusframework.report.MessageListenersFactory; import org.citrusframework.report.TestActionListenersFactory; diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/ComponentLifecycleProcessor.java b/core/citrus-spring/src/main/java/org/citrusframework/config/ComponentLifecycleProcessor.java index e446ca5834..abb4a88e60 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/ComponentLifecycleProcessor.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/ComponentLifecycleProcessor.java @@ -40,7 +40,7 @@ public class ComponentLifecycleProcessor implements DestructionAwareBeanPostProc private ReferenceResolver referenceResolver; /** Logger */ - private final static Logger LOG = LoggerFactory.getLogger(ComponentLifecycleProcessor.class); + private static final Logger logger = LoggerFactory.getLogger(ComponentLifecycleProcessor.class); @Override public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { @@ -53,8 +53,8 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro } if (bean instanceof InitializingPhase) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Initializing component '%s'", beanName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Initializing component '%s'", beanName)); } ((InitializingPhase) bean).initialize(); } @@ -65,8 +65,8 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) thro @Override public void postProcessBeforeDestruction(Object bean, String beanName) throws BeansException { if (requiresDestruction(bean)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Destroying component '%s'", beanName)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Destroying component '%s'", beanName)); } ((ShutdownPhase) bean).destroy(); } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/handler/CitrusConfigNamespaceHandler.java b/core/citrus-spring/src/main/java/org/citrusframework/config/handler/CitrusConfigNamespaceHandler.java index 26d4ed61e8..16c4626fdd 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/handler/CitrusConfigNamespaceHandler.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/handler/CitrusConfigNamespaceHandler.java @@ -52,7 +52,7 @@ public class CitrusConfigNamespaceHandler extends NamespaceHandlerSupport { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusConfigNamespaceHandler.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusConfigNamespaceHandler.class); @Override public void init() { @@ -89,8 +89,8 @@ private void lookupBeanDefinitionParser() { actionParserMap.forEach((k, p) -> { registerBeanDefinitionParser(k, p); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Register bean definition parser %s from resource %s", p.getClass(), k)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Register bean definition parser %s from resource %s", p.getClass(), k)); } }); } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaParser.java b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaParser.java index d0c6fc1de1..9b7a9927f7 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaParser.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaParser.java @@ -37,7 +37,7 @@ public class SchemaParser implements BeanDefinitionParser { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SchemaParser.class); + private static final Logger logger = LoggerFactory.getLogger(SchemaParser.class); /** Resource path where to find custom schema parsers via lookup */ private static final String RESOURCE_PATH = "META-INF/citrus/schema/parser"; @@ -69,7 +69,7 @@ private BeanDefinitionParser lookupSchemaParser(String location) { } BeanDefinitionParser parser = TYPE_RESOLVER.resolve(fileExtension); - log.info(String.format("Found schema bean definition parser %s from resource %s", parser.getClass(), RESOURCE_PATH + "/" + fileExtension)); + logger.info(String.format("Found schema bean definition parser %s from resource %s", parser.getClass(), RESOURCE_PATH + "/" + fileExtension)); SCHEMA_PARSER.put(fileExtension, parser); return parser; } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaRepositoryParser.java b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaRepositoryParser.java index bda17d7787..2c487951a9 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaRepositoryParser.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/SchemaRepositoryParser.java @@ -43,7 +43,7 @@ public class SchemaRepositoryParser implements BeanDefinitionParser { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SchemaRepositoryParser.class); + private static final Logger logger = LoggerFactory.getLogger(SchemaRepositoryParser.class); private static final String LOCATION = "location"; private static final String LOCATIONS = "locations"; @@ -85,7 +85,7 @@ private BeanDefinitionParser lookupSchemaRepositoryParser(String type) { } BeanDefinitionParser parser = TYPE_RESOLVER.resolve(type); - log.info(String.format("Found schema repository bean definition parser %s from resource %s", parser.getClass(), RESOURCE_PATH + "/" + type)); + logger.info(String.format("Found schema repository bean definition parser %s from resource %s", parser.getClass(), RESOURCE_PATH + "/" + type)); SCHEMA_REPOSITORY_PARSER.put(type, parser); return parser; } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/parser/CitrusXmlConfigParser.java b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/parser/CitrusXmlConfigParser.java index 261ecedf43..2f4c7158a5 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/config/xml/parser/CitrusXmlConfigParser.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/config/xml/parser/CitrusXmlConfigParser.java @@ -34,7 +34,7 @@ public interface CitrusXmlConfigParser { /** Logger */ - Logger LOG = LoggerFactory.getLogger(CitrusXmlConfigParser.class); + Logger logger = LoggerFactory.getLogger(CitrusXmlConfigParser.class); /** Bean definition parser resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/config/parser"; @@ -50,8 +50,8 @@ public interface CitrusXmlConfigParser { static Map lookup(String category) { Map parser = TYPE_RESOLVER.resolveAll(category, TypeResolver.DEFAULT_TYPE_PROPERTY, null); - if (LOG.isDebugEnabled()) { - parser.forEach((k, v) -> LOG.debug(String.format("Found XML config parser '%s/%s' as %s", category, k, v.getClass()))); + if (logger.isDebugEnabled()) { + parser.forEach((k, v) -> logger.debug(String.format("Found XML config parser '%s/%s' as %s", category, k, v.getClass()))); } return parser; @@ -70,7 +70,7 @@ static Optional lookup(String category, String name) { T instance = TYPE_RESOLVER.resolve(category + "/" + name); return Optional.of(instance); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve XML config parser from resource '%s/%s/%s'", RESOURCE_PATH, category, name)); + logger.warn(String.format("Failed to resolve XML config parser from resource '%s/%s/%s'", RESOURCE_PATH, category, name)); } return Optional.empty(); diff --git a/core/citrus-spring/src/main/java/org/citrusframework/context/SpringBeanReferenceResolver.java b/core/citrus-spring/src/main/java/org/citrusframework/context/SpringBeanReferenceResolver.java index 95abd431e4..fa8e8f160d 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/context/SpringBeanReferenceResolver.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/context/SpringBeanReferenceResolver.java @@ -43,7 +43,7 @@ public class SpringBeanReferenceResolver implements ReferenceResolver, ApplicationContextAware { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(SpringBeanReferenceResolver.class); + private static final Logger logger = LoggerFactory.getLogger(SpringBeanReferenceResolver.class); private ApplicationContext applicationContext; @@ -210,7 +210,7 @@ private Optional resolveAlias(Class source, Function, ?> supp try { return Optional.of(resolver.adapt(supplier.apply(resolver.getAliasType()))); } catch (Exception e) { - log.warn(String.format("Unable to resolve alias type %s for required source %s", resolver.getAliasType(), source)); + logger.warn(String.format("Unable to resolve alias type %s for required source %s", resolver.getAliasType(), source)); return Optional.empty(); } } @@ -239,7 +239,7 @@ private Optional> resolveAllAlias(Class source, Function resolver.adapt(v.getValue())))); } catch (Exception e) { - log.warn(String.format("Unable to resolve alias type %s for required source %s", resolver.getAliasType(), source)); + logger.warn(String.format("Unable to resolve alias type %s for required source %s", resolver.getAliasType(), source)); return Optional.empty(); } } diff --git a/core/citrus-spring/src/main/java/org/citrusframework/context/TestContextFactoryBean.java b/core/citrus-spring/src/main/java/org/citrusframework/context/TestContextFactoryBean.java index 482d726e74..84619579f5 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/context/TestContextFactoryBean.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/context/TestContextFactoryBean.java @@ -23,7 +23,7 @@ import org.citrusframework.container.BeforeTest; import org.citrusframework.endpoint.EndpointFactory; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.report.MessageListeners; import org.citrusframework.report.TestActionListeners; import org.citrusframework.report.TestListeners; diff --git a/core/citrus-spring/src/main/java/org/citrusframework/variable/GlobalVariablesPropertyLoader.java b/core/citrus-spring/src/main/java/org/citrusframework/variable/GlobalVariablesPropertyLoader.java index 88cbffe35e..560b471122 100644 --- a/core/citrus-spring/src/main/java/org/citrusframework/variable/GlobalVariablesPropertyLoader.java +++ b/core/citrus-spring/src/main/java/org/citrusframework/variable/GlobalVariablesPropertyLoader.java @@ -41,7 +41,7 @@ public class GlobalVariablesPropertyLoader implements InitializingBean { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(GlobalVariablesPropertyLoader.class); + private static final Logger logger = LoggerFactory.getLogger(GlobalVariablesPropertyLoader.class); /** Bean name in Spring application context */ public static final String BEAN_NAME = "globalVariablesPropertyLoader"; @@ -67,7 +67,7 @@ public void afterPropertiesSet() { for (String propertyFilePath : propertyFiles) { Resource propertyFile = new PathMatchingResourcePatternResolver().getResource(propertyFilePath.trim()); - LOG.debug("Reading property file " + propertyFile.getFilename()); + logger.debug("Reading property file " + propertyFile.getFilename()); // Use input stream as this also allows to read from resources in a JAR file reader = new BufferedReader(new InputStreamReader(propertyFile.getInputStream())); @@ -83,7 +83,7 @@ public void afterPropertiesSet() { String propertyExpression; while ((propertyExpression = reader.readLine()) != null) { - LOG.debug("Property line [ {} ]", propertyExpression); + logger.debug("Property line [ {} ]", propertyExpression); propertyExpression = propertyExpression.trim(); if (!isPropertyLine(propertyExpression)) { @@ -93,15 +93,15 @@ public void afterPropertiesSet() { String key = propertyExpression.substring(0, propertyExpression.indexOf('=')).trim(); String value = propertyExpression.substring(propertyExpression.indexOf('=') + 1).trim(); - LOG.debug("Property value replace dynamic content [ {} ]", value); + logger.debug("Property value replace dynamic content [ {} ]", value); value = context.replaceDynamicContentInString(value); - if (LOG.isDebugEnabled()) { - LOG.debug("Loading property: " + key + "=" + value + " into default variables"); + if (logger.isDebugEnabled()) { + logger.debug("Loading property: " + key + "=" + value + " into default variables"); } - if (LOG.isDebugEnabled() && globalVariables.getVariables().containsKey(key)) { - LOG.debug("Overwriting property " + key + " old value:" + globalVariables.getVariables().get(key) + if (logger.isDebugEnabled() && globalVariables.getVariables().containsKey(key)) { + logger.debug("Overwriting property " + key + " old value:" + globalVariables.getVariables().get(key) + " new value:" + value); } @@ -110,7 +110,7 @@ public void afterPropertiesSet() { context.setVariable(key, globalVariables.getVariables().get(key)); } - LOG.info("Loaded property file " + propertyFile.getFilename()); + logger.info("Loaded property file " + propertyFile.getFilename()); } } } catch (IOException e) { @@ -120,7 +120,7 @@ public void afterPropertiesSet() { try { reader.close(); } catch (IOException e) { - LOG.warn("Unable to close property file reader", e); + logger.warn("Unable to close property file reader", e); } } } diff --git a/core/citrus-spring/src/test/java/org/citrusframework/TestSuiteTest.java b/core/citrus-spring/src/test/java/org/citrusframework/TestSuiteTest.java index 14dade0c65..9f0b92f157 100644 --- a/core/citrus-spring/src/test/java/org/citrusframework/TestSuiteTest.java +++ b/core/citrus-spring/src/test/java/org/citrusframework/TestSuiteTest.java @@ -27,7 +27,7 @@ import org.citrusframework.context.TestContextFactoryBean; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.report.MessageListeners; import org.citrusframework.report.TestActionListeners; import org.citrusframework.report.TestListeners; diff --git a/core/citrus-spring/src/test/java/org/citrusframework/util/InvocationDummy.java b/core/citrus-spring/src/test/java/org/citrusframework/util/InvocationDummy.java index fe8cae2850..343087ba5d 100644 --- a/core/citrus-spring/src/test/java/org/citrusframework/util/InvocationDummy.java +++ b/core/citrus-spring/src/test/java/org/citrusframework/util/InvocationDummy.java @@ -27,64 +27,64 @@ public class InvocationDummy { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(InvocationDummy.class); + private static final Logger logger = LoggerFactory.getLogger(InvocationDummy.class); public InvocationDummy() { - if (log.isDebugEnabled()) { - log.debug("Constructor without argument"); + if (logger.isDebugEnabled()) { + logger.debug("Constructor without argument"); } } public InvocationDummy(String arg) { - if (log.isDebugEnabled()) { - log.debug("Constructor with argument: " + arg); + if (logger.isDebugEnabled()) { + logger.debug("Constructor with argument: " + arg); } } public InvocationDummy(Integer arg1, String arg2, Boolean arg3) { - if (log.isDebugEnabled()) { - if (log.isDebugEnabled()) { - log.debug("Constructor with arguments:"); - log.debug("arg1: " + arg1); - log.debug("arg2: " + arg2); - log.debug("arg3: " + arg3); + if (logger.isDebugEnabled()) { + if (logger.isDebugEnabled()) { + logger.debug("Constructor with arguments:"); + logger.debug("arg1: " + arg1); + logger.debug("arg2: " + arg2); + logger.debug("arg3: " + arg3); } } } public void invoke() { - if (log.isDebugEnabled()) { - log.debug("Methode invoke no arguments"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke no arguments"); } } public void invoke(String text) { - if (log.isDebugEnabled()) { - log.debug("Methode invoke with string argument: '" + text + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with string argument: '" + text + "'"); } } public void invoke(String[] args) { for (int i = 0; i < args.length; i++) { - if (log.isDebugEnabled()) { - log.debug("Methode invoke with argument: " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with argument: " + args[i]); } } } public void invoke(Integer arg1, String arg2, Boolean arg3) { - if (log.isDebugEnabled()) { - log.debug("Method invoke with arguments:"); - log.debug("arg1: " + arg1); - log.debug("arg2: " + arg2); - log.debug("arg3: " + arg3); + if (logger.isDebugEnabled()) { + logger.debug("Method invoke with arguments:"); + logger.debug("arg1: " + arg1); + logger.debug("arg2: " + arg2); + logger.debug("arg3: " + arg3); } } public static void main(String[] args) { for (int i = 0; i < args.length; i++) { - if (log.isDebugEnabled()) { - log.debug("arg" + i + ": " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("arg" + i + ": " + args[i]); } } } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelControlBusAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelControlBusAction.java index ea361541cd..d2eb2b3f3d 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelControlBusAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CamelControlBusAction.java @@ -36,7 +36,7 @@ public class CamelControlBusAction extends AbstractCamelRouteAction { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CamelControlBusAction.class); + private static final Logger logger = LoggerFactory.getLogger(CamelControlBusAction.class); /** The control bus action */ private final String action; @@ -89,12 +89,12 @@ public void doExecute(TestContext context) { if (StringUtils.hasText(result)) { String expectedResult = context.replaceDynamicContentInString(result); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Validating Camel controlbus response = '%s'", expectedResult)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Validating Camel controlbus response = '%s'", expectedResult)); } ValidationUtils.validateValues(response.getPayload(String.class), expectedResult, "camelControlBusResult", context); - LOG.info("Validation of Camel controlbus response successful - All values OK"); + logger.info("Validation of Camel controlbus response successful - All values OK"); } } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CreateCamelRouteAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CreateCamelRouteAction.java index c64d8950d9..57b6a32885 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CreateCamelRouteAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/CreateCamelRouteAction.java @@ -27,6 +27,8 @@ import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.xml.StringSource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.BeanDefinitionStoreException; import org.springframework.util.StringUtils; @@ -36,6 +38,9 @@ */ public class CreateCamelRouteAction extends AbstractCamelRouteAction { + /** Logger */ + private static final Logger logger = LoggerFactory.getLogger(CreateCamelRouteAction.class); + /** Camel route */ private final List routes; @@ -81,7 +86,7 @@ public void configure() throws Exception { for (RouteDefinition routeDefinition : routesToUse) { try { getRouteCollection().getRoutes().add(routeDefinition); - log.info(String.format("Created new Camel route '%s' in context '%s'", routeDefinition.getId(), camelContext.getName())); + logger.info(String.format("Created new Camel route '%s' in context '%s'", routeDefinition.getId(), camelContext.getName())); } catch (Exception e) { throw new CitrusRuntimeException(String.format("Failed to create route definition '%s' in context '%s'", routeDefinition.getId(), camelContext.getName()), e); } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/RemoveCamelRouteAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/RemoveCamelRouteAction.java index 6b9c06e4d7..07442e43d0 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/RemoveCamelRouteAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/RemoveCamelRouteAction.java @@ -29,7 +29,7 @@ public class RemoveCamelRouteAction extends AbstractCamelRouteAction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(RemoveCamelRouteAction.class); + private static final Logger logger = LoggerFactory.getLogger(RemoveCamelRouteAction.class); /** * Default constructor. @@ -50,7 +50,7 @@ public void doExecute(TestContext context) { } if (camelContext.removeRoute(route)) { - log.info(String.format("Removed Camel route '%s' from context '%s'", route, camelContext.getName())); + logger.info(String.format("Removed Camel route '%s' from context '%s'", route, camelContext.getName())); } else { throw new CitrusRuntimeException(String.format("Failed to remove Camel route '%s' from context '%s'", route, camelContext.getName())); } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StartCamelRouteAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StartCamelRouteAction.java index d2e56e496d..bd597109fd 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StartCamelRouteAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StartCamelRouteAction.java @@ -29,7 +29,7 @@ public class StartCamelRouteAction extends AbstractCamelRouteAction { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(StartCamelRouteAction.class); + private static final Logger logger = LoggerFactory.getLogger(StartCamelRouteAction.class); /** * Default constructor. @@ -45,7 +45,7 @@ public void doExecute(TestContext context) { try { ((AbstractCamelContext) camelContext).startRoute(route); - LOG.info(String.format("Started Camel route '%s' on context '%s'", route, camelContext.getName())); + logger.info(String.format("Started Camel route '%s' on context '%s'", route, camelContext.getName())); } catch (Exception e) { throw new CitrusRuntimeException("Failed to start Camel route: " + route, e); } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StopCamelRouteAction.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StopCamelRouteAction.java index 1139bc17f9..17857c447a 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StopCamelRouteAction.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/actions/StopCamelRouteAction.java @@ -29,7 +29,7 @@ public class StopCamelRouteAction extends AbstractCamelRouteAction { /** Logger */ - private static Logger log = LoggerFactory.getLogger(StopCamelRouteAction.class); + private static final Logger logger = LoggerFactory.getLogger(StopCamelRouteAction.class); /** * Default constructor. @@ -45,7 +45,7 @@ public void doExecute(TestContext context) { try { ((AbstractCamelContext) camelContext).stopRoute(route); - log.info(String.format("Stopped Camel route '%s' on context '%s'", route, camelContext.getName())); + logger.info(String.format("Stopped Camel route '%s' on context '%s'", route, camelContext.getName())); } catch (Exception e) { throw new CitrusRuntimeException("Failed to stop Camel route: " + route, e); } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelConsumer.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelConsumer.java index 25f2cfd746..1e069089ff 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelConsumer.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelConsumer.java @@ -41,7 +41,7 @@ public class CamelConsumer implements Consumer { private ConsumerTemplate consumerTemplate; /** Logger */ - private static Logger log = LoggerFactory.getLogger(CamelConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(CamelConsumer.class); /** * Constructor using endpoint configuration and fields. @@ -69,8 +69,8 @@ public Message receive(TestContext context, long timeout) { throw new CitrusRuntimeException("Missing endpoint or endpointUri on Camel consumer"); } - if (log.isDebugEnabled()) { - log.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); } Exchange exchange; @@ -84,7 +84,7 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, endpointUri); } - log.info("Received message from camel endpoint: '" + endpointUri + "'"); + logger.info("Received message from camel endpoint: '" + endpointUri + "'"); Message message = endpointConfiguration.getMessageConverter().convertInbound(exchange, endpointConfiguration, context); context.onInboundMessage(message); diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelProducer.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelProducer.java index e39628a11a..f829d31b33 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelProducer.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelProducer.java @@ -40,7 +40,7 @@ public class CamelProducer implements Producer { private ProducerTemplate producerTemplate; /** Logger */ - private static Logger log = LoggerFactory.getLogger(CamelProducer.class); + private static final Logger logger = LoggerFactory.getLogger(CamelProducer.class); /** * Constructor using endpoint configuration and fields. @@ -63,8 +63,8 @@ public void send(final Message message, final TestContext context) { throw new CitrusRuntimeException("Missing endpoint or endpointUri on Camel producer"); } - if (log.isDebugEnabled()) { - log.debug("Sending message to camel endpoint: '" + endpointUri + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to camel endpoint: '" + endpointUri + "'"); } Exchange camelExchange; @@ -84,7 +84,7 @@ public void send(final Message message, final TestContext context) { context.onOutboundMessage(message); - log.info("Message was sent to camel endpoint '" + endpointUri + "'"); + logger.info("Message was sent to camel endpoint '" + endpointUri + "'"); } /** diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncConsumer.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncConsumer.java index dbadb8e2dd..f45114e3ff 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncConsumer.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncConsumer.java @@ -39,7 +39,7 @@ public class CamelSyncConsumer extends CamelConsumer implements ReplyProducer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CamelSyncConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(CamelSyncConsumer.class); /** Storage for in flight exchanges */ private CorrelationManager correlationManager; @@ -70,8 +70,8 @@ public Message receive(TestContext context, long timeout) { throw new CitrusRuntimeException("Missing endpoint or endpointUri on Camel consumer"); } - if (log.isDebugEnabled()) { - log.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Receiving message from camel endpoint: '" + endpointUri + "'"); } Exchange exchange; @@ -85,7 +85,7 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, endpointUri); } - log.info("Received message from camel endpoint: '" + endpointUri + "'"); + logger.info("Received message from camel endpoint: '" + endpointUri + "'"); Message message = endpointConfiguration.getMessageConverter().convertInbound(exchange, endpointConfiguration, context); context.onInboundMessage(message); @@ -109,15 +109,15 @@ public void send(Message message, TestContext context) { buildOutMessage(exchange, message); - if (log.isDebugEnabled()) { - log.debug("Sending reply message to camel endpoint: '" + exchange.getFromEndpoint() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending reply message to camel endpoint: '" + exchange.getFromEndpoint() + "'"); } getConsumerTemplate().doneUoW(exchange); context.onOutboundMessage(message); - log.info("Message was sent to camel endpoint: '" + exchange.getFromEndpoint() + "'"); + logger.info("Message was sent to camel endpoint: '" + exchange.getFromEndpoint() + "'"); } /** @@ -150,7 +150,7 @@ private void buildOutMessage(Exchange exchange, Message message) { exchange.setException((Throwable) exception.getDeclaredConstructor().newInstance()); } } catch (Exception e) { - log.warn("Unable to create proper exception instance for exchange!", e); + logger.warn("Unable to create proper exception instance for exchange!", e); } } diff --git a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncProducer.java b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncProducer.java index be490cac60..b96c95412d 100644 --- a/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncProducer.java +++ b/endpoints/citrus-camel/src/main/java/org/citrusframework/camel/endpoint/CamelSyncProducer.java @@ -39,7 +39,7 @@ public class CamelSyncProducer extends CamelProducer implements ReplyConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CamelSyncProducer.class); + private static final Logger logger = LoggerFactory.getLogger(CamelSyncProducer.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -71,8 +71,8 @@ public void send(final Message message, final TestContext context) { throw new CitrusRuntimeException("Missing endpoint or endpointUri on Camel producer"); } - if (log.isDebugEnabled()) { - log.debug("Sending message to camel endpoint: '" + endpointUri + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to camel endpoint: '" + endpointUri + "'"); } String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()); @@ -86,12 +86,12 @@ public void send(final Message message, final TestContext context) { @Override public void process(Exchange exchange) throws Exception { endpointConfiguration.getMessageConverter().convertOutbound(exchange, message, endpointConfiguration, context); - log.info("Message was sent to camel endpoint: '" + endpointUri + "'"); + logger.info("Message was sent to camel endpoint: '" + endpointUri + "'"); } }); - log.info("Received synchronous reply message on camel endpoint: '" + endpointUri + "'"); + logger.info("Received synchronous reply message on camel endpoint: '" + endpointUri + "'"); Message replyMessage = endpointConfiguration.getMessageConverter().convertInbound(response, endpointConfiguration, context); context.onInboundMessage(replyMessage); correlationManager.store(correlationKey, replyMessage); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/ControlBusTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/ControlBusTest.java index 4f379d1d7f..4e71e96cc3 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/ControlBusTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/ControlBusTest.java @@ -44,16 +44,16 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/RemoveRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/RemoveRoutesTest.java index 150d13ddf6..1893be1735 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/RemoveRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/RemoveRoutesTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StartRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StartRoutesTest.java index 2963f8e620..59ff5e9443 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StartRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StartRoutesTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StopRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StopRoutesTest.java index 694b1985c5..4241efc900 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StopRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/groovy/StopRoutesTest.java @@ -44,15 +44,15 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/ControlBusTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/ControlBusTest.java index 09bce10e16..39f0772510 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/ControlBusTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/ControlBusTest.java @@ -44,16 +44,16 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/RemoveRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/RemoveRoutesTest.java index 1ffea875fc..86a84e4414 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/RemoveRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/RemoveRoutesTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StartRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StartRoutesTest.java index 9bdc100ddb..0977c66b5b 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StartRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StartRoutesTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StopRoutesTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StopRoutesTest.java index ae1cdd4fc4..5af0e1350a 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StopRoutesTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/xml/StopRoutesTest.java @@ -44,15 +44,15 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/ControlBusTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/ControlBusTest.java index 57bbb914dc..5f37e62773 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/ControlBusTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/ControlBusTest.java @@ -44,16 +44,16 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/RemoveRouteTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/RemoveRouteTest.java index bf7041b1f6..e2d779106e 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/RemoveRouteTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/RemoveRouteTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StartRouteTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StartRouteTest.java index 415af2fb5b..73821ca20a 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StartRouteTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StartRouteTest.java @@ -45,17 +45,17 @@ public void configure() throws Exception { from("direct:hello") .routeId("route_1") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") .autoStartup(false) - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") .autoStartup(false) - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StopRouteTest.java b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StopRouteTest.java index 493bf1df15..d99e601b21 100644 --- a/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StopRouteTest.java +++ b/endpoints/citrus-camel/src/test/java/org/citrusframework/camel/yaml/StopRouteTest.java @@ -44,15 +44,15 @@ public void shouldLoadCamelActions() throws Exception { public void configure() throws Exception { from("direct:hello") .routeId("route_1") - .to("log:info"); + .to("logger:info"); from("direct:goodbye") .routeId("route_2") - .to("log:info"); + .to("logger:info"); from("direct:goodnight") .routeId("route_3") - .to("log:info"); + .to("logger:info"); } }); diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/FtpClient.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/FtpClient.java index 67110c51de..db79fef625 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/FtpClient.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/FtpClient.java @@ -70,7 +70,7 @@ public class FtpClient extends AbstractEndpoint implements Producer, ReplyConsumer, InitializingPhase, ShutdownPhase { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(FtpClient.class); + private static final Logger logger = LoggerFactory.getLogger(FtpClient.class); /** Apache ftp client */ private FTPClient ftpClient; @@ -113,9 +113,9 @@ public void send(Message message, TestContext context) { String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(ftpMessage); correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Sending FTP message to: ftp://'%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); - LOG.debug("Message to send:\n" + ftpMessage.getPayload(String.class)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Sending FTP message to: ftp://'%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.debug("Message to send:\n" + ftpMessage.getPayload(String.class)); } try { @@ -142,7 +142,7 @@ public void send(Message message, TestContext context) { } } - LOG.info(String.format("FTP message was sent to: '%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.info(String.format("FTP message was sent to: '%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); correlationManager.store(correlationKey, response); } catch (IOException e) { @@ -405,8 +405,8 @@ protected void connectAndLogin() throws IOException { if (!ftpClient.isConnected()) { ftpClient.connect(getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()); - if (LOG.isDebugEnabled()) { - LOG.debug("Connected to FTP server: " + ftpClient.getReplyString()); + if (logger.isDebugEnabled()) { + logger.debug("Connected to FTP server: " + ftpClient.getReplyString()); } int reply = ftpClient.getReplyCode(); @@ -415,11 +415,11 @@ protected void connectAndLogin() throws IOException { throw new CitrusRuntimeException("FTP server refused connection."); } - LOG.info("Opened connection to FTP server"); + logger.info("Opened connection to FTP server"); if (getEndpointConfiguration().getUser() != null) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Login as user: '%s'", getEndpointConfiguration().getUser())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Login as user: '%s'", getEndpointConfiguration().getUser())); } boolean login = ftpClient.login(getEndpointConfiguration().getUser(), getEndpointConfiguration().getPassword()); @@ -475,15 +475,15 @@ public void initialize() { ftpClient.addProtocolCommandListener(new ProtocolCommandListener() { @Override public void protocolCommandSent(ProtocolCommandEvent event) { - if (LOG.isDebugEnabled()) { - LOG.debug("Send FTP command: " + event.getCommand()); + if (logger.isDebugEnabled()) { + logger.debug("Send FTP command: " + event.getCommand()); } } @Override public void protocolReplyReceived(ProtocolCommandEvent event) { - if (LOG.isDebugEnabled()) { - LOG.debug("Received FTP command reply: " + event.getReplyCode()); + if (logger.isDebugEnabled()) { + logger.debug("Received FTP command reply: " + event.getReplyCode()); } } }); @@ -498,10 +498,10 @@ public void destroy() { try { ftpClient.disconnect(); } catch (IOException e) { - LOG.warn("Failed to disconnect from FTP server", e); + logger.warn("Failed to disconnect from FTP server", e); } - LOG.info("Closed connection to FTP server"); + logger.info("Closed connection to FTP server"); } } catch (IOException e) { throw new CitrusRuntimeException("Failed to logout from FTP server", e); diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/ScpClient.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/ScpClient.java index 4ef8aaffc7..2decb862ce 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/ScpClient.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/ScpClient.java @@ -49,7 +49,7 @@ public class ScpClient extends SftpClient { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ScpClient.class); + private static final Logger logger = LoggerFactory.getLogger(ScpClient.class); private org.apache.sshd.scp.client.ScpClient scpClient; @@ -93,7 +93,7 @@ protected FtpMessage storeFile(PutCommand command, TestContext context) { try { scpClient.upload(FileUtils.getFileResource(command.getFile().getPath(), context).getFile().getAbsolutePath(), command.getTarget().getPath()); } catch (IOException e) { - LOG.error("Failed to store file via SCP", e); + logger.error("Failed to store file via SCP", e); return FtpMessage.error(); } @@ -105,12 +105,12 @@ protected FtpMessage retrieveFile(GetCommand command, TestContext context) { try { Resource target = FileUtils.getFileResource(command.getTarget().getPath(), context); if (!Optional.ofNullable(target.getFile().getParentFile()).map(File::mkdirs).orElse(true)) { - LOG.warn("Failed to create target directories in path: " + target.getFile().getAbsolutePath()); + logger.warn("Failed to create target directories in path: " + target.getFile().getAbsolutePath()); } scpClient.download(command.getFile().getPath(), target.getFile().getAbsolutePath()); } catch (IOException e) { - LOG.error("Failed to retrieve file via SCP", e); + logger.error("Failed to retrieve file via SCP", e); return FtpMessage.error(); } diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/SftpClient.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/SftpClient.java index 5cb5267f31..0920c57161 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/SftpClient.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/client/SftpClient.java @@ -63,7 +63,7 @@ public class SftpClient extends FtpClient { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SftpClient.class); + private static final Logger logger = LoggerFactory.getLogger(SftpClient.class); /** Session for the SSH communication */ private Session session; @@ -278,7 +278,7 @@ protected void connectAndLogin() { getEndpointConfiguration().getSessionConfigs().entrySet() .stream() - .peek(entry -> log.info(String.format("Setting session configuration: %s='%s'", entry.getKey(), entry.getValue()))) + .peek(entry -> logger.info(String.format("Setting session configuration: %s='%s'", entry.getKey(), entry.getValue()))) .forEach(entry -> session.setConfig(entry.getKey(), entry.getValue())); session.connect((int) getEndpointConfiguration().getTimeout()); @@ -287,7 +287,7 @@ protected void connectAndLogin() { channel.connect((int) getEndpointConfiguration().getTimeout()); sftp = (ChannelSftp) channel; - log.info("Opened secure connection to FTP server"); + logger.info("Opened secure connection to FTP server"); } catch (JSchException e) { throw new CitrusRuntimeException(String.format("Failed to login to FTP server using credentials: %s:%s", getEndpointConfiguration().getUser(), getEndpointConfiguration().getPassword()), e); } @@ -366,7 +366,7 @@ public void initialize() { public void destroy() { if (session != null && session.isConnected()) { session.disconnect(); - log.info("Closed connection to FTP server"); + logger.info("Closed connection to FTP server"); } sftp.disconnect(); diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/message/FtpMarshaller.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/message/FtpMarshaller.java index 35b5c7895d..681d8c930c 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/message/FtpMarshaller.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/message/FtpMarshaller.java @@ -55,7 +55,7 @@ public class FtpMarshaller implements Marshaller, Unmarshaller { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(FtpMarshaller.class); + private static final Logger logger = LoggerFactory.getLogger(FtpMarshaller.class); /** System property defining message format to marshal to */ private static final String JDBC_MARSHALLER_TYPE_PROPERTY = "citrus.ftp.marshaller.type"; @@ -102,7 +102,7 @@ public Object unmarshal(Source source) { } catch (JsonParseException | JsonMappingException e2) { continue; } catch (IOException io) { - log.warn("Failed to read ftp JSON object from source: " + io.getMessage()); + logger.warn("Failed to read ftp JSON object from source: " + io.getMessage()); break; } } @@ -124,7 +124,7 @@ public Object unmarshal(Source source) { try { return marshaller.unmarshal(source); } catch (JAXBException me) { - log.warn("Failed to read ftp XML object from source: " + me.getMessage()); + logger.warn("Failed to read ftp XML object from source: " + me.getMessage()); } throw new CitrusRuntimeException("Failed to read ftp JSON object from source" + source); diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/FtpServerFtpLet.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/FtpServerFtpLet.java index ddd7e365da..ebe9c8a33e 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/FtpServerFtpLet.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/FtpServerFtpLet.java @@ -52,7 +52,7 @@ public class FtpServerFtpLet implements Ftplet { /** Logger */ - private static Logger log = LoggerFactory.getLogger(FtpServerFtpLet.class); + private static final Logger logger = LoggerFactory.getLogger(FtpServerFtpLet.class); /** Endpoint configuration */ private final FtpEndpointConfiguration endpointConfiguration; @@ -77,8 +77,8 @@ public FtpMessage handleMessage(FtpMessage request) { request.setPayload(result.toString()); } - if (log.isDebugEnabled()) { - log.debug(String.format("Received request on ftp server: '%s':%n%s", + if (logger.isDebugEnabled()) { + logger.debug(String.format("Received request on ftp server: '%s':%n%s", request.getSignal(), request.getPayload(String.class))); } @@ -96,22 +96,22 @@ public FtpMessage handleMessage(FtpMessage request) { @Override public void init(FtpletContext ftpletContext) { - if (log.isDebugEnabled()) { - log.debug(String.format("Total FTP logins: %s", ftpletContext.getFtpStatistics().getTotalLoginNumber())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Total FTP logins: %s", ftpletContext.getFtpStatistics().getTotalLoginNumber())); } } @Override public void destroy() { - log.info("FTP server shutting down ..."); + logger.info("FTP server shutting down ..."); } @Override public FtpletResult beforeCommand(FtpSession session, FtpRequest request) { String command = request.getCommand().toUpperCase(); - if (log.isDebugEnabled()) { - log.debug(String.format("Received FTP command: '%s'", command)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Received FTP command: '%s'", command)); } if (endpointConfiguration.isAutoLogin() && (command.equals(FTPCmd.USER.getCommand()) || command.equals(FTPCmd.PASS.getCommand()))) { @@ -138,8 +138,8 @@ public FtpletResult afterCommand(FtpSession session, FtpRequest request, FtpRepl @Override public FtpletResult onConnect(FtpSession session) { - if (log.isDebugEnabled()) { - log.debug(String.format("Received new FTP connection: '%s'", session.getSessionId())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Received new FTP connection: '%s'", session.getSessionId())); } if (!endpointConfiguration.isAutoConnect()) { @@ -164,8 +164,8 @@ public FtpletResult onDisconnect(FtpSession session) { } } - if (log.isDebugEnabled()) { - log.debug(String.format("Closing FTP connection: '%s'", session.getSessionId())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Closing FTP connection: '%s'", session.getSessionId())); } return FtpletResult.DISCONNECT; diff --git a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/SftpServer.java b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/SftpServer.java index ca3f247342..a24a1ebf94 100644 --- a/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/SftpServer.java +++ b/endpoints/citrus-ftp/src/main/java/org/citrusframework/ftp/server/SftpServer.java @@ -47,7 +47,7 @@ public class SftpServer extends SshServer implements ScpTransferEventListener, SftpEventListener { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SftpServer.class); + private static final Logger logger = LoggerFactory.getLogger(SftpServer.class); /** This servers endpoint configuration */ private final SftpEndpointConfiguration endpointConfiguration; @@ -74,8 +74,8 @@ public FtpMessage handleMessage(FtpMessage request) { request.setPayload(result.toString()); } - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Received request on ftp server: '%s':%n%s", + if (logger.isDebugEnabled()) { + logger.debug(String.format("Received request on ftp server: '%s':%n%s", request.getSignal(), request.getPayload(String.class))); } @@ -113,8 +113,8 @@ public void startFolderEvent(Session session, FileOperation op, Path file, Set

correlationManager; @@ -99,9 +99,9 @@ public void send(Message message, TestContext context) { final String endpointUri = getEndpointUri(httpMessage); context.setVariable(MessageHeaders.MESSAGE_REPLY_TO + "_" + correlationKeyName, endpointUri); - log.info("Sending HTTP message to: '" + endpointUri + "'"); - if (log.isDebugEnabled()) { - log.debug("Message to send:\n" + httpMessage.getPayload(String.class)); + logger.info("Sending HTTP message to: '" + endpointUri + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Message to send:\n" + httpMessage.getPayload(String.class)); } RequestMethod method = getEndpointConfiguration().getRequestMethod(); @@ -119,7 +119,7 @@ public void send(Message message, TestContext context) { try { return MediaType.valueOf(mediaType[0]); } catch (InvalidMediaTypeException e) { - log.warn(String.format("Failed to parse accept media type '%s' - using default media type '%s'", + logger.warn(String.format("Failed to parse accept media type '%s' - using default media type '%s'", mediaType[0], MediaType.ALL_VALUE), e); return MediaType.ALL; } @@ -132,11 +132,11 @@ public void send(Message message, TestContext context) { response = getEndpointConfiguration().getRestTemplate().exchange(URI.create(endpointUri), HttpMethod.valueOf(method.toString()), requestEntity, String.class); } - log.info("HTTP message was sent to endpoint: '" + endpointUri + "'"); + logger.info("HTTP message was sent to endpoint: '" + endpointUri + "'"); correlationManager.store(correlationKey, getEndpointConfiguration().getMessageConverter().convertInbound(response, getEndpointConfiguration(), context)); } catch (HttpErrorPropagatingException e) { - log.info("Caught HTTP rest client exception: " + e.getMessage()); - log.info("Propagating HTTP rest client exception according to error handling strategy"); + logger.info("Caught HTTP rest client exception: " + e.getMessage()); + logger.info("Propagating HTTP rest client exception according to error handling strategy"); Message responseMessage = getEndpointConfiguration().getMessageConverter().convertInbound( new ResponseEntity<>(e.getResponseBodyAsString(), e.getResponseHeaders(), e.getStatusCode()), getEndpointConfiguration(), context); correlationManager.store(correlationKey, responseMessage); diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingClientInterceptor.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingClientInterceptor.java index 1e81895ebe..351ea8a25e 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingClientInterceptor.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingClientInterceptor.java @@ -45,11 +45,11 @@ */ public class LoggingClientInterceptor implements ClientHttpRequestInterceptor { - /** New line characters in log files */ + /** New line characters in logger files */ private static final String NEWLINE = System.getProperty("line.separator"); /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(LoggingClientInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(LoggingClientInterceptor.class); private MessageListeners messageListener; @@ -73,11 +73,11 @@ public ClientHttpResponse intercept(HttpRequest request, byte[] body, */ public void handleRequest(String request) { if (hasMessageListeners()) { - LOG.debug("Sending Http request message"); + logger.debug("Sending Http request message"); messageListener.onOutboundMessage(new RawMessage(request), contextFactory.getObject()); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Sending Http request message:" + NEWLINE + request); + if (logger.isDebugEnabled()) { + logger.debug("Sending Http request message:" + NEWLINE + request); } } } @@ -88,11 +88,11 @@ public void handleRequest(String request) { */ public void handleResponse(String response) { if (hasMessageListeners()) { - LOG.debug("Received Http response message"); + logger.debug("Received Http response message"); messageListener.onInboundMessage(new RawMessage(response), contextFactory.getObject()); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Received Http response message:" + NEWLINE + response); + if (logger.isDebugEnabled()) { + logger.debug("Received Http response message:" + NEWLINE + response); } } } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingHandlerInterceptor.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingHandlerInterceptor.java index 122780b53d..677a8160e5 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingHandlerInterceptor.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/interceptor/LoggingHandlerInterceptor.java @@ -45,11 +45,11 @@ */ public class LoggingHandlerInterceptor implements HandlerInterceptor { - /** New line characters in log files */ + /** New line characters in logger files */ private static final String NEWLINE = System.getProperty("line.separator"); /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(LoggingHandlerInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(LoggingHandlerInterceptor.class); private MessageListeners messageListener; @@ -79,11 +79,11 @@ public void afterCompletion(HttpServletRequest request, */ public void handleRequest(String request) { if (hasMessageListeners()) { - LOG.debug("Received Http request"); + logger.debug("Received Http request"); messageListener.onInboundMessage(new RawMessage(request), contextFactory.getObject()); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Received Http request:" + NEWLINE + request); + if (logger.isDebugEnabled()) { + logger.debug("Received Http request:" + NEWLINE + request); } } } @@ -94,11 +94,11 @@ public void handleRequest(String request) { */ public void handleResponse(String response) { if (hasMessageListeners()) { - LOG.debug("Sending Http response"); + logger.debug("Sending Http response"); messageListener.onOutboundMessage(new RawMessage(response), contextFactory.getObject()); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Sending Http response:" + NEWLINE + response); + if (logger.isDebugEnabled()) { + logger.debug("Sending Http response:" + NEWLINE + response); } } } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CachingHttpServletRequestWrapper.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CachingHttpServletRequestWrapper.java index 291cf7fbeb..2a8226fd10 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CachingHttpServletRequestWrapper.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CachingHttpServletRequestWrapper.java @@ -45,7 +45,7 @@ */ public class CachingHttpServletRequestWrapper extends HttpServletRequestWrapper { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CachingHttpServletRequestWrapper.class); + private static final Logger logger = LoggerFactory.getLogger(CachingHttpServletRequestWrapper.class); /** Cached request data initialized when first read from input stream */ private byte[] body; @@ -68,7 +68,7 @@ public Map getParameterMap() { try { return MediaType.valueOf(mediaType); } catch (InvalidMediaTypeException e) { - log.warn(String.format("Failed to parse content type '%s' - using default media type '%s'", + logger.warn(String.format("Failed to parse content type '%s' - using default media type '%s'", getContentType(), MediaType.ALL_VALUE), e); return MediaType.ALL; } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CitrusDispatcherServlet.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CitrusDispatcherServlet.java index 2c8ee838b4..aecebc52ed 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CitrusDispatcherServlet.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/servlet/CitrusDispatcherServlet.java @@ -50,7 +50,7 @@ public class CitrusDispatcherServlet extends DispatcherServlet { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CitrusDispatcherServlet.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusDispatcherServlet.class); /** Http server hosting the servlet */ private HttpServer httpServer; @@ -153,7 +153,7 @@ private List adaptInterceptors(List interceptors, Ap } else if (interceptor instanceof WebRequestInterceptor) { handlerInterceptors.add(new WebRequestHandlerInterceptorAdapter((WebRequestInterceptor) interceptor)); } else { - log.warn("Unsupported interceptor type: {}", interceptor.getClass().getName()); + logger.warn("Unsupported interceptor type: {}", interceptor.getClass().getName()); } } } diff --git a/endpoints/citrus-http/src/main/java/org/citrusframework/http/validation/FormUrlEncodedMessageValidator.java b/endpoints/citrus-http/src/main/java/org/citrusframework/http/validation/FormUrlEncodedMessageValidator.java index a5644a7ac0..219f2ab73c 100644 --- a/endpoints/citrus-http/src/main/java/org/citrusframework/http/validation/FormUrlEncodedMessageValidator.java +++ b/endpoints/citrus-http/src/main/java/org/citrusframework/http/validation/FormUrlEncodedMessageValidator.java @@ -54,7 +54,7 @@ public class FormUrlEncodedMessageValidator implements MessageValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(FormUrlEncodedMessageValidator.class); + private static final Logger logger = LoggerFactory.getLogger(FormUrlEncodedMessageValidator.class); /** Message type this validator is bound to */ public static final String MESSAGE_TYPE = "x-www-form-urlencoded"; @@ -73,7 +73,7 @@ public class FormUrlEncodedMessageValidator implements MessageValidator validationContexts) throws ValidationException { - log.info("Start " + MESSAGE_TYPE + " message validation"); + logger.info("Start " + MESSAGE_TYPE + " message validation"); try { Message formMessage = new DefaultMessage(receivedMessage); @@ -86,7 +86,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, throw new ValidationException("Failed to validate " + MESSAGE_TYPE + " message", e); } - log.info("Validation of " + MESSAGE_TYPE + " message finished successfully: All values OK"); + logger.info("Validation of " + MESSAGE_TYPE + " message finished successfully: All values OK"); } /** diff --git a/endpoints/citrus-http/src/test/java/org/citrusframework/http/validation/TextEqualsMessageValidator.java b/endpoints/citrus-http/src/test/java/org/citrusframework/http/validation/TextEqualsMessageValidator.java index 0e6b282e72..fd6afa5165 100644 --- a/endpoints/citrus-http/src/test/java/org/citrusframework/http/validation/TextEqualsMessageValidator.java +++ b/endpoints/citrus-http/src/test/java/org/citrusframework/http/validation/TextEqualsMessageValidator.java @@ -34,18 +34,18 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + private boolean trim = false; @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage == null || controlMessage.getPayload() == null || controlMessage.getPayload(String.class).isEmpty()) { - LOG.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } - log.debug("Start text equals validation ..."); + logger.debug("Start text equals validation ..."); String controlPayload = controlMessage.getPayload(String.class); String receivedPayload = receivedMessage.getPayload(String.class); @@ -58,7 +58,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes Assert.assertEquals(receivedPayload, controlPayload, "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/actions/PurgeJmsQueuesAction.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/actions/PurgeJmsQueuesAction.java index b573f1e207..005032e8ab 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/actions/PurgeJmsQueuesAction.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/actions/PurgeJmsQueuesAction.java @@ -70,7 +70,7 @@ public class PurgeJmsQueuesAction extends AbstractTestAction { private final long sleepTime; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(PurgeJmsQueuesAction.class); + private static final Logger logger = LoggerFactory.getLogger(PurgeJmsQueuesAction.class); /** * Default constructor. @@ -88,7 +88,7 @@ public PurgeJmsQueuesAction(Builder builder) { @SuppressWarnings("PMD.CloseResource") //suppress since session/connection closed via JmsUtils @Override public void doExecute(TestContext context) { - LOG.debug("Purging JMS queues..."); + logger.debug("Purging JMS queues..."); Connection connection = null; Session session = null; @@ -106,14 +106,14 @@ public void doExecute(TestContext context) { } } catch (JMSException e) { - LOG.error("Error while establishing jms connection", e); + logger.error("Error while establishing jms connection", e); throw new CitrusRuntimeException(e); } finally { JmsUtils.closeSession(session); JmsUtils.closeConnection(connection, true); } - LOG.info("Purged JMS queues"); + logger.info("Purged JMS queues"); } /** @@ -144,8 +144,8 @@ private void purgeQueue(Queue queue, Session session) throws JMSException { * @throws JMSException */ private void purgeDestination(Destination destination, Session session, String destinationName) throws JMSException { - if (LOG.isDebugEnabled()) { - LOG.debug("Try to purge destination " + destinationName); + if (logger.isDebugEnabled()) { + logger.debug("Try to purge destination " + destinationName); } int messagesPurged = 0; @@ -156,19 +156,19 @@ private void purgeDestination(Destination destination, Session session, String d message = (receiveTimeout >= 0) ? messageConsumer.receive(receiveTimeout) : messageConsumer.receive(); if (message != null) { - LOG.debug("Removed message from destination " + destinationName); + logger.debug("Removed message from destination " + destinationName); messagesPurged++; try { Thread.sleep(sleepTime); } catch (InterruptedException e) { - LOG.warn("Interrupted during wait", e); + logger.warn("Interrupted during wait", e); } } } while (message != null); - if (LOG.isDebugEnabled()) { - LOG.debug("Purged " + messagesPurged + " messages from destination"); + if (logger.isDebugEnabled()) { + logger.debug("Purged " + messagesPurged + " messages from destination"); } } finally { JmsUtils.closeMessageConsumer(messageConsumer); diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsConsumer.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsConsumer.java index 604b2e2090..464c78924e 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsConsumer.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsConsumer.java @@ -34,7 +34,7 @@ public class JmsConsumer extends AbstractSelectiveMessageConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmsConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(JmsConsumer.class); /** Endpoint configuration */ protected final JmsEndpointConfiguration endpointConfiguration; @@ -81,8 +81,8 @@ public Message receive(String selector, TestContext context, long timeout) { private jakarta.jms.Message receive(String destinationName, String selector) { jakarta.jms.Message receivedJmsMessage; - if (log.isDebugEnabled()) { - log.debug("Receiving JMS message on destination: '" + getDestinationNameWithSelector(destinationName, selector) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Receiving JMS message on destination: '" + getDestinationNameWithSelector(destinationName, selector) + "'"); } if (StringUtils.hasText(selector)) { @@ -95,7 +95,7 @@ private jakarta.jms.Message receive(String destinationName, String selector) { throw new MessageTimeoutException(endpointConfiguration.getTimeout(), getDestinationNameWithSelector(destinationName, selector)); } - log.info("Received JMS message on destination: '" + getDestinationNameWithSelector(destinationName, selector) + "'"); + logger.info("Received JMS message on destination: '" + getDestinationNameWithSelector(destinationName, selector) + "'"); return receivedJmsMessage; } @@ -109,8 +109,8 @@ private jakarta.jms.Message receive(String destinationName, String selector) { private jakarta.jms.Message receive(Destination destination, String selector) { jakarta.jms.Message receivedJmsMessage; - if (log.isDebugEnabled()) { - log.debug("Receiving JMS message on destination: '" + getDestinationNameWithSelector(endpointConfiguration.getDestinationName(destination), selector) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Receiving JMS message on destination: '" + getDestinationNameWithSelector(endpointConfiguration.getDestinationName(destination), selector) + "'"); } if (StringUtils.hasText(selector)) { @@ -123,7 +123,7 @@ private jakarta.jms.Message receive(Destination destination, String selector) { throw new MessageTimeoutException(endpointConfiguration.getTimeout(), getDestinationNameWithSelector(endpointConfiguration.getDestinationName(destination), selector)); } - log.info("Received JMS message on destination: '" + getDestinationNameWithSelector(endpointConfiguration.getDestinationName(destination), selector) + "'"); + logger.info("Received JMS message on destination: '" + getDestinationNameWithSelector(endpointConfiguration.getDestinationName(destination), selector) + "'"); return receivedJmsMessage; } diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointAdapter.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointAdapter.java index 0a0925e9c6..c5fc658801 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointAdapter.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointAdapter.java @@ -43,7 +43,7 @@ public class JmsEndpointAdapter extends AbstractEndpointAdapter { private final JmsSyncEndpointConfiguration endpointConfiguration; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(JmsEndpointAdapter.class); + private static final Logger logger = LoggerFactory.getLogger(JmsEndpointAdapter.class); /** * Default constructor using endpoint configuration. @@ -63,7 +63,7 @@ public JmsEndpointAdapter(JmsSyncEndpointConfiguration endpointConfiguration) { @Override protected Message handleMessageInternal(Message request) { - LOG.debug("Forwarding request to jms destination ..."); + logger.debug("Forwarding request to jms destination ..."); TestContext context = getTestContext(); Message replyMessage = null; @@ -75,7 +75,7 @@ protected Message handleMessageInternal(Message request) { replyMessage = producer.receive(context, endpointConfiguration.getTimeout()); } } catch (ActionTimeoutException e) { - LOG.warn(e.getMessage()); + logger.warn(e.getMessage()); } return replyMessage; diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointConfiguration.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointConfiguration.java index 473745fac7..e48b1770e2 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointConfiguration.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsEndpointConfiguration.java @@ -41,7 +41,7 @@ public class JmsEndpointConfiguration extends AbstractPollableEndpointConfiguration { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(JmsEndpointConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger(JmsEndpointConfiguration.class); /** The connection factory */ private ConnectionFactory connectionFactory; @@ -98,7 +98,7 @@ public String getDestinationName(Destination destination) { return destination.toString(); } } catch (JMSException e) { - LOG.error("Unable to resolve destination name", e); + logger.error("Unable to resolve destination name", e); return ""; } } diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsProducer.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsProducer.java index 35675af4ff..755d569e38 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsProducer.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsProducer.java @@ -34,7 +34,7 @@ public class JmsProducer implements Producer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmsProducer.class); + private static final Logger logger = LoggerFactory.getLogger(JmsProducer.class); /** The producer name. */ private final String name; @@ -82,8 +82,8 @@ public void send(final Message message, final TestContext context) { * @param context */ private void send(Message message, String destinationName, TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + destinationName + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + destinationName + "'"); } endpointConfiguration.getJmsTemplate().send(destinationName, session -> { @@ -92,7 +92,7 @@ private void send(Message message, String destinationName, TestContext context) return jmsMessage; }); - log.info("Message was sent to JMS destination: '" + destinationName + "'"); + logger.info("Message was sent to JMS destination: '" + destinationName + "'"); } /** @@ -102,8 +102,8 @@ private void send(Message message, String destinationName, TestContext context) * @param context */ private void send(Message message, Destination destination, TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(destination) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(destination) + "'"); } endpointConfiguration.getJmsTemplate().send(destination, session -> { @@ -112,7 +112,7 @@ private void send(Message message, Destination destination, TestContext context) return jmsMessage; }); - log.info("Message was sent to JMS destination: '" + endpointConfiguration.getDestinationName(destination) + "'"); + logger.info("Message was sent to JMS destination: '" + endpointConfiguration.getDestinationName(destination) + "'"); } @Override diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncConsumer.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncConsumer.java index c0f496bd28..dcda758ba8 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncConsumer.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncConsumer.java @@ -41,7 +41,7 @@ public class JmsSyncConsumer extends JmsConsumer implements ReplyProducer { private final JmsSyncEndpointConfiguration endpointConfiguration; /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmsSyncConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(JmsSyncConsumer.class); /** * Default constructor using endpoint configuration. @@ -80,8 +80,8 @@ public void send(final Message message, final TestContext context) { Destination replyDestination = correlationManager.find(correlationKey, endpointConfiguration.getTimeout()); Assert.notNull(replyDestination, "Failed to find JMS reply destination for message correlation key: '" + correlationKey + "'"); - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(replyDestination) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(replyDestination) + "'"); } endpointConfiguration.getJmsTemplate().send(replyDestination, session -> { @@ -92,7 +92,7 @@ public void send(final Message message, final TestContext context) { context.onOutboundMessage(message); - log.info("Message was sent to JMS destination: '" + endpointConfiguration.getDestinationName(replyDestination) + "'"); + logger.info("Message was sent to JMS destination: '" + endpointConfiguration.getDestinationName(replyDestination) + "'"); } /** @@ -109,7 +109,7 @@ public void saveReplyDestination(JmsMessage jmsMessage, TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, jmsMessage.getReplyTo()); } else { - log.warn("Unable to retrieve reply to destination for message \n" + + logger.warn("Unable to retrieve reply to destination for message \n" + jmsMessage + "\n - no reply to destination found in message headers!"); } } diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncProducer.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncProducer.java index 1e5a7f4736..20b6e07a6d 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncProducer.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsSyncProducer.java @@ -54,7 +54,7 @@ public class JmsSyncProducer extends JmsProducer implements ReplyConsumer { private final JmsSyncEndpointConfiguration endpointConfiguration; /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmsSyncProducer.class); + private static final Logger logger = LoggerFactory.getLogger(JmsSyncProducer.class); /** * Default constructor using endpoint configuration. @@ -91,8 +91,8 @@ public void send(Message message, TestContext context) { Destination destination; if (endpointConfiguration.getDestination() != null) { - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getDestination()) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getDestination()) + "'"); } destination = endpointConfiguration.getDestination(); @@ -103,8 +103,8 @@ public void send(Message message, TestContext context) { destination = resolveDestination(context.replaceDynamicContentInString(endpointConfiguration.getDestinationName())); } } else if (endpointConfiguration.getJmsTemplate().getDefaultDestination() != null) { - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getJmsTemplate().getDefaultDestination()) + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + endpointConfiguration.getDestinationName(endpointConfiguration.getJmsTemplate().getDefaultDestination()) + "'"); } destination = endpointConfiguration.getJmsTemplate().getDefaultDestination(); @@ -129,8 +129,8 @@ public void send(Message message, TestContext context) { messageConsumer = createMessageConsumer(replyToDestination, jmsRequest.getJMSMessageID()); } - log.info("Message was sent to JMS destination: '{}'", endpointConfiguration.getDestinationName(destination)); - log.debug("Receiving reply message on destination: '{}'", replyToDestination); + logger.info("Message was sent to JMS destination: '{}'", endpointConfiguration.getDestinationName(destination)); + logger.debug("Receiving reply message on destination: '{}'", replyToDestination); jakarta.jms.Message jmsReplyMessage = (endpointConfiguration.getTimeout() >= 0) ? messageConsumer.receive(endpointConfiguration.getTimeout()) : messageConsumer.receive(); @@ -140,7 +140,7 @@ public void send(Message message, TestContext context) { Message responseMessage = endpointConfiguration.getMessageConverter().convertInbound(jmsReplyMessage, endpointConfiguration, context); - log.info("Received reply message on JMS destination: '{}'", replyToDestination); + logger.info("Received reply message on JMS destination: '{}'", replyToDestination); context.onInboundMessage(responseMessage); @@ -202,7 +202,7 @@ protected void createConnection() throws JMSException { connection = ((TopicConnectionFactory) endpointConfiguration.getConnectionFactory()).createTopicConnection(); connection.setClientID(getName()); } else { - log.warn("Not able to create a connection with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" + + logger.warn("Not able to create a connection with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" + " when using setting 'publish-subscribe-domain' (=" + endpointConfiguration.isPubSubDomain() + ")"); connection = endpointConfiguration.getConnectionFactory().createConnection(); @@ -225,7 +225,7 @@ protected void createSession(Connection connection) throws JMSException { } else if (endpointConfiguration.isPubSubDomain() && endpointConfiguration.getConnectionFactory() instanceof TopicConnectionFactory) { session = ((TopicConnection) connection).createTopicSession(false, Session.AUTO_ACKNOWLEDGE); } else { - log.warn("Not able to create a session with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" + + logger.warn("Not able to create a session with connection factory '" + endpointConfiguration.getConnectionFactory() + "'" + " when using setting 'publish-subscribe-domain' (=" + endpointConfiguration.isPubSubDomain() + ")"); session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE); @@ -261,7 +261,7 @@ private MessageConsumer createMessageConsumer(Destination replyToDestination, St * @param destination */ private void deleteTemporaryDestination(Destination destination) { - log.debug("Delete temporary destination: '{}'", destination); + logger.debug("Delete temporary destination: '{}'", destination); try { if (destination instanceof TemporaryQueue) { @@ -270,7 +270,7 @@ private void deleteTemporaryDestination(Destination destination) { ((TemporaryTopic) destination).delete(); } } catch (JMSException e) { - log.error("Error while deleting temporary destination '" + destination + "'", e); + logger.error("Error while deleting temporary destination '" + destination + "'", e); } } @@ -310,8 +310,8 @@ private Destination getReplyDestination(Session session, Message message) throws * @throws JMSException */ private Destination resolveDestination(String destinationName) throws JMSException { - if (log.isDebugEnabled()) { - log.debug("Sending JMS message to destination: '" + destinationName + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending JMS message to destination: '" + destinationName + "'"); } return resolveDestinationName(destinationName, session); diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsTopicSubscriber.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsTopicSubscriber.java index 1b54cc3724..c75b9e184c 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsTopicSubscriber.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/endpoint/JmsTopicSubscriber.java @@ -50,7 +50,7 @@ public class JmsTopicSubscriber extends JmsConsumer implements Runnable { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmsConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(JmsConsumer.class); /** Boolean flag for continued message consumption, if false stop */ private boolean running = true; @@ -118,10 +118,10 @@ public void run() { TopicSubscriber subscriber; if (endpointConfiguration.isDurableSubscription()) { - log.debug(String.format("Create JMS topic durable subscription '%s'", Optional.ofNullable(endpointConfiguration.getDurableSubscriberName()).orElse(getName()))); + logger.debug(String.format("Create JMS topic durable subscription '%s'", Optional.ofNullable(endpointConfiguration.getDurableSubscriberName()).orElse(getName()))); subscriber = session.createDurableSubscriber(topic, Optional.ofNullable(endpointConfiguration.getDurableSubscriberName()).orElse(getName())); } else { - log.debug("Create JMS topic subscription"); + logger.debug("Create JMS topic subscription"); subscriber = session.createSubscriber(topic); } @@ -136,19 +136,19 @@ public void run() { TestContext context = testContextFactory.getObject(); Message message = endpointConfiguration.getMessageConverter().convertInbound(event, endpointConfiguration, context); - if (log.isDebugEnabled()) { - log.debug(String.format("Received topic event '%s'", message.getId())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Received topic event '%s'", message.getId())); } messageQueue.createProducer().send(message, context); } else { - if (log.isDebugEnabled()) { - log.debug("Topic subscriber received null message - continue after " + endpointConfiguration.getPollingInterval() + " milliseconds"); + if (logger.isDebugEnabled()) { + logger.debug("Topic subscriber received null message - continue after " + endpointConfiguration.getPollingInterval() + " milliseconds"); } try { Thread.sleep(endpointConfiguration.getPollingInterval()); } catch (InterruptedException e) { - log.warn("Interrupted while waiting after null message", e); + logger.warn("Interrupted while waiting after null message", e); } } } @@ -162,7 +162,7 @@ public void run() { try { connection.close(); } catch (JMSException e) { - log.warn("Failed to close JMS topic connection", e); + logger.warn("Failed to close JMS topic connection", e); } } @@ -175,10 +175,10 @@ public void start() { try { if (started.get()) { - log.info("Started JMS topic subscription"); + logger.info("Started JMS topic subscription"); } } catch (InterruptedException | ExecutionException e) { - log.warn("Failed to wait for topic subscriber to start subscription", e); + logger.warn("Failed to wait for topic subscriber to start subscription", e); } } @@ -188,9 +188,9 @@ public void stop() { try { stopped.get(endpointConfiguration.getTimeout(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException e) { - log.warn("Failed to wait for topic subscriber to stop gracefully", e); + logger.warn("Failed to wait for topic subscriber to stop gracefully", e); } catch (TimeoutException e) { - log.warn("Timeout while waiting for topic subscriber to stop gracefully", e); + logger.warn("Timeout while waiting for topic subscriber to stop gracefully", e); } } diff --git a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/message/SoapJmsMessageConverter.java b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/message/SoapJmsMessageConverter.java index 2adb52cc6a..e5014933ee 100644 --- a/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/message/SoapJmsMessageConverter.java +++ b/endpoints/citrus-jms/src/main/java/org/citrusframework/jms/message/SoapJmsMessageConverter.java @@ -59,7 +59,7 @@ public class SoapJmsMessageConverter extends JmsMessageConverter implements InitializingPhase, ReferenceResolverAware { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SoapJmsMessageConverter.class); + private static final Logger logger = LoggerFactory.getLogger(SoapJmsMessageConverter.class); /** Soap message factory - either set explicitly or auto configured through application context */ private SoapMessageFactory soapMessageFactory; @@ -123,7 +123,7 @@ public org.citrusframework.message.Message convertInbound(Message jmsMessage, Jm public Message createJmsMessage(org.citrusframework.message.Message message, Session session, JmsEndpointConfiguration endpointConfiguration, TestContext context) { String payload = message.getPayload(String.class); - LOG.debug("Creating SOAP message from payload: " + payload); + logger.debug("Creating SOAP message from payload: " + payload); try { SoapMessage soapMessage = soapMessageFactory.createWebServiceMessage(); diff --git a/endpoints/citrus-jms/src/test/java/org/citrusframework/jms/integration/service/LoggingInterceptor.java b/endpoints/citrus-jms/src/test/java/org/citrusframework/jms/integration/service/LoggingInterceptor.java index fe8e5711cc..d659decabd 100644 --- a/endpoints/citrus-jms/src/test/java/org/citrusframework/jms/integration/service/LoggingInterceptor.java +++ b/endpoints/citrus-jms/src/test/java/org/citrusframework/jms/integration/service/LoggingInterceptor.java @@ -26,12 +26,12 @@ * @author Christoph Deppisch */ public class LoggingInterceptor implements ChannelInterceptor { - private static final Logger log = LoggerFactory.getLogger(LoggingInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(LoggingInterceptor.class); @Override public Message preSend(Message message, MessageChannel channel) { - if (log.isDebugEnabled()) { - log.debug(channel.toString() + ": " + message.getPayload()); + if (logger.isDebugEnabled()) { + logger.debug(channel.toString() + ": " + message.getPayload()); } if (message.getPayload() instanceof Throwable) { diff --git a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/client/JmxClient.java b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/client/JmxClient.java index d72c3c1849..ef05f3addc 100644 --- a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/client/JmxClient.java +++ b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/client/JmxClient.java @@ -61,7 +61,7 @@ public class JmxClient extends AbstractEndpoint implements Producer, ReplyConsumer, NotificationListener { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmxClient.class); + private static final Logger logger = LoggerFactory.getLogger(JmxClient.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -113,9 +113,9 @@ public void send(Message message, TestContext context) { serverConnection = getNetworkConnection(); } - if (log.isDebugEnabled()) { - log.debug("Sending message to JMX MBeanServer server: '" + getEndpointConfiguration().getServerUrl() + "'"); - log.debug("Message to send:\n" + message.getPayload(String.class)); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to JMX MBeanServer server: '" + getEndpointConfiguration().getServerUrl() + "'"); + logger.debug("Message to send:\n" + message.getPayload(String.class)); } context.onOutboundMessage(message); @@ -226,7 +226,7 @@ public Message receive(String selector, TestContext context, long timeout) { public void handleNotification(Notification notification, Object handback) { JMXConnectionNotification connectionNotification = (JMXConnectionNotification) notification; if (connectionNotification.getConnectionId().equals(getConnectionId()) && connectionLost(connectionNotification)) { - log.warn("JmxClient lost JMX connection for : {}", getEndpointConfiguration().getServerUrl()); + logger.warn("JmxClient lost JMX connection for : {}", getEndpointConfiguration().getServerUrl()); if (getEndpointConfiguration().isAutoReconnect()) { scheduleReconnect(); } @@ -257,12 +257,12 @@ public void run() { serverConnection.addNotificationListener(objectName, notificationListener, getEndpointConfiguration().getNotificationFilter(), getEndpointConfiguration().getNotificationHandback()); } } catch (Exception e) { - log.warn("Failed to reconnect to JMX MBean server. {}", e.getMessage()); + logger.warn("Failed to reconnect to JMX MBean server. {}", e.getMessage()); scheduleReconnect(); } } }; - log.info("Reconnecting to MBean server {} in {} milliseconds.", getEndpointConfiguration().getServerUrl(), getEndpointConfiguration().getDelayOnReconnect()); + logger.info("Reconnecting to MBean server {} in {} milliseconds.", getEndpointConfiguration().getServerUrl(), getEndpointConfiguration().getDelayOnReconnect()); scheduledExecutor.schedule(startRunnable, getEndpointConfiguration().getDelayOnReconnect(), TimeUnit.MILLISECONDS); } diff --git a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxEndpointMBean.java b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxEndpointMBean.java index 3b6278ef30..d39d4bc9d3 100644 --- a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxEndpointMBean.java +++ b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxEndpointMBean.java @@ -53,7 +53,7 @@ public class JmxEndpointMBean implements DynamicMBean { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmxEndpointMBean.class); + private static final Logger logger = LoggerFactory.getLogger(JmxEndpointMBean.class); /** Endpoint adapter delegate */ private final EndpointAdapter endpointAdapter; @@ -129,8 +129,8 @@ public AttributeList setAttributes(AttributeList attributes) { @Override public Object invoke(String actionName, Object[] params, String[] signature) throws MBeanException, ReflectionException { - if (log.isDebugEnabled()) { - log.debug("Received message on JMX server: '" + endpointConfiguration.getServerUrl() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Received message on JMX server: '" + endpointConfiguration.getServerUrl() + "'"); } ManagedBeanInvocation mbeanInvocation = new ManagedBeanInvocation(); diff --git a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxServer.java b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxServer.java index db1a2f8d84..325d8e39b7 100644 --- a/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxServer.java +++ b/endpoints/citrus-jmx/src/main/java/org/citrusframework/jmx/server/JmxServer.java @@ -38,7 +38,7 @@ public class JmxServer extends AbstractServer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JmxServer.class); + private static final Logger logger = LoggerFactory.getLogger(JmxServer.class); /** Endpoint configuration */ private final JmxEndpointConfiguration endpointConfiguration; @@ -108,7 +108,7 @@ protected void shutdown() { server.unregisterMBean(mbean.createObjectName()); } } catch (Exception e) { - log.warn("Failed to unregister mBean:" + e.getMessage()); + logger.warn("Failed to unregister mBean:" + e.getMessage()); } } @@ -116,7 +116,7 @@ protected void shutdown() { try { jmxConnectorServer.stop(); } catch (IOException e) { - log.warn("Error during jmx connector shutdown: " + e.getMessage()); + logger.warn("Error during jmx connector shutdown: " + e.getMessage()); } } diff --git a/endpoints/citrus-jmx/src/test/java/org/citrusframework/jmx/mbean/HelloBeanImpl.java b/endpoints/citrus-jmx/src/test/java/org/citrusframework/jmx/mbean/HelloBeanImpl.java index 96a2c0fa70..3edd13aefe 100644 --- a/endpoints/citrus-jmx/src/test/java/org/citrusframework/jmx/mbean/HelloBeanImpl.java +++ b/endpoints/citrus-jmx/src/test/java/org/citrusframework/jmx/mbean/HelloBeanImpl.java @@ -26,7 +26,7 @@ public class HelloBeanImpl implements HelloBean { /** Logger */ - private static Logger log = LoggerFactory.getLogger(HelloBeanImpl.class); + private static final Logger logger = LoggerFactory.getLogger(HelloBeanImpl.class); private String helloMessage; @@ -42,7 +42,7 @@ public void setHelloMessage(String message) { @Override public String hello(String username) { - log.info(String.format(helloMessage, username)); + logger.info(String.format(helloMessage, username)); return String.format(helloMessage, username); } } diff --git a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/config/xml/KafkaEmbeddedServerParser.java b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/config/xml/KafkaEmbeddedServerParser.java index 3098f45621..e334c2d1c1 100644 --- a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/config/xml/KafkaEmbeddedServerParser.java +++ b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/config/xml/KafkaEmbeddedServerParser.java @@ -36,7 +36,7 @@ public class KafkaEmbeddedServerParser extends AbstractBeanDefinitionParser { protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) { BeanDefinitionBuilder builder = BeanDefinitionBuilder.genericBeanDefinition(EmbeddedKafkaServer.class); - BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("log-dir-path"), "logDirPath"); + BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("logger-dir-path"), "logDirPath"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("auto-delete-logs"), "autoDeleteLogs"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("zookeeper-port"), "zookeeperPort"); BeanDefinitionParserUtils.setPropertyValue(builder, element.getAttribute("kafka-server-port"), "kafkaServerPort"); diff --git a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServer.java b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServer.java index 7f0663c426..e9efe1a9bc 100644 --- a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServer.java +++ b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServer.java @@ -62,7 +62,7 @@ public class EmbeddedKafkaServer implements InitializingPhase, ShutdownPhase { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(EmbeddedKafkaServer.class); + private static final Logger logger = LoggerFactory.getLogger(EmbeddedKafkaServer.class); /** Zookeeper embedded server and factory */ private ZooKeeperServer zookeeper; @@ -83,10 +83,10 @@ public class EmbeddedKafkaServer implements InitializingPhase, ShutdownPhase { /** Topics to create on embedded server */ private String topics = "citrus"; - /** Path to log directory for Zookeeper server */ + /** Path to logger directory for Zookeeper server */ private String logDirPath; - /** Auto delete log dir on exit */ + /** Auto delete logger dir on exit */ private boolean autoDeleteLogs = true; /** Kafka broker server properties */ @@ -97,7 +97,7 @@ public class EmbeddedKafkaServer implements InitializingPhase, ShutdownPhase { */ public void start() { if (kafkaServer != null) { - LOG.debug("Found instance of Kafka server - avoid duplicate Kafka server startup"); + logger.debug("Found instance of Kafka server - avoid duplicate Kafka server startup"); return; } @@ -142,13 +142,13 @@ public void stop() { kafkaServer.awaitShutdown(); } } catch (Exception e) { - LOG.warn("Failed to shutdown Kafka embedded server", e); + logger.warn("Failed to shutdown Kafka embedded server", e); } try { CoreUtils.delete(kafkaServer.config().logDirs()); } catch (Exception e) { - LOG.warn("Failed to remove logs on Kafka embedded server", e); + logger.warn("Failed to remove logs on Kafka embedded server", e); } } @@ -156,7 +156,7 @@ public void stop() { try { serverFactory.shutdown(); } catch (Exception e) { - LOG.warn("Failed to shutdown Zookeeper instance", e); + logger.warn("Failed to shutdown Zookeeper instance", e); } } } @@ -184,7 +184,7 @@ protected ZooKeeperServer createZookeeperServer(File logDir) { } /** - * Creates Zookeeper log directory. By default logs are created in Java temp directory. + * Creates Zookeeper logger directory. By default logs are created in Java temp directory. * By default directory is automatically deleted on exit. * * @return @@ -197,9 +197,9 @@ protected File createLogDir() { if (!logDir.exists()) { if (!logDir.mkdirs()) { - LOG.warn("Unable to create log directory: " + logDir.getAbsolutePath()); + logger.warn("Unable to create logger directory: " + logDir.getAbsolutePath()); logDir = new File(System.getProperty("java.io.tmpdir")); - LOG.info("Using default log directory: " + logDir.getAbsolutePath()); + logger.info("Using default logger directory: " + logDir.getAbsolutePath()); } } @@ -241,7 +241,7 @@ protected void createKafkaTopics(Set topics) { try { createTopics.all().get(); } catch (Exception e) { - LOG.warn("Failed to create Kafka topics", e); + logger.warn("Failed to create Kafka topics", e); } } } @@ -274,8 +274,8 @@ protected Properties createBrokerProperties(String zooKeeperConnect, int kafkaSe props.put(KafkaConfig.ListenersProp(), SecurityProtocol.PLAINTEXT.name + "://localhost:" + kafkaServerPort); - if (LOG.isDebugEnabled()) { - props.forEach((key, value) -> LOG.debug(String.format("Using default Kafka broker property %s='%s'", key, value))); + if (logger.isDebugEnabled()) { + props.forEach((key, value) -> logger.debug(String.format("Using default Kafka broker property %s='%s'", key, value))); } return props; diff --git a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServerBuilder.java b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServerBuilder.java index e010ca3bb4..6553e75d5d 100644 --- a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServerBuilder.java +++ b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/embedded/EmbeddedKafkaServerBuilder.java @@ -107,7 +107,7 @@ public EmbeddedKafkaServerBuilder brokerProperties(Map propertie } /** - * Sets the Zookeeper log directory path. + * Sets the Zookeeper logger directory path. * @param logDirPath * @return */ diff --git a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaConsumer.java b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaConsumer.java index 1ca64fda7e..0bd25288b2 100644 --- a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaConsumer.java +++ b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaConsumer.java @@ -43,7 +43,7 @@ public class KafkaConsumer extends AbstractMessageConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(KafkaConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(KafkaConsumer.class); /** Endpoint configuration */ protected final KafkaEndpointConfiguration endpointConfiguration; @@ -67,8 +67,8 @@ public Message receive(TestContext context, long timeout) { String topic = context.replaceDynamicContentInString(Optional.ofNullable(endpointConfiguration.getTopic()) .orElseThrow(() -> new CitrusRuntimeException("Missing Kafka topic to receive messages from - add topic to endpoint configuration"))); - if (log.isDebugEnabled()) { - log.debug("Receiving Kafka message on topic: '" + topic); + if (logger.isDebugEnabled()) { + logger.debug("Receiving Kafka message on topic: '" + topic); } if (CollectionUtils.isEmpty(consumer.subscription())) { @@ -81,8 +81,8 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, topic); } - if (log.isDebugEnabled()) { - records.forEach(record -> log.debug("Received message: (" + record.key() + ", " + record.value() + ") at offset " + record.offset())); + if (logger.isDebugEnabled()) { + records.forEach(record -> logger.debug("Received message: (" + record.key() + ", " + record.value() + ") at offset " + record.offset())); } Message received = endpointConfiguration.getMessageConverter() @@ -91,7 +91,7 @@ public Message receive(TestContext context, long timeout) { consumer.commitSync(Duration.ofMillis(endpointConfiguration.getTimeout())); - log.info("Received Kafka message on topic: '" + topic); + logger.info("Received Kafka message on topic: '" + topic); return received; } diff --git a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaProducer.java b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaProducer.java index 3539943bfd..b7c4be9711 100644 --- a/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaProducer.java +++ b/endpoints/citrus-kafka/src/main/java/org/citrusframework/kafka/endpoint/KafkaProducer.java @@ -43,7 +43,7 @@ public class KafkaProducer implements Producer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(KafkaProducer.class); + private static final Logger logger = LoggerFactory.getLogger(KafkaProducer.class); /** The producer name. */ private final String name; @@ -78,14 +78,14 @@ public void send(final Message message, final TestContext context) { throw new CitrusRuntimeException(String.format("Invalid Kafka stream topic header %s - must not be empty or null", KafkaMessageHeaders.TOPIC)); } - if (log.isDebugEnabled()) { - log.debug("Sending Kafka stream message to topic: '" + topic + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending Kafka stream message to topic: '" + topic + "'"); } try { ProducerRecord producerRecord = endpointConfiguration.getMessageConverter().convertOutbound(message, endpointConfiguration, context); producer.send(producerRecord).get(endpointConfiguration.getTimeout(), TimeUnit.MILLISECONDS); - log.info("Message was sent to Kafka stream topic: '" + topic + "'"); + logger.info("Message was sent to Kafka stream topic: '" + topic + "'"); } catch (InterruptedException | ExecutionException e) { throw new CitrusRuntimeException(String.format("Failed to send message to Kafka topic '%s'", topic), e); } catch (TimeoutException e) { diff --git a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/client/MailClient.java b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/client/MailClient.java index 864dce0c76..0c586c7fab 100644 --- a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/client/MailClient.java +++ b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/client/MailClient.java @@ -41,7 +41,7 @@ */ public class MailClient extends AbstractEndpoint implements Producer, InitializingPhase { - private static Logger log = LoggerFactory.getLogger(MailClient.class); + private static final Logger logger = LoggerFactory.getLogger(MailClient.class); private MailSender mailSender = new MailSender(); @@ -66,8 +66,8 @@ public MailEndpointConfiguration getEndpointConfiguration() { @Override public void send(Message message, TestContext context) { - if (log.isDebugEnabled()) { - log.debug(String.format("Sending mail message to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Sending mail message to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); } MimeMailMessage mimeMessage = getEndpointConfiguration().getMessageConverter().convertOutbound(message, getEndpointConfiguration(), context); @@ -89,13 +89,13 @@ public void send(Message message, TestContext context) { try { bos.close(); } catch (IOException e) { - log.warn("Failed to close output stream", e); + logger.warn("Failed to close output stream", e); } } context.onOutboundMessage(mailMessage); - log.info(String.format("Mail message was sent to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); + logger.info(String.format("Mail message was sent to host: '%s://%s:%s'", getEndpointConfiguration().getProtocol(), getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort())); } /** diff --git a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/message/MailMessageConverter.java b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/message/MailMessageConverter.java index 452b17d876..24924f0809 100644 --- a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/message/MailMessageConverter.java +++ b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/message/MailMessageConverter.java @@ -61,7 +61,7 @@ public class MailMessageConverter implements MessageConverter { /** Logger */ - private static Logger log = LoggerFactory.getLogger(MailMessageConverter.class); + private static final Logger logger = LoggerFactory.getLogger(MailMessageConverter.class); /** Mail delivery date format */ private SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ"); @@ -72,7 +72,7 @@ public MimeMailMessage convertOutbound(Message message, MailEndpointConfiguratio try { Session session = Session.getInstance(endpointConfiguration.getJavaMailProperties(), endpointConfiguration.getAuthenticator()); - session.setDebug(log.isDebugEnabled()); + session.setDebug(logger.isDebugEnabled()); MimeMessage mimeMessage = new MimeMessage(session); MimeMailMessage mimeMailMessage = new MimeMailMessage(new MimeMessageHelper(mimeMessage, @@ -311,7 +311,7 @@ private String stripMailBodyEnding(String textBody) throws IOException { try { reader.close(); } catch (IOException e) { - log.warn("Failed to close reader", e); + logger.warn("Failed to close reader", e); } } } @@ -369,7 +369,7 @@ static String parseContentType(String contentType) throws IOException { try { reader.close(); } catch (IOException e) { - log.warn("Failed to close reader", e); + logger.warn("Failed to close reader", e); } } } diff --git a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/model/MailMarshaller.java b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/model/MailMarshaller.java index 227aeb7576..9474201964 100644 --- a/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/model/MailMarshaller.java +++ b/endpoints/citrus-mail/src/main/java/org/citrusframework/mail/model/MailMarshaller.java @@ -43,7 +43,7 @@ public class MailMarshaller implements Marshaller, Unmarshaller { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(MailMarshaller.class); + private static final Logger logger = LoggerFactory.getLogger(MailMarshaller.class); /** System property defining message format to marshal to */ private static final String MAIL_MARSHALLER_TYPE_PROPERTY = "citrus.mail.marshaller.type"; @@ -78,7 +78,7 @@ public Object unmarshal(Source source) { } catch (JsonParseException | JsonMappingException e2) { continue; } catch (IOException io) { - log.warn("Unable to read mail JSON object from source", io); + logger.warn("Unable to read mail JSON object from source", io); throw new CitrusRuntimeException("Failed to unmarshal source", io); } } diff --git a/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/client/RmiClient.java b/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/client/RmiClient.java index 8de2f78f38..522f8893ec 100644 --- a/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/client/RmiClient.java +++ b/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/client/RmiClient.java @@ -53,7 +53,7 @@ public class RmiClient extends AbstractEndpoint implements Producer, ReplyConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(RmiClient.class); + private static final Logger logger = LoggerFactory.getLogger(RmiClient.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -108,9 +108,9 @@ public void send(final Message message, TestContext context) { throw new CitrusRuntimeException("Unable to find proper method declaration on remote target object"); } - if (log.isDebugEnabled()) { - log.debug("Sending message to RMI server: '" + binding + "'"); - log.debug("Message to send:\n" + message.getPayload(String.class)); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to RMI server: '" + binding + "'"); + logger.debug("Message to send:\n" + message.getPayload(String.class)); } context.onOutboundMessage(message); @@ -129,7 +129,7 @@ public void send(final Message message, TestContext context) { Message response = new DefaultMessage(payload.toString()); correlationManager.store(correlationKey, response); - log.info("Message was sent to RMI server: '" + binding + "'"); + logger.info("Message was sent to RMI server: '" + binding + "'"); if (result != null) { context.onInboundMessage(response); } @@ -143,7 +143,7 @@ public void send(final Message message, TestContext context) { throw new CitrusRuntimeException("Failed to invoke method on remote target, because remote method not accessible", e); } - log.info("Message was sent to RMI server: '" + binding + "'"); + logger.info("Message was sent to RMI server: '" + binding + "'"); } @Override diff --git a/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/server/RmiServer.java b/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/server/RmiServer.java index c46a06470f..845ccb8053 100644 --- a/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/server/RmiServer.java +++ b/endpoints/citrus-rmi/src/main/java/org/citrusframework/rmi/server/RmiServer.java @@ -46,7 +46,7 @@ public class RmiServer extends AbstractServer implements InvocationHandler { /** Logger */ - private static Logger log = LoggerFactory.getLogger(RmiServer.class); + private static final Logger logger = LoggerFactory.getLogger(RmiServer.class); /** Endpoint configuration */ private final RmiEndpointConfiguration endpointConfiguration; @@ -79,8 +79,8 @@ public RmiServer(RmiEndpointConfiguration endpointConfiguration) { @Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { - if (log.isDebugEnabled()) { - log.debug("Received message on RMI server: '" + endpointConfiguration.getBinding() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Received message on RMI server: '" + endpointConfiguration.getBinding() + "'"); } Message response = getEndpointAdapter().handleMessage(endpointConfiguration.getMessageConverter() @@ -155,7 +155,7 @@ protected void shutdown() { try { registry.unbind(endpointConfiguration.getBinding()); } catch (Exception e) { - log.warn("Failed to unbind from registry:" + e.getMessage()); + logger.warn("Failed to unbind from registry:" + e.getMessage()); } } @@ -163,7 +163,7 @@ protected void shutdown() { try { UnicastRemoteObject.unexportObject(proxy, true); } catch (Exception e) { - log.warn("Failed to unexport from remote object:" + e.getMessage()); + logger.warn("Failed to unexport from remote object:" + e.getMessage()); } } diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/actions/PurgeMessageChannelAction.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/actions/PurgeMessageChannelAction.java index ad99c54217..66663af9f0 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/actions/PurgeMessageChannelAction.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/actions/PurgeMessageChannelAction.java @@ -58,7 +58,7 @@ public class PurgeMessageChannelAction extends AbstractTestAction { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(PurgeMessageChannelAction.class); + private static final Logger logger = LoggerFactory.getLogger(PurgeMessageChannelAction.class); /** * Default constructor. @@ -74,8 +74,8 @@ public PurgeMessageChannelAction(Builder builder) { @Override public void doExecute(TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Purging message channels ..."); + if (logger.isDebugEnabled()) { + logger.debug("Purging message channels ..."); } for (MessageChannel channel : channels) { @@ -86,7 +86,7 @@ public void doExecute(TestContext context) { purgeChannel(resolveChannelName(channelName)); } - log.info("Purged message channels"); + logger.info("Purged message channels"); } /** @@ -99,8 +99,8 @@ private void purgeChannel(MessageChannel channel) { if (channel instanceof QueueChannel) { List> messages = ((QueueChannel)channel).purge(messageSelector); - if (log.isDebugEnabled()) { - log.debug("Purged channel " + ((QueueChannel)channel).getComponentName() + " - removed " + messages.size() + " messages"); + if (logger.isDebugEnabled()) { + logger.debug("Purged channel " + ((QueueChannel)channel).getComponentName() + " - removed " + messages.size() + " messages"); } } } diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelConsumer.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelConsumer.java index eb283d6ea5..b7cadb5e49 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelConsumer.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelConsumer.java @@ -39,7 +39,7 @@ public class ChannelConsumer extends AbstractSelectiveMessageConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ChannelConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(ChannelConsumer.class); /** Endpoint configuration */ private ChannelEndpointConfiguration endpointConfiguration; @@ -65,8 +65,8 @@ public Message receive(String selector, TestContext context, long timeout) { destinationChannelName = getDestinationChannelName(); } - if (log.isDebugEnabled()) { - log.debug("Receiving message from: " + destinationChannelName); + if (logger.isDebugEnabled()) { + logger.debug("Receiving message from: " + destinationChannelName); } Message message; @@ -99,7 +99,7 @@ public Message receive(String selector, TestContext context, long timeout) { throw new MessageTimeoutException(timeout, destinationChannelName); } - log.debug("Received message from: " + destinationChannelName); + logger.debug("Received message from: " + destinationChannelName); return message; } diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelEndpointAdapter.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelEndpointAdapter.java index d5dc3abff8..11882cae1f 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelEndpointAdapter.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelEndpointAdapter.java @@ -43,7 +43,7 @@ public class ChannelEndpointAdapter extends AbstractEndpointAdapter { private final ChannelSyncEndpointConfiguration endpointConfiguration; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ChannelEndpointAdapter.class); + private static final Logger logger = LoggerFactory.getLogger(ChannelEndpointAdapter.class); /** * Default constructor using endpoint configuration. @@ -61,7 +61,7 @@ public ChannelEndpointAdapter(ChannelSyncEndpointConfiguration endpointConfigura @Override public Message handleMessageInternal(Message request) { - LOG.debug("Forwarding request to message channel ..."); + logger.debug("Forwarding request to message channel ..."); TestContext context = getTestContext(); Message replyMessage = null; @@ -73,7 +73,7 @@ public Message handleMessageInternal(Message request) { replyMessage = producer.receive(context, endpointConfiguration.getTimeout()); } } catch (ActionTimeoutException e) { - LOG.warn(e.getMessage()); + logger.warn(e.getMessage()); } return replyMessage; diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelProducer.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelProducer.java index 46e7cedc6f..0ee8a3bc2d 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelProducer.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelProducer.java @@ -36,7 +36,7 @@ */ public class ChannelProducer implements Producer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ChannelProducer.class); + private static final Logger logger = LoggerFactory.getLogger(ChannelProducer.class); /** The producer name */ private final String name; @@ -58,12 +58,12 @@ public ChannelProducer(String name, ChannelEndpointConfiguration endpointConfigu public void send(Message message, TestContext context) { String destinationChannelName = getDestinationChannelName(); - if (log.isDebugEnabled()) { - log.debug("Sending message to channel: '" + destinationChannelName + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to channel: '" + destinationChannelName + "'"); } - if (log.isDebugEnabled()) { - log.debug("Message to send is:" + System.getProperty("line.separator") + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Message to send is:" + System.getProperty("line.separator") + message.toString()); } try { @@ -73,7 +73,7 @@ public void send(Message message, TestContext context) { throw new CitrusRuntimeException("Failed to send message to channel: '" + destinationChannelName + "'", e); } - log.info("Message was sent to channel: '" + destinationChannelName + "'"); + logger.info("Message was sent to channel: '" + destinationChannelName + "'"); } /** diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncConsumer.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncConsumer.java index fa157fe39f..8542cc5584 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncConsumer.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncConsumer.java @@ -35,7 +35,7 @@ */ public class ChannelSyncConsumer extends ChannelConsumer implements ReplyProducer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ChannelSyncConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(ChannelSyncConsumer.class); /** Reply channel store */ private CorrelationManager correlationManager; @@ -72,9 +72,9 @@ public void send(Message message, TestContext context) { MessageChannel replyChannel = correlationManager.find(correlationKey, endpointConfiguration.getTimeout()); Assert.notNull(replyChannel, "Failed to find reply channel for message correlation key: " + correlationKey); - if (log.isDebugEnabled()) { - log.debug("Sending message to reply channel: '" + replyChannel + "'"); - log.debug("Message to send is:\n" + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to reply channel: '" + replyChannel + "'"); + logger.debug("Message to send is:\n" + message.toString()); } try { @@ -84,7 +84,7 @@ public void send(Message message, TestContext context) { throw new CitrusRuntimeException("Failed to send message to channel: '" + replyChannel + "'", e); } - log.info("Message was sent to reply channel: '" + replyChannel + "'"); + logger.info("Message was sent to reply channel: '" + replyChannel + "'"); } /** @@ -106,7 +106,7 @@ public void saveReplyMessageChannel(Message receivedMessage, TestContext context correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, replyChannel); } else { - log.warn("Unable to retrieve reply message channel for message \n" + + logger.warn("Unable to retrieve reply message channel for message \n" + receivedMessage + "\n - no reply channel found in message headers!"); } } diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncProducer.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncProducer.java index 6161ff891c..2c5d819b83 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncProducer.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/ChannelSyncProducer.java @@ -36,7 +36,7 @@ */ public class ChannelSyncProducer extends ChannelProducer implements ReplyConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(ChannelSyncProducer.class); + private static final Logger logger = LoggerFactory.getLogger(ChannelSyncProducer.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -65,14 +65,14 @@ public void send(Message message, TestContext context) { String destinationChannelName = getDestinationChannelName(); - if (log.isDebugEnabled()) { - log.debug("Sending message to channel: '" + destinationChannelName + "'"); - log.debug("Message to send is:\n" + message.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to channel: '" + destinationChannelName + "'"); + logger.debug("Message to send is:\n" + message.toString()); } endpointConfiguration.getMessagingTemplate().setReceiveTimeout(endpointConfiguration.getTimeout()); - log.info("Message was sent to channel: '" + destinationChannelName + "'"); + logger.info("Message was sent to channel: '" + destinationChannelName + "'"); org.springframework.messaging.Message replyMessage = endpointConfiguration.getMessagingTemplate().sendAndReceive(getDestinationChannel(context), endpointConfiguration.getMessageConverter().convertOutbound(message, endpointConfiguration, context)); @@ -80,7 +80,7 @@ public void send(Message message, TestContext context) { if (replyMessage == null) { throw new ReplyMessageTimeoutException(endpointConfiguration.getTimeout(), destinationChannelName); } else { - log.info("Received synchronous response from reply channel '" + destinationChannelName + "'"); + logger.info("Received synchronous response from reply channel '" + destinationChannelName + "'"); } correlationManager.store(correlationKey, endpointConfiguration.getMessageConverter().convertInbound(replyMessage, endpointConfiguration, context)); diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/RootQNameMessageSelector.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/RootQNameMessageSelector.java index 485a637f86..961c59bc1a 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/RootQNameMessageSelector.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/RootQNameMessageSelector.java @@ -43,7 +43,7 @@ public class RootQNameMessageSelector extends AbstractMessageSelector { public static final String SELECTOR_ID = "root-qname"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(RootQNameMessageSelector.class); + private static final Logger logger = LoggerFactory.getLogger(RootQNameMessageSelector.class); /** * Default constructor using fields. @@ -69,7 +69,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - log.warn("Root QName message selector ignoring not well-formed XML message payload", e); + logger.warn("Root QName message selector ignoring not well-formed XML message payload", e); return false; // non XML message - not accepted } diff --git a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/XpathPayloadMessageSelector.java b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/XpathPayloadMessageSelector.java index eb9eb25b8e..cd01b07e93 100644 --- a/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/XpathPayloadMessageSelector.java +++ b/endpoints/citrus-spring-integration/src/main/java/org/citrusframework/channel/selector/XpathPayloadMessageSelector.java @@ -44,7 +44,7 @@ public class XpathPayloadMessageSelector extends AbstractMessageSelector { public static final String SELECTOR_PREFIX = "xpath:"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(XpathPayloadMessageSelector.class); + private static final Logger logger = LoggerFactory.getLogger(XpathPayloadMessageSelector.class); /** * Default constructor using fields. @@ -60,7 +60,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - log.warn("Ignoring non XML message for XPath message selector (" + e.getClass().getName() + ")"); + logger.warn("Ignoring non XML message for XPath message selector (" + e.getClass().getName() + ")"); return false; // non XML message - not accepted } @@ -82,7 +82,7 @@ public boolean accept(Message message) { return evaluate(value); } catch (XPathParseException e) { - log.warn("Could not evaluate XPath expression for message selector - ignoring message (" + e.getClass().getName() + ")"); + logger.warn("Could not evaluate XPath expression for message selector - ignoring message (" + e.getClass().getName() + ")"); return false; // wrong XML message - not accepted } } diff --git a/endpoints/citrus-spring-integration/src/test/java/org/citrusframework/integration/service/LoggingInterceptor.java b/endpoints/citrus-spring-integration/src/test/java/org/citrusframework/integration/service/LoggingInterceptor.java index 4e0379d750..e1bf749189 100644 --- a/endpoints/citrus-spring-integration/src/test/java/org/citrusframework/integration/service/LoggingInterceptor.java +++ b/endpoints/citrus-spring-integration/src/test/java/org/citrusframework/integration/service/LoggingInterceptor.java @@ -26,12 +26,12 @@ * @author Christoph Deppisch */ public class LoggingInterceptor implements ChannelInterceptor { - private static final Logger log = LoggerFactory.getLogger(LoggingInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(LoggingInterceptor.class); @Override public Message preSend(Message message, MessageChannel channel) { - if (log.isDebugEnabled()) { - log.debug(channel.toString() + ": " + message.getPayload()); + if (logger.isDebugEnabled()) { + logger.debug(channel.toString() + ": " + message.getPayload()); } if (message.getPayload() instanceof Throwable) { diff --git a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/SshCommand.java b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/SshCommand.java index 1265e2aee4..9a23a98d8c 100644 --- a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/SshCommand.java +++ b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/SshCommand.java @@ -43,7 +43,7 @@ public class SshCommand implements Command, Runnable { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SshCommand.class); + private static final Logger logger = LoggerFactory.getLogger(SshCommand.class); /** Endpoint adapter for creating requests/responses **/ private final EndpointAdapter endpointAdapter; @@ -106,7 +106,7 @@ public void run() { @Override public void destroy(ChannelSession session) { - log.warn("Destroy has been called"); + logger.warn("Destroy has been called"); } @Override diff --git a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/model/SshMarshaller.java b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/model/SshMarshaller.java index c6a0276a0d..2e8af920fe 100644 --- a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/model/SshMarshaller.java +++ b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/model/SshMarshaller.java @@ -35,7 +35,7 @@ public class SshMarshaller implements Marshaller, Unmarshaller { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(SshMarshaller.class); + private static final Logger logger = LoggerFactory.getLogger(SshMarshaller.class); private final Jaxb2Marshaller marshaller; diff --git a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/server/SinglePublicKeyAuthenticator.java b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/server/SinglePublicKeyAuthenticator.java index b9dfc94fa0..cf52e6996c 100644 --- a/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/server/SinglePublicKeyAuthenticator.java +++ b/endpoints/citrus-ssh/src/main/java/org/citrusframework/ssh/server/SinglePublicKeyAuthenticator.java @@ -41,7 +41,7 @@ class SinglePublicKeyAuthenticator implements PublickeyAuthenticator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SinglePublicKeyAuthenticator.class); + private static final Logger logger = LoggerFactory.getLogger(SinglePublicKeyAuthenticator.class); private PublicKey allowedKey; private String user; @@ -100,7 +100,7 @@ private PublicKey readKey(InputStream is) { } } catch (IOException e) { // Ignoring, returning null - log.warn("Failed to get key from PEM file", e); + logger.warn("Failed to get key from PEM file", e); } finally { IoUtils.closeQuietly(isr,r); } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxConsumer.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxConsumer.java index 22fd64b2b8..d070c6f2df 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxConsumer.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxConsumer.java @@ -39,7 +39,7 @@ public class VertxConsumer extends AbstractMessageConsumer { private final VertxEndpointConfiguration endpointConfiguration; /** Logger */ - private static final Logger log = LoggerFactory.getLogger(VertxConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(VertxConsumer.class); /** Retry logger */ private static final Logger RETRY_LOG = LoggerFactory.getLogger("org.citrusframework.RetryLogger"); @@ -58,8 +58,8 @@ public VertxConsumer(String name, Vertx vertx, VertxEndpointConfiguration endpoi @Override public Message receive(TestContext context, long timeout) { - if (log.isDebugEnabled()) { - log.debug("Receiving message on Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Receiving message on Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); } VertxSingleMessageHandler vertxMessageHandler = new VertxSingleMessageHandler(); @@ -91,7 +91,7 @@ public Message receive(TestContext context, long timeout) { throw new MessageTimeoutException(timeout, endpointConfiguration.getAddress()); } - log.info("Received message on Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + logger.info("Received message on Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); context.onInboundMessage(message); @@ -113,8 +113,8 @@ public void handle(io.vertx.core.eventbus.Message event) { if (message == null) { this.message = event; } else { - log.warn("Vert.x message handler ignored message on event bus address '" + endpointConfiguration.getAddress() + "'"); - log.debug("Vert.x message ignored is " + event); + logger.warn("Vert.x message handler ignored message on event bus address '" + endpointConfiguration.getAddress() + "'"); + logger.debug("Vert.x message ignored is " + event); } } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxEndpointComponent.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxEndpointComponent.java index f7b61374f5..52d9170b01 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxEndpointComponent.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxEndpointComponent.java @@ -34,7 +34,7 @@ public class VertxEndpointComponent extends AbstractEndpointComponent { public static final String VERTX_INSTANCE_FACTORY = "vertxInstanceFactory"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(VertxEndpointComponent.class); + private static final Logger logger = LoggerFactory.getLogger(VertxEndpointComponent.class); /** * Default constructor using the name for this component. @@ -71,14 +71,14 @@ protected Endpoint createEndpoint(String resourcePath, Map param if (context.getReferenceResolver() != null) { endpoint.setVertxInstanceFactory(context.getReferenceResolver().resolve(vertFactoryBean, VertxInstanceFactory.class)); } else { - log.warn("Unable to set custom Vert.x instance factory as Spring application context is not accessible!"); + logger.warn("Unable to set custom Vert.x instance factory as Spring application context is not accessible!"); } } else { // set default jms connection factory if (context.getReferenceResolver() != null && context.getReferenceResolver().isResolvable(VERTX_INSTANCE_FACTORY)) { endpoint.setVertxInstanceFactory(context.getReferenceResolver().resolve(VERTX_INSTANCE_FACTORY, VertxInstanceFactory.class)); } else { - log.warn("Unable to set default Vert.x instance factory as Spring application context is not accessible or default factory bean is not available!"); + logger.warn("Unable to set default Vert.x instance factory as Spring application context is not accessible or default factory bean is not available!"); } } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxProducer.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxProducer.java index ce983462fc..85787d92e9 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxProducer.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxProducer.java @@ -31,7 +31,7 @@ public class VertxProducer implements Producer { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(VertxProducer.class); + private static final Logger logger = LoggerFactory.getLogger(VertxProducer.class); /** The producer name. */ private final String name; @@ -59,12 +59,12 @@ public void send(Message message, TestContext context) { sendOrPublishMessage(message); } catch (IllegalStateException e) { if (e.getMessage().equals("Event Bus is not started")) { - log.warn("Event bus not started yet - retrying in 2000 ms"); + logger.warn("Event bus not started yet - retrying in 2000 ms"); try { Thread.sleep(2000L); } catch (InterruptedException ex) { - log.warn("Interrupted while waiting fot event bus to start", ex); + logger.warn("Interrupted while waiting fot event bus to start", ex); } sendOrPublishMessage(message); @@ -75,7 +75,7 @@ public void send(Message message, TestContext context) { context.onOutboundMessage(message); - log.info("Message was sent to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + logger.info("Message was sent to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); } /** @@ -87,13 +87,13 @@ private void sendOrPublishMessage(Message message) { deliveryOptions.setSendTimeout(endpointConfiguration.getTimeout()); if (endpointConfiguration.isPubSubDomain()) { - if (log.isDebugEnabled()) { - log.debug("Publish Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Publish Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); } vertx.eventBus().publish(endpointConfiguration.getAddress(), message.getPayload(), deliveryOptions); } else { - if (log.isDebugEnabled()) { - log.debug("Sending Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending Vert.x event bus message to address: '" + endpointConfiguration.getAddress() + "'"); } vertx.eventBus().send(endpointConfiguration.getAddress(), message.getPayload(), deliveryOptions); } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncConsumer.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncConsumer.java index a8db4f2599..55beaa1ba9 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncConsumer.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncConsumer.java @@ -34,7 +34,7 @@ public class VertxSyncConsumer extends VertxConsumer implements ReplyProducer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(VertxSyncConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(VertxSyncConsumer.class); /** Map of reply destinations */ private CorrelationManager correlationManager; @@ -76,15 +76,15 @@ public void send(Message message, TestContext context) { String replyAddress = correlationManager.find(correlationKey, endpointConfiguration.getTimeout()); Assert.notNull(replyAddress, "Failed to find reply address for message correlation key: '" + correlationKey + "'"); - if (log.isDebugEnabled()) { - log.debug("Sending Vert.x message to event bus address: '" + replyAddress + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending Vert.x message to event bus address: '" + replyAddress + "'"); } vertx.eventBus().send(replyAddress, message.getPayload()); context.onOutboundMessage(message); - log.info("Message was sent to Vert.x event bus address: '" + replyAddress + "'"); + logger.info("Message was sent to Vert.x event bus address: '" + replyAddress + "'"); } /** @@ -101,7 +101,7 @@ public void saveReplyDestination(Message receivedMessage, TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); correlationManager.store(correlationKey, receivedMessage.getHeader(CitrusVertxMessageHeaders.VERTX_REPLY_ADDRESS).toString()); } else { - log.warn("Unable to retrieve reply address for message \n" + + logger.warn("Unable to retrieve reply address for message \n" + receivedMessage + "\n - no reply address found in message headers!"); } } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncProducer.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncProducer.java index 1da1b7d609..5e9341abb4 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncProducer.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/endpoint/VertxSyncProducer.java @@ -36,7 +36,7 @@ public class VertxSyncProducer extends VertxProducer implements ReplyConsumer { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(VertxSyncProducer.class); + private static final Logger logger = LoggerFactory.getLogger(VertxSyncProducer.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -64,8 +64,8 @@ public VertxSyncProducer(String name, Vertx vertx, VertxSyncEndpointConfiguratio @Override public void send(Message message, final TestContext context) { - if (log.isDebugEnabled()) { - log.debug("Sending message to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Sending message to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); } String correlationKeyName = endpointConfiguration.getCorrelator().getCorrelationKeyName(getName()); @@ -73,13 +73,13 @@ public void send(Message message, final TestContext context) { correlationManager.saveCorrelationKey(correlationKeyName, correlationKey, context); context.onOutboundMessage(message); - log.info("Message was sent to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); + logger.info("Message was sent to Vert.x event bus address: '" + endpointConfiguration.getAddress() + "'"); DeliveryOptions deliveryOptions = new DeliveryOptions(); deliveryOptions.setSendTimeout(endpointConfiguration.getTimeout()); vertx.eventBus().request(endpointConfiguration.getAddress(), message.getPayload(), deliveryOptions, event -> { - log.info("Received synchronous response on Vert.x event bus reply address"); + logger.info("Received synchronous response on Vert.x event bus reply address"); Message responseMessage = endpointConfiguration.getMessageConverter().convertInbound(event.result(), endpointConfiguration, context); diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/AbstractVertxInstanceFactory.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/AbstractVertxInstanceFactory.java index afb3f7afa8..f644fd1095 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/AbstractVertxInstanceFactory.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/AbstractVertxInstanceFactory.java @@ -41,7 +41,7 @@ public abstract class AbstractVertxInstanceFactory implements VertxInstanceFactory { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(AbstractVertxInstanceFactory.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractVertxInstanceFactory.class); /** * Creates new Vert.x instance with default factory. Subclasses may overwrite this @@ -53,11 +53,11 @@ protected Vertx createVertx(VertxEndpointConfiguration endpointConfiguration) { Handler> asyncLoadingHandler = event -> { loading.complete(event.result()); - log.info("Vert.x instance started"); + logger.info("Vert.x instance started"); }; - if (log.isDebugEnabled()) { - log.debug("Creating new Vert.x instance ..."); + if (logger.isDebugEnabled()) { + logger.debug("Creating new Vert.x instance ..."); } VertxOptions vertxOptions = new VertxOptions(); @@ -73,9 +73,9 @@ protected Vertx createVertx(VertxEndpointConfiguration endpointConfiguration) { return vertx; } } catch (InterruptedException | ExecutionException e) { - log.warn("Interrupted while waiting for Vert.x instance startup", e); + logger.warn("Interrupted while waiting for Vert.x instance startup", e); } catch (TimeoutException e) { - log.debug("Waiting for Vert.x instance to startup ..."); + logger.debug("Waiting for Vert.x instance to startup ..."); } } diff --git a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/SingleVertxInstanceFactory.java b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/SingleVertxInstanceFactory.java index e69f04ed6d..ddf75d57cc 100644 --- a/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/SingleVertxInstanceFactory.java +++ b/endpoints/citrus-vertx/src/main/java/org/citrusframework/vertx/factory/SingleVertxInstanceFactory.java @@ -30,7 +30,7 @@ public class SingleVertxInstanceFactory extends AbstractVertxInstanceFactory { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SingleVertxInstanceFactory.class); + private static final Logger logger = LoggerFactory.getLogger(SingleVertxInstanceFactory.class); /** Vert.x instance */ private Vertx vertx; @@ -44,7 +44,7 @@ public final Vertx newInstance(VertxEndpointConfiguration endpointConfiguration) try { Thread.sleep(5000L); } catch (InterruptedException e) { - log.warn("Interrupted while waiting for vert.x instance to start up", e); + logger.warn("Interrupted while waiting for vert.x instance to start up", e); } return vertx; diff --git a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/client/WebSocketClientEndpointConfiguration.java b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/client/WebSocketClientEndpointConfiguration.java index 94c0269260..e70a9cf74d 100644 --- a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/client/WebSocketClientEndpointConfiguration.java +++ b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/client/WebSocketClientEndpointConfiguration.java @@ -41,7 +41,7 @@ public class WebSocketClientEndpointConfiguration extends AbstractWebSocketEndpointConfiguration { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WebSocketClientEndpointConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger(WebSocketClientEndpointConfiguration.class); /** Web socket handler */ private CitrusWebSocketHandler handler; @@ -83,7 +83,7 @@ private CitrusWebSocketHandler getWebSocketClientHandler(String url) { future.get(); } catch (Exception e) { String errMsg = String.format("Failed to connect to Web Socket server - '%s'", url); - LOG.error(errMsg); + logger.error(errMsg); throw new CitrusRuntimeException(errMsg); } return handler; diff --git a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketConsumer.java b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketConsumer.java index 1352c9864a..c6f2dd7221 100644 --- a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketConsumer.java +++ b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketConsumer.java @@ -32,7 +32,7 @@ public class WebSocketConsumer extends AbstractSelectiveMessageConsumer { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WebSocketConsumer.class); + private static final Logger logger = LoggerFactory.getLogger(WebSocketConsumer.class); /** * Endpoint configuration @@ -52,12 +52,12 @@ public WebSocketConsumer(String name, WebSocketEndpointConfiguration endpointCon @Override public Message receive(String selector, TestContext context, long timeout) { - LOG.info(String.format("Waiting %s ms for Web Socket message ...", timeout)); + logger.info(String.format("Waiting %s ms for Web Socket message ...", timeout)); WebSocketMessage message = receive(endpointConfiguration, timeout); Message receivedMessage = endpointConfiguration.getMessageConverter().convertInbound(message, endpointConfiguration, context); - LOG.info("Received Web Socket message"); + logger.info("Received Web Socket message"); context.onInboundMessage(receivedMessage); return receivedMessage; @@ -77,15 +77,15 @@ private WebSocketMessage receive(WebSocketEndpointConfiguration config, long while (message == null && timeLeft > 0) { timeLeft -= endpointConfiguration.getPollingInterval(); long sleep = timeLeft > 0 ? endpointConfiguration.getPollingInterval() : endpointConfiguration.getPollingInterval() + timeLeft; - if (LOG.isDebugEnabled()) { + if (logger.isDebugEnabled()) { String msg = "Waiting for message on '%s' - retrying in %s ms"; - LOG.debug(String.format(msg, endpointUri, (sleep))); + logger.debug(String.format(msg, endpointUri, (sleep))); } try { Thread.sleep(sleep); } catch (InterruptedException e) { - LOG.warn(String.format("Thread interrupted while waiting for message on '%s'", endpointUri), e); + logger.warn(String.format("Thread interrupted while waiting for message on '%s'", endpointUri), e); } message = config.getHandler().getMessage(); diff --git a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketProducer.java b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketProducer.java index 0ef29491a5..015d149fb7 100644 --- a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketProducer.java +++ b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/endpoint/WebSocketProducer.java @@ -33,7 +33,7 @@ public class WebSocketProducer implements Producer { /** * Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WebSocketProducer.class); + private static final Logger logger = LoggerFactory.getLogger(WebSocketProducer.class); private final String name; private final WebSocketEndpointConfiguration endpointConfiguration; @@ -53,13 +53,13 @@ public WebSocketProducer(String name, WebSocketEndpointConfiguration endpointCon public void send(Message message, TestContext context) { Assert.notNull(message, "Message is empty - unable to send empty message"); - LOG.info("Sending WebSocket message ..."); + logger.info("Sending WebSocket message ..."); context.onOutboundMessage(message); WebSocketMessage wsMessage = endpointConfiguration.getMessageConverter().convertOutbound(message, endpointConfiguration, context); if (endpointConfiguration.getHandler().sendMessage(wsMessage)) { - LOG.info("WebSocket Message was successfully sent"); + logger.info("WebSocket Message was successfully sent"); } } diff --git a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/handler/CitrusWebSocketHandler.java b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/handler/CitrusWebSocketHandler.java index 5db5e808a9..fd34a1a565 100644 --- a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/handler/CitrusWebSocketHandler.java +++ b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/handler/CitrusWebSocketHandler.java @@ -35,7 +35,7 @@ */ public class CitrusWebSocketHandler extends AbstractWebSocketHandler { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusWebSocketHandler.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusWebSocketHandler.class); /** Inbound message cache */ private final Queue> inboundMessages = new LinkedList<>(); @@ -45,36 +45,36 @@ public class CitrusWebSocketHandler extends AbstractWebSocketHandler { @Override public void afterConnectionEstablished(WebSocketSession session) throws Exception { - LOG.debug(String.format("WebSocket connection established (%s)", session.getId())); + logger.debug(String.format("WebSocket connection established (%s)", session.getId())); sessions.put(session.getId(), session); } @Override protected void handleTextMessage(WebSocketSession session, TextMessage message) throws Exception { - LOG.debug(String.format("WebSocket endpoint (%s) received text message", session.getId())); + logger.debug(String.format("WebSocket endpoint (%s) received text message", session.getId())); inboundMessages.add(message); } @Override protected void handleBinaryMessage(WebSocketSession session, BinaryMessage message) throws Exception { - LOG.debug(String.format("WebSocket endpoint (%s) received binary message", session.getId())); + logger.debug(String.format("WebSocket endpoint (%s) received binary message", session.getId())); inboundMessages.add(message); } @Override protected void handlePongMessage(WebSocketSession session, PongMessage message) throws Exception { - LOG.debug(String.format("WebSocket endpoint (%s) received pong message", session.getId())); + logger.debug(String.format("WebSocket endpoint (%s) received pong message", session.getId())); inboundMessages.add(message); } @Override public void handleTransportError(WebSocketSession session, Throwable exception) throws Exception { - LOG.error(String.format("WebSocket transport error (%s)", session.getId()), exception); + logger.error(String.format("WebSocket transport error (%s)", session.getId()), exception); } @Override public void afterConnectionClosed(WebSocketSession session, CloseStatus status) throws Exception { - LOG.debug(String.format("WebSocket session (%s) closed - status : %s", session.getId(), status)); + logger.debug(String.format("WebSocket session (%s) closed - status : %s", session.getId(), status)); sessions.remove(session.getId()); } @@ -94,7 +94,7 @@ public WebSocketMessage getMessage() { public boolean sendMessage(WebSocketMessage message) { boolean sentSuccessfully = false; if (sessions.isEmpty()) { - LOG.warn("No Web Socket session exists - message cannot be sent"); + logger.warn("No Web Socket session exists - message cannot be sent"); } for (WebSocketSession session : sessions.values()) { @@ -103,7 +103,7 @@ public boolean sendMessage(WebSocketMessage message) { session.sendMessage(message); sentSuccessfully = true; } catch (IOException e) { - LOG.error(String.format("(%s) error sending message", session.getId()), e); + logger.error(String.format("(%s) error sending message", session.getId()), e); } } } diff --git a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/server/WebSocketServerEndpointConfiguration.java b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/server/WebSocketServerEndpointConfiguration.java index 31a271fa35..e6c08b58ac 100644 --- a/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/server/WebSocketServerEndpointConfiguration.java +++ b/endpoints/citrus-websocket/src/main/java/org/citrusframework/websocket/server/WebSocketServerEndpointConfiguration.java @@ -28,7 +28,7 @@ */ public class WebSocketServerEndpointConfiguration extends AbstractWebSocketEndpointConfiguration { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WebSocketServerEndpointConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger(WebSocketServerEndpointConfiguration.class); /** Web socket handler */ private CitrusWebSocketHandler handler; @@ -41,7 +41,7 @@ public CitrusWebSocketHandler getHandler() { @Override public void setHandler(CitrusWebSocketHandler handler) { if (this.handler != null) { - LOG.warn(String.format("Handler already set for Web Socket endpoint (path='%s'). " + + logger.warn(String.format("Handler already set for Web Socket endpoint (path='%s'). " + "Check configuration to ensure that the Web Socket endpoint is not being used by multiple http-servers", getEndpointUri())); } this.handler = handler; diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/AssertSoapFault.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/AssertSoapFault.java index cfbad88fc7..a46b50cd70 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/AssertSoapFault.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/AssertSoapFault.java @@ -80,7 +80,7 @@ public class AssertSoapFault extends AbstractActionContainer { private final SoapFaultValidationContext validationContext; /** Logger */ - private static Logger LOG = LoggerFactory.getLogger(AssertSoapFault.class); + private static final Logger logger = LoggerFactory.getLogger(AssertSoapFault.class); /** * Default constructor. @@ -101,19 +101,19 @@ public AssertSoapFault(Builder builder) { @Override public void doExecute(TestContext context) { - LOG.debug("Asserting SOAP fault ..."); + logger.debug("Asserting SOAP fault ..."); try { executeAction(action, context); } catch (SoapFaultClientException soapFaultException) { - LOG.debug("Validating SOAP fault ..."); + logger.debug("Validating SOAP fault ..."); SoapFault controlFault = constructControlFault(context); validator.validateSoapFault(SoapFault.from(soapFaultException.getSoapFault()), controlFault, context, validationContext); - LOG.debug("Asserted SOAP fault as expected: " + soapFaultException.getFaultCode() + ": " + soapFaultException.getFaultStringOrReason()); - LOG.info("Assert SOAP fault validation successful"); + logger.debug("Asserted SOAP fault as expected: " + soapFaultException.getFaultCode() + ": " + soapFaultException.getFaultStringOrReason()); + logger.info("Assert SOAP fault validation successful"); return; } catch (Exception e) { diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SendSoapMessageAction.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SendSoapMessageAction.java index 503ea5eff2..3b13974746 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SendSoapMessageAction.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/actions/SendSoapMessageAction.java @@ -49,7 +49,7 @@ public class SendSoapMessageAction extends SendMessageAction implements TestAction { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(SendSoapMessageAction.class); + private static final Logger logger = LoggerFactory.getLogger(SendSoapMessageAction.class); /** SOAP attachments */ private final List attachments; @@ -83,13 +83,13 @@ protected SoapMessage createMessage(TestContext context, String messageType) { if (attachment.isMtomInline() && messagePayload.contains(cid)) { byte[] attachmentBinaryData = FileUtils.readToString(attachment.getInputStream(), Charset.forName(attachment.getCharsetName())).getBytes(Charset.forName(attachment.getCharsetName())); if (attachment.getEncodingType().equals(SoapAttachment.ENCODING_BASE64_BINARY)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Adding inline base64Binary data for attachment: %s", cid)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Adding inline base64Binary data for attachment: %s", cid)); } messagePayload = messagePayload.replaceAll(cid, Base64.encodeBase64String(attachmentBinaryData)); } else if (attachment.getEncodingType().equals(SoapAttachment.ENCODING_HEX_BINARY)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Adding inline hexBinary data for attachment: %s", cid)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Adding inline hexBinary data for attachment: %s", cid)); } messagePayload = messagePayload.replaceAll(cid, Hex.encodeHexString(attachmentBinaryData).toUpperCase()); } else { diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/client/WebServiceClient.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/client/WebServiceClient.java index 187e81b758..ba4471acc3 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/client/WebServiceClient.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/client/WebServiceClient.java @@ -54,7 +54,7 @@ */ public class WebServiceClient extends AbstractEndpoint implements Producer, ReplyConsumer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(WebServiceClient.class); + private static final Logger logger = LoggerFactory.getLogger(WebServiceClient.class); /** Store of reply messages */ private CorrelationManager correlationManager; @@ -112,9 +112,9 @@ public void send(Message message, TestContext context) { context.setVariable(MessageHeaders.MESSAGE_REPLY_TO + "_" + correlationKeyName, endpointUri); - if (log.isDebugEnabled()) { - log.debug("Sending SOAP message to endpoint: '" + endpointUri + "'"); - log.debug("Message to send is:\n" + soapMessage.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending SOAP message to endpoint: '" + endpointUri + "'"); + logger.debug("Message to send is:\n" + soapMessage.toString()); } if (!(soapMessage.getPayload() instanceof String)) { @@ -135,13 +135,13 @@ public void send(Message message, TestContext context) { result = getEndpointConfiguration().getWebServiceTemplate().sendAndReceive(requestCallback, responseCallback); } - log.info("SOAP message was sent to endpoint: '" + endpointUri + "'"); + logger.info("SOAP message was sent to endpoint: '" + endpointUri + "'"); if (result) { - log.info("Received SOAP response on endpoint: '" + endpointUri + "'"); + logger.info("Received SOAP response on endpoint: '" + endpointUri + "'"); correlationManager.store(correlationKey, responseCallback.getResponse()); } else { - log.info("Received no SOAP response from endpoint: '" + endpointUri + "'"); + logger.info("Received no SOAP response from endpoint: '" + endpointUri + "'"); } } @@ -247,7 +247,7 @@ public void resolveFault(WebServiceMessage webServiceResponse) throws IOExceptio responseMessage.setPayload(faultPayload.toString()); } - log.info("Received SOAP fault response on endpoint: '" + endpointUri + "'"); + logger.info("Received SOAP fault response on endpoint: '" + endpointUri + "'"); correlationManager.store(correlationKey, responseMessage); } catch (TransformerException e) { throw new CitrusRuntimeException("Failed to handle fault response message", e); diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingClientInterceptor.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingClientInterceptor.java index aeacef1444..5354cb1a09 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingClientInterceptor.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingClientInterceptor.java @@ -38,7 +38,7 @@ public boolean handleRequest(MessageContext messageContext) throws WebServiceCli try { logRequest("Sending SOAP request", messageContext, false); } catch (SoapEnvelopeException | TransformerException e) { - log.warn("Unable to write SOAP request to logger", e); + logger.warn("Unable to write SOAP request to logger", e); } return true; @@ -51,7 +51,7 @@ public boolean handleResponse(MessageContext messageContext) throws WebServiceCl try { logResponse("Received SOAP response", messageContext, true); } catch (SoapEnvelopeException | TransformerException e) { - log.warn("Unable to write SOAP response to logger", e); + logger.warn("Unable to write SOAP response to logger", e); } return true; @@ -64,7 +64,7 @@ public boolean handleFault(MessageContext messageContext) throws WebServiceClien try { logResponse("Received SOAP fault", messageContext, true); } catch (SoapEnvelopeException | TransformerException e) { - log.warn("Unable to write SOAP fault to logger", e); + logger.warn("Unable to write SOAP fault to logger", e); } return true; diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingInterceptorSupport.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingInterceptorSupport.java index 7d460a920a..03b92c1d5a 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingInterceptorSupport.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/interceptor/LoggingInterceptorSupport.java @@ -37,14 +37,14 @@ import org.springframework.xml.transform.TransformerObjectSupport; /** - * Abstract logging support class offers basic log methods for SOAP messages. + * Abstract logging support class offers basic logger methods for SOAP messages. * * @author Christoph Deppisch */ public abstract class LoggingInterceptorSupport extends TransformerObjectSupport { /** Logger */ - protected final Logger log = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); private MessageListeners messageListener; @@ -95,7 +95,7 @@ protected void logResponse(String logMessage, MessageContext messageContext, boo /** * Log SOAP message with transformer instance. * - * @param logMessage the customized log message. + * @param logMessage the customized logger message. * @param soapMessage the message content as SOAP envelope source. * @param incoming * @throws TransformerException @@ -112,8 +112,8 @@ protected void logSoapMessage(String logMessage, SoapMessage soapMessage, boolea * Log WebService message (other than SOAP) with in memory * {@link ByteArrayOutputStream} * - * @param logMessage the customized log message. - * @param message the message to log. + * @param logMessage the customized logger message. + * @param message the message to logger. * @param incoming */ protected void logWebServiceMessage(String logMessage, WebServiceMessage message, boolean incoming) { @@ -123,20 +123,20 @@ protected void logWebServiceMessage(String logMessage, WebServiceMessage message message.writeTo(os); logMessage(logMessage, os.toString(), incoming); } catch (IOException e) { - log.warn("Unable to log WebService message", e); + logger.warn("Unable to logger WebService message", e); } } /** * Performs the final logger call with dynamic message. * - * @param logMessage a custom log message entry. + * @param logMessage a custom logger message entry. * @param message the message content. * @param incoming */ protected void logMessage(String logMessage, String message, boolean incoming) { if (hasMessageListeners()) { - log.debug(logMessage); + logger.debug(logMessage); if (incoming) { messageListener.onInboundMessage(new RawMessage(message), testContextFactory.getObject()); @@ -144,8 +144,8 @@ protected void logMessage(String logMessage, String message, boolean incoming) { messageListener.onOutboundMessage(new RawMessage(message), testContextFactory.getObject()); } } else { - if (log.isDebugEnabled()) { - log.debug(logMessage + ":" + System.getProperty("line.separator") + message); + if (logger.isDebugEnabled()) { + logger.debug(logMessage + ":" + System.getProperty("line.separator") + message); } } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/message/converter/SoapMessageConverter.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/message/converter/SoapMessageConverter.java index 6d87c368a7..2b9c46cde9 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/message/converter/SoapMessageConverter.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/message/converter/SoapMessageConverter.java @@ -75,7 +75,7 @@ public class SoapMessageConverter implements WebServiceMessageConverter { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SoapMessageConverter.class); + private static final Logger logger = LoggerFactory.getLogger(SoapMessageConverter.class); /** Default payload source encoding */ private String charset = CitrusSettings.CITRUS_FILE_ENCODING; @@ -104,7 +104,7 @@ public void convertOutbound(final WebServiceMessage webServiceMessage, copySoapHeaderData(soapRequest, soapMessage, transformerFactory); if (soapMessage.isMtomEnabled() && soapMessage.getAttachments().size() > 0) { - log.debug("Converting SOAP request to XOP package"); + logger.debug("Converting SOAP request to XOP package"); soapRequest.convertToXopPackage(); } @@ -220,7 +220,7 @@ protected void handleInboundHttpHeaders(final SoapMessage message, final WebServiceEndpointConfiguration endpointConfiguration) { final TransportContext transportContext = TransportContextHolder.getTransportContext(); if (transportContext == null) { - log.warn("Unable to get complete set of http request headers - no transport context available"); + logger.warn("Unable to get complete set of http request headers - no transport context available"); return; } @@ -246,12 +246,12 @@ protected void handleInboundHttpHeaders(final SoapMessage message, } } } else { - log.warn("Unable to get complete set of http request headers"); + logger.warn("Unable to get complete set of http request headers"); try { message.setHeader(SoapMessageHeaders.HTTP_REQUEST_URI, connection.getUri()); } catch (final URISyntaxException e) { - log.warn("Unable to get http request uri from http connection", e); + logger.warn("Unable to get http request uri from http connection", e); } } } @@ -323,7 +323,7 @@ private void handleOutboundMimeMessageHeader(final org.springframework.ws.soap.S final MimeHeaders headers = soapMsg.getSaajMessage().getMimeHeaders(); headers.setHeader(name, value.toString()); } else { - log.warn("Unsupported SOAP message implementation - unable to set mime message header '" + name + "'"); + logger.warn("Unsupported SOAP message implementation - unable to set mime message header '" + name + "'"); } } @@ -344,7 +344,7 @@ protected void handleInboundMimeHeaders(final org.springframework.ws.soap.SoapMe if (soapMessage instanceof SaajSoapMessage) { messageMimeHeaders = ((SaajSoapMessage)soapMessage).getSaajMessage().getMimeHeaders(); } else { - log.warn("Unsupported SOAP message implementation - skipping mime headers"); + logger.warn("Unsupported SOAP message implementation - skipping mime headers"); } if (messageMimeHeaders != null) { @@ -401,8 +401,8 @@ protected void handleInboundAttachments(final org.springframework.ws.soap.SoapMe final Attachment attachment = attachments.next(); final SoapAttachment soapAttachment = SoapAttachment.from(attachment); - if (log.isDebugEnabled()) { - log.debug(String.format("SOAP message contains attachment with contentId '%s'", soapAttachment.getContentId())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("SOAP message contains attachment with contentId '%s'", soapAttachment.getContentId())); } message.addAttachment(soapAttachment); @@ -482,8 +482,8 @@ private void copySoapAttachments(final TestContext context, contentId = "<" + contentId + ">"; } - if (log.isDebugEnabled()) { - log.debug(String.format("Adding attachment to SOAP message: '%s' ('%s')", contentId, attachment.getContentType())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Adding attachment to SOAP message: '%s' ('%s')", contentId, attachment.getContentType())); } soapRequest.addAttachment(contentId, attachment::getInputStream, attachment.getContentType()); diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/server/WebServiceEndpoint.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/server/WebServiceEndpoint.java index 37b739f331..22e597e113 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/server/WebServiceEndpoint.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/server/WebServiceEndpoint.java @@ -84,7 +84,7 @@ public class WebServiceEndpoint implements MessageEndpoint { private WebServiceEndpointConfiguration endpointConfiguration = new WebServiceEndpointConfiguration(); /** Logger */ - private static Logger log = LoggerFactory.getLogger(WebServiceEndpoint.class); + private static final Logger logger = LoggerFactory.getLogger(WebServiceEndpoint.class); /** JMS headers begin with this prefix */ private static final String DEFAULT_JMS_HEADER_PREFIX = "JMS"; @@ -98,8 +98,8 @@ public void invoke(final MessageContext messageContext) throws Exception { Message requestMessage = endpointConfiguration.getMessageConverter().convertInbound(messageContext.getRequest(), messageContext, endpointConfiguration); - if (log.isDebugEnabled()) { - log.debug("Received SOAP request:\n" + requestMessage.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Received SOAP request:\n" + requestMessage.toString()); } //delegate request processing to endpoint adapter @@ -110,8 +110,8 @@ public void invoke(final MessageContext messageContext) throws Exception { } if (replyMessage != null && replyMessage.getPayload() != null) { - if (log.isDebugEnabled()) { - log.debug("Sending SOAP response:\n" + replyMessage.toString()); + if (logger.isDebugEnabled()) { + logger.debug("Sending SOAP response:\n" + replyMessage.toString()); } SoapMessage response = (SoapMessage) messageContext.getResponse(); @@ -127,10 +127,10 @@ public void invoke(final MessageContext messageContext) throws Exception { addSoapHeaders(response, replyMessage); addMimeHeaders(response, replyMessage); } else { - if (log.isDebugEnabled()) { - log.debug("No reply message from endpoint adapter '" + endpointAdapter + "'"); + if (logger.isDebugEnabled()) { + logger.debug("No reply message from endpoint adapter '" + endpointAdapter + "'"); } - log.warn("No SOAP response for calling client"); + logger.warn("No SOAP response for calling client"); } } @@ -172,7 +172,7 @@ private boolean simulateHttpStatusCode(Message replyMessage) throws IOException ((HttpServletConnection)connection).getHttpServletResponse().setStatus(statusCode); return true; } else { - log.warn("Unable to set custom Http status code on connection other than HttpServletConnection (" + connection.getClass().getName() + ")"); + logger.warn("Unable to set custom Http status code on connection other than HttpServletConnection (" + connection.getClass().getName() + ")"); } } } @@ -196,7 +196,7 @@ private void addMimeHeaders(SoapMessage response, Message replyMessage) { MimeHeaders headers = saajSoapMessage.getSaajMessage().getMimeHeaders(); headers.setHeader(headerName, headerEntry.getValue().toString()); } else { - log.warn("Unsupported SOAP message implementation - unable to set mime message header '" + headerName + "'"); + logger.warn("Unsupported SOAP message implementation - unable to set mime message header '" + headerName + "'"); } } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractFaultDetailValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractFaultDetailValidator.java index a28fd4e2da..642b9daa7a 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractFaultDetailValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractFaultDetailValidator.java @@ -35,15 +35,15 @@ public abstract class AbstractFaultDetailValidator extends AbstractSoapFaultValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractFaultDetailValidator.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractFaultDetailValidator.class); @Override protected void validateFaultDetail(SoapFault receivedDetail, SoapFault controlDetail, TestContext context, final SoapFaultValidationContext validationContext) { if (controlDetail == null) { return; } - if (log.isDebugEnabled()) { - log.debug("Validating SOAP fault detail content ..."); + if (logger.isDebugEnabled()) { + logger.debug("Validating SOAP fault detail content ..."); } if (receivedDetail == null) { diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapAttachmentValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapAttachmentValidator.java index 2f90879cbc..0982095fb4 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapAttachmentValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapAttachmentValidator.java @@ -40,24 +40,24 @@ public abstract class AbstractSoapAttachmentValidator implements SoapAttachmentV /** * Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractSoapAttachmentValidator.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractSoapAttachmentValidator.class); @Override public void validateAttachment(SoapMessage soapMessage, List controlAttachments) { - log.debug("Validating SOAP attachments ..."); + logger.debug("Validating SOAP attachments ..."); for (SoapAttachment controlAttachment : controlAttachments) { SoapAttachment attachment = findAttachment(soapMessage, controlAttachment); - if (log.isDebugEnabled()) { - log.debug("Found attachment with contentId '" + controlAttachment.getContentId() + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Found attachment with contentId '" + controlAttachment.getContentId() + "'"); } validateAttachmentContentId(attachment, controlAttachment); validateAttachmentContentType(attachment, controlAttachment); validateAttachmentContent(attachment, controlAttachment); - log.info("SOAP attachment validation successful: All values OK"); + logger.info("SOAP attachment validation successful: All values OK"); } } @@ -120,8 +120,8 @@ protected void validateAttachmentContentId(SoapAttachment receivedAttachment, So controlAttachment.getContentId(), null)); } - if (log.isDebugEnabled()) { - log.debug("Validating attachment contentId: " + receivedAttachment.getContentId() + + if (logger.isDebugEnabled()) { + logger.debug("Validating attachment contentId: " + receivedAttachment.getContentId() + "='" + controlAttachment.getContentId() + "': OK."); } } @@ -149,8 +149,8 @@ protected void validateAttachmentContentType(SoapAttachment receivedAttachment, controlAttachment.getContentType(), null)); } - if (log.isDebugEnabled()) { - log.debug("Validating attachment contentType: " + receivedAttachment.getContentType() + + if (logger.isDebugEnabled()) { + logger.debug("Validating attachment contentType: " + receivedAttachment.getContentType() + "='" + controlAttachment.getContentType() + "': OK."); } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapFaultValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapFaultValidator.java index 4567c0f75f..0aca55a846 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapFaultValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/AbstractSoapFaultValidator.java @@ -38,7 +38,7 @@ public abstract class AbstractSoapFaultValidator implements SoapFaultValidator { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(AbstractSoapFaultValidator.class); + private static final Logger logger = LoggerFactory.getLogger(AbstractSoapFaultValidator.class); @Override public void validateSoapFault(SoapFault receivedFault, SoapFault controlFault, @@ -47,7 +47,7 @@ public void validateSoapFault(SoapFault receivedFault, SoapFault controlFault, if (controlFault.getFaultString() != null && !controlFault.getFaultString().equals(receivedFault.getFaultString())) { if (controlFault.getFaultString().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - log.debug("SOAP fault-string is ignored by placeholder - skipped fault-string validation"); + logger.debug("SOAP fault-string is ignored by placeholder - skipped fault-string validation"); } else if (ValidationMatcherUtils.isValidationMatcherExpression(controlFault.getFaultString())) { ValidationMatcherUtils.resolveValidationMatcher("SOAP fault string", receivedFault.getFaultString(), controlFault.getFaultString(), context); } else { diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/BinarySoapAttachmentValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/BinarySoapAttachmentValidator.java index 4fa0352351..9c29161a27 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/BinarySoapAttachmentValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/BinarySoapAttachmentValidator.java @@ -35,12 +35,12 @@ public class BinarySoapAttachmentValidator extends AbstractSoapAttachmentValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(BinarySoapAttachmentValidator.class); + private static final Logger logger = LoggerFactory.getLogger(BinarySoapAttachmentValidator.class); @Override protected void validateAttachmentContent(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) { - if (log.isDebugEnabled()) { - log.debug("Validating binary SOAP attachment content ..."); + if (logger.isDebugEnabled()) { + logger.debug("Validating binary SOAP attachment content ..."); } try { @@ -51,8 +51,8 @@ protected void validateAttachmentContent(SoapAttachment receivedAttachment, Soap throw new CitrusRuntimeException("Binary SOAP attachment validation failed", e); } - if (log.isDebugEnabled()) { - log.debug("Validating binary SOAP attachment content: OK"); + if (logger.isDebugEnabled()) { + logger.debug("Validating binary SOAP attachment content: OK"); } } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapAttachmentValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapAttachmentValidator.java index 425002903d..0d827d5564 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapAttachmentValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapAttachmentValidator.java @@ -33,17 +33,17 @@ public class SimpleSoapAttachmentValidator extends AbstractSoapAttachmentValidat private boolean ignoreAllWhitespaces = false; /** Logger */ - private static Logger log = LoggerFactory.getLogger(SimpleSoapAttachmentValidator.class); + private static final Logger logger = LoggerFactory.getLogger(SimpleSoapAttachmentValidator.class); @Override protected void validateAttachmentContent(SoapAttachment receivedAttachment, SoapAttachment controlAttachment) { String receivedContent = StringUtils.trimWhitespace(receivedAttachment.getContent()); String controlContent = StringUtils.trimWhitespace(controlAttachment.getContent()); - if (log.isDebugEnabled()) { - log.debug("Validating SOAP attachment content ..."); - log.debug("Received attachment content: " + receivedContent); - log.debug("Control attachment content: " + controlContent); + if (logger.isDebugEnabled()) { + logger.debug("Validating SOAP attachment content ..."); + logger.debug("Received attachment content: " + receivedContent); + logger.debug("Control attachment content: " + controlContent); } if (receivedContent != null) { @@ -62,8 +62,8 @@ protected void validateAttachmentContent(SoapAttachment receivedAttachment, Soap + null + "'"); } - if (log.isDebugEnabled()) { - log.debug("Validating attachment content: OK"); + if (logger.isDebugEnabled()) { + logger.debug("Validating attachment content: OK"); } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapFaultValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapFaultValidator.java index 4c14eef3ef..53a2a63ec5 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapFaultValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/SimpleSoapFaultValidator.java @@ -32,20 +32,20 @@ public class SimpleSoapFaultValidator extends AbstractFaultDetailValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SimpleSoapFaultValidator.class); + private static final Logger logger = LoggerFactory.getLogger(SimpleSoapFaultValidator.class); @Override protected void validateFaultDetailString(String received, String control, TestContext context, SoapFaultDetailValidationContext validationContext) throws ValidationException { - log.debug("Validating SOAP fault detail ..."); + logger.debug("Validating SOAP fault detail ..."); String receivedDetail = StringUtils.trimAllWhitespace(received); String controlDetail = StringUtils.trimAllWhitespace(control); - if (log.isDebugEnabled()) { - log.debug("Received fault detail:\n" + StringUtils.trimWhitespace(received)); - log.debug("Control fault detail:\n" + StringUtils.trimWhitespace(control)); + if (logger.isDebugEnabled()) { + logger.debug("Received fault detail:\n" + StringUtils.trimWhitespace(received)); + logger.debug("Control fault detail:\n" + StringUtils.trimWhitespace(control)); } if (!receivedDetail.equals(controlDetail)) { @@ -53,6 +53,6 @@ protected void validateFaultDetailString(String received, String control, controlDetail + "' \n received \n'" + receivedDetail + "'"); } - log.info("SOAP fault detail validation successful: All values OK"); + logger.info("SOAP fault detail validation successful: All values OK"); } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapAttachmentValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapAttachmentValidator.java index f6eec956a2..db93542d73 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapAttachmentValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapAttachmentValidator.java @@ -40,7 +40,7 @@ public class XmlSoapAttachmentValidator extends SimpleSoapAttachmentValidator implements ReferenceResolverAware { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XmlSoapAttachmentValidator.class); + private static final Logger logger = LoggerFactory.getLogger(XmlSoapAttachmentValidator.class); private TestContextFactory testContextFactory; @@ -81,7 +81,7 @@ private MessageValidator getMessageValidator() { try { defaultMessageValidator = Optional.of(getTestContextFactory().getReferenceResolver().resolve(DEFAULT_XML_MESSAGE_VALIDATOR, MessageValidator.class)); } catch (CitrusRuntimeException e) { - LOG.warn("Unable to find default XML message validator in message validator registry"); + logger.warn("Unable to find default XML message validator in message validator registry"); } } diff --git a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapFaultValidator.java b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapFaultValidator.java index d8aaf1e8da..9a4b3f7d56 100644 --- a/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapFaultValidator.java +++ b/endpoints/citrus-ws/src/main/java/org/citrusframework/ws/validation/XmlSoapFaultValidator.java @@ -37,7 +37,7 @@ public class XmlSoapFaultValidator extends AbstractFaultDetailValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(XmlSoapFaultValidator.class); + private static final Logger logger = LoggerFactory.getLogger(XmlSoapFaultValidator.class); /** Xml message validator */ private MessageValidator messageValidator; @@ -72,7 +72,7 @@ private MessageValidator getMessageValidator(TestCo try { defaultMessageValidator = Optional.of(context.getReferenceResolver().resolve(DEFAULT_XML_MESSAGE_VALIDATOR, MessageValidator.class)); } catch (CitrusRuntimeException e) { - log.warn("Unable to find default XML message validator in message validator registry"); + logger.warn("Unable to find default XML message validator in message validator registry"); } } diff --git a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/TextEqualsMessageValidator.java b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/TextEqualsMessageValidator.java index 7313a8c1b7..532bba34bc 100644 --- a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/TextEqualsMessageValidator.java +++ b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/TextEqualsMessageValidator.java @@ -16,19 +16,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage.getPayload(String.class).isBlank()) { - log.info("Skip text validation as no control message payload specified"); + logger.info("Skip text validation as no control message payload specified"); return; } Assert.assertEquals(receivedMessage.getPayload(String.class), controlMessage.getPayload(String.class), "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/integration/SoapAttachmentHandlingEndpoint.java b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/integration/SoapAttachmentHandlingEndpoint.java index fde508eea5..0954768346 100644 --- a/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/integration/SoapAttachmentHandlingEndpoint.java +++ b/endpoints/citrus-ws/src/test/java/org/citrusframework/ws/integration/SoapAttachmentHandlingEndpoint.java @@ -33,13 +33,13 @@ public class SoapAttachmentHandlingEndpoint implements MessageEndpoint { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(SoapAttachmentHandlingEndpoint.class); + private static final Logger logger = LoggerFactory.getLogger(SoapAttachmentHandlingEndpoint.class); public void invoke(MessageContext messageContext) throws Exception { Iterator it = ((SoapMessage)messageContext.getRequest()).getAttachments(); while(it.hasNext()) { Attachment attachment = it.next(); - log.info("Endpoint handling SOAP attachment: " + attachment.getContentId() + "('" + attachment.getContentType() + "')"); + logger.info("Endpoint handling SOAP attachment: " + attachment.getContentId() + "('" + attachment.getContentType() + "')"); } } } diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/actions/ZooExecuteAction.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/actions/ZooExecuteAction.java index e3e65fe1ce..5e32c738c4 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/actions/ZooExecuteAction.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/actions/ZooExecuteAction.java @@ -63,7 +63,7 @@ public class ZooExecuteAction extends AbstractTestAction { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(ZooExecuteAction.class); + private static final Logger logger = LoggerFactory.getLogger(ZooExecuteAction.class); /** Zookeeper client instance */ private final ZooClient zookeeperClient; @@ -109,14 +109,14 @@ public ZooExecuteAction(Builder builder) { @Override public void doExecute(TestContext context) { try { - if (log.isDebugEnabled()) { - log.debug(String.format("Executing zookeeper command '%s'", command.getName())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Executing zookeeper command '%s'", command.getName())); } command.execute(zookeeperClient, context); validateCommandResult(command, context); - log.info(String.format("Zookeeper command execution successful: '%s'", command.getName())); + logger.info(String.format("Zookeeper command execution successful: '%s'", command.getName())); } catch (CitrusRuntimeException e) { throw e; } catch (Exception e) { @@ -196,8 +196,8 @@ private void validateCommandResult(ZooCommand command, TestContext context) { processor.process(commandResult, context); } - if (log.isDebugEnabled()) { - log.debug("Validating Zookeeper response"); + if (logger.isDebugEnabled()) { + logger.debug("Validating Zookeeper response"); } if (StringUtils.hasText(expectedCommandResult)) { @@ -211,7 +211,7 @@ private void validateCommandResult(ZooCommand command, TestContext context) { getPathValidator(context).validateMessage(commandResult, null, context, Collections.singletonList(jsonPathMessageValidationContext)); } - log.info("Zookeeper command result validation successful - all values OK!"); + logger.info("Zookeeper command result validation successful - all values OK!"); if (command.getResultCallback() != null) { command.getResultCallback().doWithCommandResult(command.getCommandResult(), context); diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/client/ZooClient.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/client/ZooClient.java index de2a16494a..87fd9ce53d 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/client/ZooClient.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/client/ZooClient.java @@ -34,7 +34,7 @@ public class ZooClient { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(ZooClient.class); + private static final Logger logger = LoggerFactory.getLogger(ZooClient.class); /** ZooKeeper client */ private ZooKeeper zookeeper; @@ -77,7 +77,7 @@ public ZooKeeper getZooKeeperClient() { zookeeper = createZooKeeperClient(); int retryAttempts = 5; while(!zookeeper.getState().isConnected() && retryAttempts > 0) { - LOG.debug("connecting..."); + logger.debug("connecting..."); retryAttempts--; Thread.sleep(1000); } @@ -114,7 +114,7 @@ private Watcher getConnectionWatcher() { return new Watcher() { @Override public void process(WatchedEvent event) { - LOG.debug(String.format("Connection Event: %s", event.toString())); + logger.debug(String.format("Connection Event: %s", event.toString())); } }; } diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Create.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Create.java index 9625e1f0f0..5ac4aadaaa 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Create.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Create.java @@ -37,7 +37,7 @@ public class Create extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(Create.class); + private static final Logger logger = LoggerFactory.getLogger(Create.class); public static final String ACL_ALL = "CREATOR_ALL_ACL"; public static final String ACL_OPEN = "OPEN_ACL_UNSAFE"; @@ -67,7 +67,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { throw new CitrusRuntimeException(e); } commandResult.setResponseParam(PATH, newPath); - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Delete.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Delete.java index 3919580730..ce59677272 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Delete.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Delete.java @@ -32,7 +32,7 @@ public class Delete extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(Delete.class); + private static final Logger logger = LoggerFactory.getLogger(Delete.class); /** * Default constructor initializing the command name. @@ -55,7 +55,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { } catch (InterruptedException e) { throw new CitrusRuntimeException(e); } - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Exists.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Exists.java index 3534b291b9..a7ba1c4cbb 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Exists.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Exists.java @@ -33,7 +33,7 @@ public class Exists extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(Exists.class); + private static final Logger logger = LoggerFactory.getLogger(Exists.class); /** * Default constructor initializing the command name. @@ -55,7 +55,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { } catch (InterruptedException | KeeperException e) { throw new CitrusRuntimeException(e); } - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetChildren.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetChildren.java index 241a4920e8..9331895971 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetChildren.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetChildren.java @@ -35,7 +35,7 @@ public class GetChildren extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(GetChildren.class); + private static final Logger logger = LoggerFactory.getLogger(GetChildren.class); /** * Default constructor initializing the command name. @@ -58,7 +58,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { } catch (InterruptedException | KeeperException e) { throw new CitrusRuntimeException(e); } - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetData.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetData.java index d50e7220eb..6b59592ac0 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetData.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/GetData.java @@ -32,7 +32,7 @@ public class GetData extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(GetData.class); + private static final Logger logger = LoggerFactory.getLogger(GetData.class); /** * Default constructor initializing the command name. @@ -54,7 +54,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { } catch (InterruptedException | KeeperException e) { throw new CitrusRuntimeException(e); } - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Info.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Info.java index cea4240b60..a06612f0f7 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Info.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/Info.java @@ -28,7 +28,7 @@ public class Info extends AbstractZooCommand { /** Logger */ - private static Logger log = LoggerFactory.getLogger(Info.class); + private static final Logger logger = LoggerFactory.getLogger(Info.class); /** * Default constructor initializing the command name. @@ -50,7 +50,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { commandResult.setResponseParam("sessionId", sessionId); commandResult.setResponseParam("sessionPwd", sessionPwd); commandResult.setResponseParam("sessionTimeout", sessionTimeout); - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } diff --git a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/SetData.java b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/SetData.java index c1c331d2a6..75d4f5fb57 100644 --- a/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/SetData.java +++ b/endpoints/citrus-zookeeper/src/main/java/org/citrusframework/zookeeper/command/SetData.java @@ -33,7 +33,7 @@ public class SetData extends AbstractZooCommand { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(SetData.class); + private static final Logger logger = LoggerFactory.getLogger(SetData.class); /** * Default constructor initializing the command name. @@ -57,7 +57,7 @@ public void execute(ZooClient zookeeperClient, TestContext context) { } catch (KeeperException | InterruptedException e) { throw new CitrusRuntimeException(e); } - log.debug(getCommandResult().toString()); + logger.debug(getCommandResult().toString()); } /** diff --git a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/CucumberTestEngine.java b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/CucumberTestEngine.java index 1c462d6b1a..12b6d29148 100644 --- a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/CucumberTestEngine.java +++ b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/CucumberTestEngine.java @@ -52,7 +52,7 @@ public class CucumberTestEngine extends AbstractTestEngine { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CucumberTestEngine.class); + private static final Logger logger = LoggerFactory.getLogger(CucumberTestEngine.class); public CucumberTestEngine(TestRunConfiguration configuration) { super(configuration); @@ -86,9 +86,9 @@ public void run() { List packagesToRun = getConfiguration().getPackages(); if (CollectionUtils.isEmpty(packagesToRun)) { - LOG.info("Running all tests in project"); + logger.info("Running all tests in project"); } else if (StringUtils.hasText(packagesToRun.get(0))) { - LOG.info(String.format("Running tests in package %s", packagesToRun.get(0))); + logger.info(String.format("Running tests in package %s", packagesToRun.get(0))); args.add(ClasspathSupport.CLASSPATH_SCHEME_PREFIX + packagesToRun.get(0).replaceAll("\\.", "/")); args.add("--glue"); diff --git a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringBackend.java b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringBackend.java index fa1da1e668..3a2c559cfa 100644 --- a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringBackend.java +++ b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringBackend.java @@ -26,7 +26,7 @@ public class CitrusSpringBackend extends CitrusBackend { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CitrusSpringBackend.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusSpringBackend.class); /** * Constructor using resource loader. @@ -70,7 +70,7 @@ public void process(Citrus instance) { for (URI gluePath : gluePaths) { String xmlStepConfigLocation = "classpath*:" + ClasspathSupport.resourceNameOfPackageName(ClasspathSupport.packageName(gluePath)) + "/**/*Steps.xml"; - log.info(String.format("Loading XML step definitions %s", xmlStepConfigLocation)); + logger.info(String.format("Loading XML step definitions %s", xmlStepConfigLocation)); ApplicationContext ctx; if (instance.getCitrusContext() instanceof CitrusSpringContext) { @@ -82,8 +82,8 @@ public void process(Citrus instance) { Map xmlSteps = ctx.getBeansOfType(StepTemplate.class); for (StepTemplate stepTemplate : xmlSteps.values()) { - if (log.isDebugEnabled()) { - log.debug(String.format("Found XML step definition: %s %s", stepTemplate.getName(), stepTemplate.getPattern().pattern())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Found XML step definition: %s %s", stepTemplate.getName(), stepTemplate.getPattern().pattern())); } glue.addStepDefinition(new XmlStepDefinition(stepTemplate, lookup)); } diff --git a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringObjectFactory.java b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringObjectFactory.java index d4963b3da7..f2c89e9125 100644 --- a/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringObjectFactory.java +++ b/runtime/citrus-cucumber/src/main/java/org/citrusframework/cucumber/backend/spring/CitrusSpringObjectFactory.java @@ -40,7 +40,7 @@ public class CitrusSpringObjectFactory implements ObjectFactory { /** Logger */ - private static Logger log = LoggerFactory.getLogger(CitrusSpringObjectFactory.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusSpringObjectFactory.class); /** Test runner */ private TestCaseRunner runner; @@ -81,7 +81,7 @@ public T getInstance(Class type) { context = contextFactoryBean.getObject(); initializeCitrus(context, contextFactoryBean.getApplicationContext()); } catch (CucumberBackendException e) { - log.warn("Failed to get proper TestContext from Cucumber Spring application context: " + e.getMessage()); + logger.warn("Failed to get proper TestContext from Cucumber Spring application context: " + e.getMessage()); context = CitrusInstanceManager.getOrDefault().getCitrusContext().createTestContext(); } } @@ -114,7 +114,7 @@ private void initializeCitrus(TestContext context, ApplicationContext applicatio if (citrusContext instanceof CitrusSpringContext && !((CitrusSpringContext) citrusContext).getApplicationContext().equals(applicationContext)) { - log.warn("Citrus instance has already been initialized - creating new instance and shutting down current instance"); + logger.warn("Citrus instance has already been initialized - creating new instance and shutting down current instance"); citrusContext.close(); } else { return; diff --git a/runtime/citrus-groovy/src/main/java/org/citrusframework/script/GroovyAction.java b/runtime/citrus-groovy/src/main/java/org/citrusframework/script/GroovyAction.java index 16b0c63bd9..ce91e4d5b3 100644 --- a/runtime/citrus-groovy/src/main/java/org/citrusframework/script/GroovyAction.java +++ b/runtime/citrus-groovy/src/main/java/org/citrusframework/script/GroovyAction.java @@ -63,7 +63,7 @@ public interface ScriptExecutor { } /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(GroovyAction.class); + private static final Logger logger = LoggerFactory.getLogger(GroovyAction.class); /** * Default constructor. @@ -116,8 +116,8 @@ public GroovyClassLoader run() { groovyObject = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance(); } - if (LOG.isDebugEnabled()) { - LOG.debug("Executing Groovy script:\n" + code); + if (logger.isDebugEnabled()) { + logger.debug("Executing Groovy script:\n" + code); } // execute the Groovy script @@ -127,7 +127,7 @@ public GroovyClassLoader run() { groovyObject.invokeMethod("run", new Object[] {}); } - LOG.info("Groovy script execution successful"); + logger.info("Groovy script execution successful"); } catch (CitrusRuntimeException e) { throw e; } catch (Exception e) { diff --git a/runtime/citrus-groovy/src/test/java/org/citrusframework/groovy/GroovyTestLoaderTest.java b/runtime/citrus-groovy/src/test/java/org/citrusframework/groovy/GroovyTestLoaderTest.java index 6f40e7680c..438ebcf6c9 100644 --- a/runtime/citrus-groovy/src/test/java/org/citrusframework/groovy/GroovyTestLoaderTest.java +++ b/runtime/citrus-groovy/src/test/java/org/citrusframework/groovy/GroovyTestLoaderTest.java @@ -53,7 +53,7 @@ public void shouldLoadGroovyTest() { Assert.assertEquals(test.getName(), "sample.test"); Assert.assertEquals(test.getPackageName(), this.getClass().getPackageName() + ".dsl"); - Assert.assertEquals(test.getTestClass(), this.getClass()); + Assert.assertEquals(test.getTestClass(), getClass()); Assert.assertEquals(test.getActionCount(), 6L); Assert.assertEquals(((DefaultTestCase)test).getFinalActions().size(), 2L); } @@ -66,7 +66,7 @@ public void shouldSupportJsonBuilderTest() { Assert.assertEquals(test.getName(), "json.test"); Assert.assertEquals(test.getPackageName(), this.getClass().getPackageName() + ".dsl"); - Assert.assertEquals(test.getTestClass(), this.getClass()); + Assert.assertEquals(test.getTestClass(), getClass()); Assert.assertEquals(test.getActionCount(), 3L); } @@ -78,7 +78,7 @@ public void shouldSupportXmlMarkupBuilderTest() { Assert.assertEquals(test.getName(), "xml.test"); Assert.assertEquals(test.getPackageName(), this.getClass().getPackageName() + ".dsl"); - Assert.assertEquals(test.getTestClass(), this.getClass()); + Assert.assertEquals(test.getTestClass(), getClass()); Assert.assertEquals(test.getActionCount(), 3L); } @@ -91,7 +91,7 @@ public void shouldLookupTestLoader() { private TestLoader getTestLoader(String testName) { TestCaseRunner runner = new DefaultTestCaseRunner(context); - runner.testClass(this.getClass()); + runner.testClass(getClass()); runner.name(testName); runner.packageName(this.getClass().getPackageName() + ".dsl"); diff --git a/runtime/citrus-groovy/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java b/runtime/citrus-groovy/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java index eb557ecfa7..760124479a 100644 --- a/runtime/citrus-groovy/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java +++ b/runtime/citrus-groovy/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java @@ -34,19 +34,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + private boolean normalizeLineEndings = false; private boolean trim = false; @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage == null || controlMessage.getPayload() == null || controlMessage.getPayload(String.class).isEmpty()) { - LOG.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } - log.debug("Start text equals validation ..."); + logger.debug("Start text equals validation ..."); String controlPayload = controlMessage.getPayload(String.class); String receivedPayload = receivedMessage.getPayload(String.class); @@ -64,7 +64,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes Assert.assertEquals(receivedPayload, controlPayload, "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/runtime/citrus-junit/src/main/java/org/citrusframework/junit/JUnit4TestEngine.java b/runtime/citrus-junit/src/main/java/org/citrusframework/junit/JUnit4TestEngine.java index c2038432ab..4a9042d664 100644 --- a/runtime/citrus-junit/src/main/java/org/citrusframework/junit/JUnit4TestEngine.java +++ b/runtime/citrus-junit/src/main/java/org/citrusframework/junit/JUnit4TestEngine.java @@ -44,7 +44,7 @@ public class JUnit4TestEngine extends AbstractTestEngine { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(JUnit4TestEngine.class); + private static final Logger logger = LoggerFactory.getLogger(JUnit4TestEngine.class); private final List listeners = new ArrayList<>(); @@ -64,13 +64,13 @@ public void run() { List packagesToRun = getConfiguration().getPackages(); if (CollectionUtils.isEmpty(packagesToRun) && CollectionUtils.isEmpty(getConfiguration().getTestClasses())) { packagesToRun = Collections.singletonList(""); - LOG.info("Running all tests in project"); + logger.info("Running all tests in project"); } List classesToRun = new ArrayList<>(); for (String packageName : packagesToRun) { if (StringUtils.hasText(packageName)) { - LOG.info(String.format("Running tests in package %s", packageName)); + logger.info(String.format("Running tests in package %s", packageName)); } if (getConfiguration().getTestJar() != null) { @@ -82,7 +82,7 @@ public void run() { } } - LOG.info(String.format("Found %s test classes to execute", classesToRun.size())); + logger.info(String.format("Found %s test classes to execute", classesToRun.size())); run(classesToRun); } } @@ -100,7 +100,7 @@ private void run(List classesToRun) { junit.run(classesToRun .stream() - .peek(testClass -> LOG.info(String.format("Running test %s", + .peek(testClass -> logger.info(String.format("Running test %s", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) .orElse(testClass.getName())))) .map(testClass -> { @@ -112,10 +112,10 @@ private void run(List classesToRun) { } else { clazz = Class.forName(testClass.getName()); } - LOG.debug("Found test candidate: " + testClass.getName()); + logger.debug("Found test candidate: " + testClass.getName()); return clazz; } catch (ClassNotFoundException | MalformedURLException e) { - LOG.warn("Unable to read test class: " + testClass.getName()); + logger.warn("Unable to read test class: " + testClass.getName()); return Void.class; } }) diff --git a/runtime/citrus-junit/src/main/java/org/citrusframework/junit/spring/JUnit4CitrusSpringSupport.java b/runtime/citrus-junit/src/main/java/org/citrusframework/junit/spring/JUnit4CitrusSpringSupport.java index adcbe91464..842ee9fab6 100644 --- a/runtime/citrus-junit/src/main/java/org/citrusframework/junit/spring/JUnit4CitrusSpringSupport.java +++ b/runtime/citrus-junit/src/main/java/org/citrusframework/junit/spring/JUnit4CitrusSpringSupport.java @@ -58,9 +58,6 @@ public class JUnit4CitrusSpringSupport extends AbstractJUnit4SpringContextTests implements GherkinTestActionRunner, CitrusFrameworkMethod.Runner { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(getClass()); - /** Citrus instance */ protected Citrus citrus; diff --git a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusApp.java b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusApp.java index eac66d6746..046bc17f60 100644 --- a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusApp.java +++ b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusApp.java @@ -38,7 +38,7 @@ public class CitrusApp { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusApp.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusApp.class); /** Endpoint configuration */ private final CitrusAppConfiguration configuration; @@ -81,7 +81,7 @@ public static void main(String[] args) { try { new CompletableFuture().get(citrusApp.configuration.getTimeToLive(), TimeUnit.MILLISECONDS); } catch (InterruptedException | ExecutionException | TimeoutException e) { - LOG.info(String.format("Shutdown Citrus application after %s ms", citrusApp.configuration.getTimeToLive())); + logger.info(String.format("Shutdown Citrus application after %s ms", citrusApp.configuration.getTimeToLive())); citrusApp.stop(); } }); @@ -116,11 +116,11 @@ public static void main(String[] args) { */ public void run() { if (isCompleted()) { - LOG.info("Not executing tests as application state is completed!"); + logger.info("Not executing tests as application state is completed!"); return; } - LOG.info(String.format("Running Citrus %s", Citrus.getVersion())); + logger.info(String.format("Running Citrus %s", Citrus.getVersion())); configuration.setDefaultProperties(); TestEngine.lookup(configuration).run(); } @@ -140,7 +140,7 @@ public boolean waitForCompletion() { try { return completed.get(); } catch (InterruptedException | ExecutionException e) { - LOG.warn("Failed to wait for application completion", e); + logger.warn("Failed to wait for application completion", e); } return false; @@ -154,7 +154,7 @@ private void stop() { Optional citrus = CitrusInstanceManager.get(); if (citrus.isPresent()) { - LOG.info("Closing Citrus and its context"); + logger.info("Closing Citrus and its context"); citrus.get().close(); } } diff --git a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppConfiguration.java b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppConfiguration.java index a0e7a9540b..d6dc975511 100644 --- a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppConfiguration.java +++ b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppConfiguration.java @@ -30,7 +30,7 @@ public class CitrusAppConfiguration extends TestRunConfiguration { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusAppConfiguration.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusAppConfiguration.class); /** Server time to live in milliseconds */ private long timeToLive = 0; @@ -121,7 +121,7 @@ public void setSystemExit(boolean systemExit) { */ public void setDefaultProperties() { for (Map.Entry entry : getDefaultProperties().entrySet()) { - LOG.debug(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); + logger.debug(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); System.setProperty(entry.getKey(), Optional.ofNullable(entry.getValue()).orElse("")); } diff --git a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppOptions.java b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppOptions.java index 274847d2a9..ce64fbaa96 100644 --- a/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppOptions.java +++ b/runtime/citrus-main/src/main/java/org/citrusframework/main/CitrusAppOptions.java @@ -37,7 +37,7 @@ public class CitrusAppOptions { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(CitrusAppOptions.class); + private static final Logger logger = LoggerFactory.getLogger(CitrusAppOptions.class); protected final List> options = new ArrayList<>(); @@ -51,7 +51,7 @@ protected void doProcess(T configuration, String arg, String value, LinkedList entry : getDefaultProperties().entrySet()) { - LOG.debug(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); + logger.debug(String.format("Setting application property %s=%s", entry.getKey(), entry.getValue())); System.setProperty(entry.getKey(), Optional.ofNullable(entry.getValue()).orElse("")); } diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusMethodInterceptor.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusMethodInterceptor.java index e684b72490..50295ef3a8 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusMethodInterceptor.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusMethodInterceptor.java @@ -45,7 +45,7 @@ public class TestNGCitrusMethodInterceptor implements IMethodInterceptor { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(TestNGCitrusMethodInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(TestNGCitrusMethodInterceptor.class); @Override public List intercept(List methods, ITestContext context) { @@ -82,7 +82,7 @@ public List intercept(List methods, ITestConte } } } catch (IOException e) { - log.error("Unable to locate file resources for test package '" + packageName + "'", e); + logger.error("Unable to locate file resources for test package '" + packageName + "'", e); } } } else if (method.getMethod().getConstructorOrMethod().getMethod().getAnnotation(CitrusXmlTest.class) != null) { diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusSupport.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusSupport.java index 7faf47e3cd..6d45d4b2db 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusSupport.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGCitrusSupport.java @@ -41,8 +41,6 @@ import org.citrusframework.common.TestSourceAware; import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.testng.IHookCallBack; import org.testng.IHookable; import org.testng.ITestContext; @@ -63,9 +61,6 @@ @Listeners( { TestNGCitrusMethodInterceptor.class } ) public class TestNGCitrusSupport implements IHookable, GherkinTestActionRunner { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(getClass()); - /** Citrus instance */ protected Citrus citrus; diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGEngine.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGEngine.java index fd8613118f..e2dc058349 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGEngine.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGEngine.java @@ -48,7 +48,7 @@ public class TestNGEngine extends AbstractTestEngine { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TestNGEngine.class); + private static final Logger logger = LoggerFactory.getLogger(TestNGEngine.class); private final List listeners = new ArrayList<>(); @@ -72,7 +72,7 @@ public void run() { if (!CollectionUtils.isEmpty(getConfiguration().getTestClasses())) { for (TestClass testClass : getConfiguration().getTestClasses()) { - LOG.info(String.format("Running test %s", + logger.info(String.format("Running test %s", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) .orElse(testClass.getName()))); @@ -95,19 +95,19 @@ public void run() { test.getClasses().add(xmlClass); } catch (ClassNotFoundException | MalformedURLException e) { - LOG.warn("Unable to read test class: " + testClass.getName()); + logger.warn("Unable to read test class: " + testClass.getName()); } } } else { List packagesToRun = getConfiguration().getPackages(); if (CollectionUtils.isEmpty(packagesToRun)) { packagesToRun = Collections.singletonList(""); - LOG.info("Running all tests in project"); + logger.info("Running all tests in project"); } for (String packageName : packagesToRun) { if (StringUtils.hasText(packageName)) { - LOG.info(String.format("Running tests in package %s", packageName)); + logger.info(String.format("Running tests in package %s", packageName)); } XmlTest test = new XmlTest(suite); @@ -122,7 +122,7 @@ public void run() { } classesToRun.stream() - .peek(testClass -> LOG.info(String.format("Running test %s", + .peek(testClass -> logger.info(String.format("Running test %s", Optional.ofNullable(testClass.getMethod()).map(method -> testClass.getName() + "#" + method) .orElse(testClass.getName())))) .map(testClass -> { @@ -136,7 +136,7 @@ public void run() { } return clazz; } catch (ClassNotFoundException | MalformedURLException e) { - LOG.warn("Unable to read test class: " + testClass.getName()); + logger.warn("Unable to read test class: " + testClass.getName()); return Void.class; } }) @@ -144,7 +144,7 @@ public void run() { .map(XmlClass::new) .forEach(test.getClasses()::add); - LOG.info(String.format("Found %s test classes to execute", test.getClasses().size())); + logger.info(String.format("Found %s test classes to execute", test.getClasses().size())); } } diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGHelper.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGHelper.java index 6a59d7cb24..9644938ccf 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGHelper.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/TestNGHelper.java @@ -57,7 +57,7 @@ public final class TestNGHelper { public static final String BUILDER_ATTRIBUTE = "builder"; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(TestNGHelper.class); + private static final Logger logger = LoggerFactory.getLogger(TestNGHelper.class); /** * Prevent instantiation of utility class @@ -184,7 +184,7 @@ private static List createMethodTestLoaders(Method method, ((TestSourceAware) testLoader).setSource(source); methodTestLoaders.add(testLoader); } else { - LOG.warn(String.format("Test loader %s is not able to handle test source %s", testLoader.getClass(), source)); + logger.warn(String.format("Test loader %s is not able to handle test source %s", testLoader.getClass(), source)); } } diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringMethodInterceptor.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringMethodInterceptor.java index 0b7f434a56..eae5c25a84 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringMethodInterceptor.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringMethodInterceptor.java @@ -45,7 +45,7 @@ public class TestNGCitrusSpringMethodInterceptor implements IMethodInterceptor { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(TestNGCitrusSpringMethodInterceptor.class); + private static final Logger logger = LoggerFactory.getLogger(TestNGCitrusSpringMethodInterceptor.class); @Override public List intercept(List methods, ITestContext context) { @@ -82,7 +82,7 @@ public List intercept(List methods, ITestConte } } } catch (IOException e) { - log.error("Unable to locate file resources for test package '" + packageName + "'", e); + logger.error("Unable to locate file resources for test package '" + packageName + "'", e); } } } else if (method.getMethod().getConstructorOrMethod().getMethod().getAnnotation(CitrusXmlTest.class) != null) { @@ -113,7 +113,7 @@ public List intercept(List methods, ITestConte } } } catch (IOException e) { - log.error("Unable to locate file resources for test package '" + packageName + "'", e); + logger.error("Unable to locate file resources for test package '" + packageName + "'", e); } } } diff --git a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringSupport.java b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringSupport.java index 761f9f69fa..50e62f08f1 100644 --- a/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringSupport.java +++ b/runtime/citrus-testng/src/main/java/org/citrusframework/testng/spring/TestNGCitrusSpringSupport.java @@ -47,8 +47,6 @@ import org.citrusframework.context.TestContext; import org.citrusframework.exceptions.CitrusRuntimeException; import org.citrusframework.testng.TestNGHelper; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.springframework.util.Assert; @@ -74,9 +72,6 @@ public class TestNGCitrusSpringSupport extends AbstractTestNGSpringContextTests implements GherkinTestActionRunner { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(getClass()); - /** Citrus instance */ protected Citrus citrus; diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/TextEqualsMessageValidator.java b/runtime/citrus-testng/src/test/java/org/citrusframework/TextEqualsMessageValidator.java index 0482dbcf51..40d171390c 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/TextEqualsMessageValidator.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/TextEqualsMessageValidator.java @@ -16,19 +16,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage.getPayload(String.class).isBlank()) { - log.info("Skip text validation as no control message payload specified"); + logger.info("Skip text validation as no control message payload specified"); return; } Assert.assertEquals(receivedMessage.getPayload(String.class), controlMessage.getPayload(String.class), "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/AsyncJavaIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/AsyncJavaIT.java index 905266cd62..d973d638b5 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/AsyncJavaIT.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/AsyncJavaIT.java @@ -49,7 +49,7 @@ public void asyncContainer() { echo("Hello Citrus"), action(context -> context.setVariable("anonymous", "anonymous")), sleep().milliseconds(500), - action(context -> log.info(context.getVariable("anonymous"))) + action(context -> logger.info(context.getVariable("anonymous"))) )); run(async().actions( @@ -63,7 +63,7 @@ public void asyncContainer() { echo("Hello Citrus"), action(context -> context.setVariable("anonymous", "anonymous")), sleep().milliseconds(200), - action(context -> log.info(context.getVariable("anonymous"))) + action(context -> logger.info(context.getVariable("anonymous"))) )); run(sleep().milliseconds(500L)); diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/IterateJavaIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/IterateJavaIT.java index 6c10d3f7ea..7fc6c190f0 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/IterateJavaIT.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/IterateJavaIT.java @@ -53,7 +53,7 @@ public void iterateContainer() { .step(5) .actions(echo("index is: ${i}"))); - AbstractTestAction anonymous = action(context -> log.info(context.getVariable("index"))).build(); + AbstractTestAction anonymous = action(context -> logger.info(context.getVariable("index"))).build(); run(iterate().condition("i lt 5").index("i") .actions(createVariable("index", "${i}"), () -> anonymous)); diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/SequentialJavaIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/SequentialJavaIT.java index f7a6ec75aa..2dba5338e9 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/SequentialJavaIT.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/container/SequentialJavaIT.java @@ -45,7 +45,7 @@ public void sequentialContainer() { echo("Hello Citrus"), action(context -> context.setVariable("anonymous", "anonymous")), sleep().milliseconds(500), - action(context -> log.info(context.getVariable("anonymous"))) + action(context -> logger.info(context.getVariable("anonymous"))) )); run(sequential().actions( @@ -59,7 +59,7 @@ public void sequentialContainer() { echo("Hello Citrus"), action(context -> context.setVariable("anonymous", "anonymous")), sleep().milliseconds(200), - action(context -> log.info(context.getVariable("anonymous"))) + action(context -> logger.info(context.getVariable("anonymous"))) )); } } diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/server/SimpleServer.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/server/SimpleServer.java index 20354e6535..4aaaf0fe41 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/server/SimpleServer.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/server/SimpleServer.java @@ -32,7 +32,7 @@ public class SimpleServer extends AbstractServer { /** Logger */ - private static Logger log = LoggerFactory.getLogger(SimpleServer.class); + private static final Logger logger = LoggerFactory.getLogger(SimpleServer.class); /** Server publishes start stop events to this channel **/ private DirectEndpoint statusEndpoint; @@ -43,13 +43,13 @@ public class SimpleServer extends AbstractServer { @Override protected void startup() { - log.info("Simple server was started successfully!"); + logger.info("Simple server was started successfully!"); statusEndpoint.createProducer().send(new RawMessage("SERVER STARTED"), testContextFactory.getObject()); } @Override protected void shutdown() { - log.info("Simple server was stopped successfully!"); + logger.info("Simple server was stopped successfully!"); statusEndpoint.createProducer().send(new RawMessage("SERVER STOPPED"), testContextFactory.getObject()); } diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/util/InvocationDummy.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/util/InvocationDummy.java index 0c099de3cf..2b6c699cb2 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/util/InvocationDummy.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/util/InvocationDummy.java @@ -32,33 +32,33 @@ public class InvocationDummy { /** * Logger */ - private static Logger log = LoggerFactory.getLogger(InvocationDummy.class); + private static final Logger logger = LoggerFactory.getLogger(InvocationDummy.class); public InvocationDummy() { - if (log.isDebugEnabled()) { - log.debug("Constructor without argument"); + if (logger.isDebugEnabled()) { + logger.debug("Constructor without argument"); } } public InvocationDummy(String arg) { checkNotVariable(arg); - if (log.isDebugEnabled()) { - log.debug("Constructor with argument: " + arg); + if (logger.isDebugEnabled()) { + logger.debug("Constructor with argument: " + arg); } } public void invoke() { - if (log.isDebugEnabled()) { - log.debug("Methode invoke no arguments"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke no arguments"); } } public void invoke(String text) { checkNotVariable(text); - if (log.isDebugEnabled()) { - log.debug("Methode invoke with string argument: '" + text + "'"); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with string argument: '" + text + "'"); } } @@ -67,8 +67,8 @@ public void invoke(String[] args) { checkNotVariable(args[i]); - if (log.isDebugEnabled()) { - log.debug("Methode invoke with argument: " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("Methode invoke with argument: " + args[i]); } } } @@ -76,11 +76,11 @@ public void invoke(String[] args) { public void invoke(Integer arg1, String arg2, Boolean arg3) { checkNotVariable(arg2); - if (log.isDebugEnabled()) { - log.debug("Method invoke with arguments:"); - log.debug("arg1: " + arg1); - log.debug("arg2: " + arg2); - log.debug("arg3: " + arg3); + if (logger.isDebugEnabled()) { + logger.debug("Method invoke with arguments:"); + logger.debug("arg1: " + arg1); + logger.debug("arg2: " + arg2); + logger.debug("arg3: " + arg3); } } @@ -96,8 +96,8 @@ public static void main(String[] args) { for (int i = 0; i < args.length; i++) { checkNotVariable(args[i]); - if (log.isDebugEnabled()) { - log.debug("arg" + i + ": " + args[i]); + if (logger.isDebugEnabled()) { + logger.debug("arg" + i + ": " + args[i]); } } } diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/variables/GlobalVariablesJavaIT.java b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/variables/GlobalVariablesJavaIT.java index 81773fcabe..40f90152d6 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/integration/variables/GlobalVariablesJavaIT.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/integration/variables/GlobalVariablesJavaIT.java @@ -69,7 +69,7 @@ private void assertVariableValuesMatchWhenReadMultipleTimes(final TestContext te String val1 = testContext.resolveDynamicValue(testContext.getVariable(name)); String val2 = testContext.resolveDynamicValue(testContext.getVariable(name)); if (val1.equals(val2)) { - log.debug(String.format("Values match for variable %s. Value: %s", name, val1)); + logger.debug(String.format("Values match for variable %s. Value: %s", name, val1)); } else { throw new RuntimeException(String.format("Values don't match for variable %s. Value1: %s, Value2: %s", name, val1, val2)); } @@ -79,7 +79,7 @@ private void assertVariableValuesMatch(final TestContext testContext, final Stri String val1 = testContext.resolveDynamicValue(testContext.getVariable(name1)); String val2 = testContext.resolveDynamicValue(testContext.getVariable(name2)); if (val1.equals(val2)) { - log.debug(String.format("Values match for variables %s and %s. Value: %s", name1, name2, val1)); + logger.debug(String.format("Values match for variables %s and %s. Value: %s", name1, name2, val1)); } else { throw new RuntimeException(String.format("Values don't match for variables. %s: %s, %s: %s", name1, val1, name2, val2)); } diff --git a/runtime/citrus-testng/src/test/java/org/citrusframework/testng/CitrusSpringConfigTest.java b/runtime/citrus-testng/src/test/java/org/citrusframework/testng/CitrusSpringConfigTest.java index 1ac4520d99..f448b5dee5 100644 --- a/runtime/citrus-testng/src/test/java/org/citrusframework/testng/CitrusSpringConfigTest.java +++ b/runtime/citrus-testng/src/test/java/org/citrusframework/testng/CitrusSpringConfigTest.java @@ -8,8 +8,8 @@ import org.citrusframework.functions.DefaultFunctionLibrary; import org.citrusframework.functions.FunctionLibrary; import org.citrusframework.functions.FunctionRegistry; -import org.citrusframework.log.DefaultLogModifier; -import org.citrusframework.log.LogModifier; +import org.citrusframework.logger.DefaultLogModifier; +import org.citrusframework.logger.LogModifier; import org.citrusframework.message.MessageProcessor; import org.citrusframework.message.MessageProcessors; import org.citrusframework.report.FailureStackTestListener; diff --git a/runtime/citrus-xml/src/main/java/org/citrusframework/xml/actions/XmlTestActionBuilder.java b/runtime/citrus-xml/src/main/java/org/citrusframework/xml/actions/XmlTestActionBuilder.java index 3c4a34d11f..cd115946af 100644 --- a/runtime/citrus-xml/src/main/java/org/citrusframework/xml/actions/XmlTestActionBuilder.java +++ b/runtime/citrus-xml/src/main/java/org/citrusframework/xml/actions/XmlTestActionBuilder.java @@ -33,7 +33,7 @@ public interface XmlTestActionBuilder { /** Logger */ - Logger LOG = LoggerFactory.getLogger(XmlTestActionBuilder.class); + Logger logger = LoggerFactory.getLogger(XmlTestActionBuilder.class); /** Endpoint builder resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/xml/builder"; @@ -72,10 +72,10 @@ static Optional> lookup(String name, String namespace) { } return Optional.of(builder); } catch (CitrusRuntimeException e) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); } else { - LOG.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); } } diff --git a/runtime/citrus-xml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java b/runtime/citrus-xml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java index eb557ecfa7..760124479a 100644 --- a/runtime/citrus-xml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java +++ b/runtime/citrus-xml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java @@ -34,19 +34,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + private boolean normalizeLineEndings = false; private boolean trim = false; @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage == null || controlMessage.getPayload() == null || controlMessage.getPayload(String.class).isEmpty()) { - LOG.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } - log.debug("Start text equals validation ..."); + logger.debug("Start text equals validation ..."); String controlPayload = controlMessage.getPayload(String.class); String receivedPayload = receivedMessage.getPayload(String.class); @@ -64,7 +64,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes Assert.assertEquals(receivedPayload, controlPayload, "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/runtime/citrus-yaml/src/main/java/org/citrusframework/yaml/actions/YamlTestActionBuilder.java b/runtime/citrus-yaml/src/main/java/org/citrusframework/yaml/actions/YamlTestActionBuilder.java index e490845e21..9c80459c47 100644 --- a/runtime/citrus-yaml/src/main/java/org/citrusframework/yaml/actions/YamlTestActionBuilder.java +++ b/runtime/citrus-yaml/src/main/java/org/citrusframework/yaml/actions/YamlTestActionBuilder.java @@ -34,7 +34,7 @@ public interface YamlTestActionBuilder { /** Logger */ - Logger LOG = LoggerFactory.getLogger(YamlTestActionBuilder.class); + Logger logger = LoggerFactory.getLogger(YamlTestActionBuilder.class); /** Endpoint builder resource lookup path */ String RESOURCE_PATH = "META-INF/citrus/yaml/builder"; @@ -50,8 +50,8 @@ public interface YamlTestActionBuilder { static Map> lookup() { Map> loader = TYPE_RESOLVER.resolveAll(); - if (LOG.isDebugEnabled()) { - loader.forEach((k, v) -> LOG.debug(String.format("Found YAML test action builder '%s' as %s", k, v.getClass()))); + if (logger.isDebugEnabled()) { + loader.forEach((k, v) -> logger.debug(String.format("Found YAML test action builder '%s' as %s", k, v.getClass()))); } return loader; } @@ -69,10 +69,10 @@ static Optional> lookup(String name) { try { return Optional.of(TYPE_RESOLVER.resolve(name)); } catch (CitrusRuntimeException e) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name), e); } else { - LOG.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); + logger.warn(String.format("Failed to resolve test action builder from resource '%s/%s'", RESOURCE_PATH, name)); } } diff --git a/runtime/citrus-yaml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java b/runtime/citrus-yaml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java index eb557ecfa7..760124479a 100644 --- a/runtime/citrus-yaml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java +++ b/runtime/citrus-yaml/src/test/java/org/citrusframework/validation/TextEqualsMessageValidator.java @@ -34,19 +34,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + private boolean normalizeLineEndings = false; private boolean trim = false; @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage == null || controlMessage.getPayload() == null || controlMessage.getPayload(String.class).isEmpty()) { - LOG.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } - log.debug("Start text equals validation ..."); + logger.debug("Start text equals validation ..."); String controlPayload = controlMessage.getPayload(String.class); String receivedPayload = receivedMessage.getPayload(String.class); @@ -64,7 +64,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes Assert.assertEquals(receivedPayload, controlPayload, "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/tools/docs-generator/src/main/java/org/citrusframework/docs/AbstractTestDocsGenerator.java b/tools/docs-generator/src/main/java/org/citrusframework/docs/AbstractTestDocsGenerator.java index ef6a6d8e3a..91d918e90e 100644 --- a/tools/docs-generator/src/main/java/org/citrusframework/docs/AbstractTestDocsGenerator.java +++ b/tools/docs-generator/src/main/java/org/citrusframework/docs/AbstractTestDocsGenerator.java @@ -49,7 +49,7 @@ public abstract class AbstractTestDocsGenerator implements TestDocsGenerator { /** Logger */ - Logger log = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); private static final String OVERVIEW_PLACEHOLDER = "+++++ OVERVIEW +++++"; private static final String BODY_PLACEHOLDER = "+++++ BODY +++++"; @@ -102,7 +102,7 @@ public void generateDoc() { try { reader.close(); } catch (final IOException e) { - log.error("Failed to close reader", e); + logger.error("Failed to close reader", e); } } @@ -110,7 +110,7 @@ public void generateDoc() { try { buffered.flush(); } catch (final IOException e) { - log.error("Failed to close output stream", e); + logger.error("Failed to close output stream", e); } } @@ -118,7 +118,7 @@ public void generateDoc() { try { fos.close(); } catch (final IOException e) { - log.error("Failed to close file", e); + logger.error("Failed to close file", e); } } } diff --git a/tools/docs-generator/src/main/java/org/citrusframework/docs/SvgTestDocsGenerator.java b/tools/docs-generator/src/main/java/org/citrusframework/docs/SvgTestDocsGenerator.java index 68da4090ee..8cdeabfaae 100644 --- a/tools/docs-generator/src/main/java/org/citrusframework/docs/SvgTestDocsGenerator.java +++ b/tools/docs-generator/src/main/java/org/citrusframework/docs/SvgTestDocsGenerator.java @@ -56,7 +56,7 @@ public void generateDoc() { List testFiles = getTestFiles(); for (File testFile : testFiles) { - log.info("Working on test " + testFile.getName()); + logger.info("Working on test " + testFile.getName()); fos = getFileOutputStream(testFile.getName().substring(0, testFile.getName().lastIndexOf('.')) + ".svg"); buffered = new BufferedOutputStream(fos); @@ -66,7 +66,7 @@ public void generateDoc() { t.transform(xml, res); - log.info("Finished test " + testFile.getName()); + logger.info("Finished test " + testFile.getName()); buffered.flush(); fos.close(); @@ -82,7 +82,7 @@ public void generateDoc() { try { buffered.flush(); } catch (IOException e) { - log.error("Failed to close output stream", e); + logger.error("Failed to close output stream", e); } } @@ -90,7 +90,7 @@ public void generateDoc() { try { fos.close(); } catch (IOException e) { - log.error("Failed to close file", e); + logger.error("Failed to close file", e); } } } diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/AbstractTestGenerator.java b/tools/test-generator/src/main/java/org/citrusframework/generate/AbstractTestGenerator.java index 38122285d2..4683158c5c 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/AbstractTestGenerator.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/AbstractTestGenerator.java @@ -31,7 +31,7 @@ public abstract class AbstractTestGenerator implements TestGenerator { /** Logger */ - protected Logger log = LoggerFactory.getLogger(getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); /** Test name */ private String name; diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/SwaggerJavaTestGenerator.java b/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/SwaggerJavaTestGenerator.java index 88e70a9d32..3994c087b3 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/SwaggerJavaTestGenerator.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/SwaggerJavaTestGenerator.java @@ -169,7 +169,7 @@ public void create() { super.create(); - log.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); } } } diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/WsdlJavaTestGenerator.java b/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/WsdlJavaTestGenerator.java index 76a8fb853d..266fdf2be4 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/WsdlJavaTestGenerator.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/javadsl/WsdlJavaTestGenerator.java @@ -68,21 +68,21 @@ public void create() { XmlObject wsdlObject = compileWsdl(wsdl); SchemaTypeSystem schemaTypeSystem = compileXsd(wsdlObject); - log.info("WSDL compilation successful"); + logger.info("WSDL compilation successful"); String serviceName = evaluateAsString(wsdlObject, wsdlNsDelaration + ".//wsdl:portType/@name"); - log.info("Found service: " + serviceName); + logger.info("Found service: " + serviceName); if (!StringUtils.hasText(namePrefix)) { withNamePrefix(serviceName + "_"); } - log.info("Found service operations:"); + logger.info("Found service operations:"); XmlObject[] messages = wsdlObject.selectPath(wsdlNsDelaration + ".//wsdl:message"); XmlObject[] operations = wsdlObject.selectPath(wsdlNsDelaration + ".//wsdl:portType/wsdl:operation"); for (XmlObject operation : operations) { - log.info(evaluateAsString(operation, wsdlNsDelaration + "./@name")); + logger.info(evaluateAsString(operation, wsdlNsDelaration + "./@name")); } - log.info("Generating test cases for service operations ..."); + logger.info("Generating test cases for service operations ..."); for (XmlObject operation : operations) { SoapMessage request = new SoapMessage(); @@ -139,7 +139,7 @@ public void create() { super.create(); - log.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); } } @@ -180,7 +180,7 @@ private XmlObject compileWsdl(String wsdl) { return XmlObject.Factory.parse(wsdlFile, (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest().setCompileDownloadUrls()); } catch (XmlException e) { for (Object error : e.getErrors()) { - log.error(((XmlError)error).getLine() + "" + error.toString()); + logger.error(((XmlError)error).getLine() + "" + error.toString()); } throw new CitrusRuntimeException("WSDL could not be parsed", e); } catch (Exception e) { @@ -217,7 +217,7 @@ private SchemaTypeSystem compileXsd(XmlObject wsdl) { schemaTypeSystem = XmlBeans.compileXsd(xsd, XmlBeans.getContextTypeLoader(), new XmlOptions()); } catch (XmlException e) { for (Object error : e.getErrors()) { - log.error("Line " + ((XmlError)error).getLine() + ": " + error.toString()); + logger.error("Line " + ((XmlError)error).getLine() + ": " + error.toString()); } throw new CitrusRuntimeException("Failed to compile XSD schema", e); } catch (Exception e) { diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/SwaggerXmlTestGenerator.java b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/SwaggerXmlTestGenerator.java index 36f18c52cf..57477f210d 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/SwaggerXmlTestGenerator.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/SwaggerXmlTestGenerator.java @@ -163,7 +163,7 @@ public void create() { super.create(); - log.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); } } } diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/WsdlXmlTestGenerator.java b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/WsdlXmlTestGenerator.java index ceb150a597..4c14cb4124 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/WsdlXmlTestGenerator.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/WsdlXmlTestGenerator.java @@ -71,21 +71,21 @@ public void create() { XmlObject wsdlObject = compileWsdl(wsdl); SchemaTypeSystem schemaTypeSystem = compileXsd(wsdlObject); - log.info("WSDL compilation successful"); + logger.info("WSDL compilation successful"); String serviceName = evaluateAsString(wsdlObject, wsdlNsDelaration + ".//wsdl:portType/@name"); - log.info("Found service: " + serviceName); + logger.info("Found service: " + serviceName); if (!StringUtils.hasText(namePrefix)) { withNamePrefix(serviceName + "_"); } - log.info("Found service operations:"); + logger.info("Found service operations:"); XmlObject[] messages = wsdlObject.selectPath(wsdlNsDelaration + ".//wsdl:message"); XmlObject[] operations = wsdlObject.selectPath(wsdlNsDelaration + ".//wsdl:portType/wsdl:operation"); for (XmlObject operation : operations) { - log.info(evaluateAsString(operation, wsdlNsDelaration + "./@name")); + logger.info(evaluateAsString(operation, wsdlNsDelaration + "./@name")); } - log.info("Generating test cases for service operations ..."); + logger.info("Generating test cases for service operations ..."); for (XmlObject operation : operations) { SoapMessage request = new SoapMessage(); @@ -142,7 +142,7 @@ public void create() { super.create(); - log.info("Successfully created new test case " + getTargetPackage() + "." + getName()); + logger.info("Successfully created new test case " + getTargetPackage() + "." + getName()); } } @@ -198,7 +198,7 @@ private XmlObject compileWsdl(String wsdl) { return XmlObject.Factory.parse(wsdlFile, (new XmlOptions()).setLoadLineNumbers().setLoadMessageDigest().setCompileDownloadUrls()); } catch (XmlException e) { for (Object error : e.getErrors()) { - log.error(((XmlError)error).getLine() + "" + error.toString()); + logger.error(((XmlError)error).getLine() + "" + error.toString()); } throw new CitrusRuntimeException("WSDL could not be parsed", e); } catch (Exception e) { @@ -235,7 +235,7 @@ private SchemaTypeSystem compileXsd(XmlObject wsdl) { schemaTypeSystem = XmlBeans.compileXsd(xsd, XmlBeans.getContextTypeLoader(), new XmlOptions()); } catch (XmlException e) { for (Object error : e.getErrors()) { - log.error("Line " + ((XmlError)error).getLine() + ": " + error.toString()); + logger.error("Line " + ((XmlError)error).getLine() + ": " + error.toString()); } throw new CitrusRuntimeException("Failed to compile XSD schema", e); } catch (Exception e) { diff --git a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/XmlTestMarshaller.java b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/XmlTestMarshaller.java index 57a74f20fc..f6cc4af491 100644 --- a/tools/test-generator/src/main/java/org/citrusframework/generate/xml/XmlTestMarshaller.java +++ b/tools/test-generator/src/main/java/org/citrusframework/generate/xml/XmlTestMarshaller.java @@ -49,7 +49,7 @@ public class XmlTestMarshaller { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(XmlTestMarshaller.class); + private static final Logger logger = LoggerFactory.getLogger(XmlTestMarshaller.class); private volatile JAXBContext jaxbContext; private final Schema schema; @@ -108,8 +108,8 @@ private Unmarshaller createUnmarshaller() throws JAXBException { private JAXBContext getOrCreateContext() throws JAXBException { if (jaxbContext == null) { synchronized (this) { - if (log.isDebugEnabled()) { - log.debug(String.format("Creating JAXBContext with context path %s", contextPath)); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Creating JAXBContext with context path %s", contextPath)); } jaxbContext = JAXBContext.newInstance(contextPath); @@ -119,8 +119,8 @@ private JAXBContext getOrCreateContext() throws JAXBException { } private Schema loadSchema(Resource resource) { - if (log.isDebugEnabled()) { - log.debug(String.format("Using marshaller validation schema '%s'", resource.getFilename())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Using marshaller validation schema '%s'", resource.getFilename())); } try { diff --git a/utils/citrus-test-support/src/main/java/org/citrusframework/testng/AbstractTestNGUnitTest.java b/utils/citrus-test-support/src/main/java/org/citrusframework/testng/AbstractTestNGUnitTest.java index 393401336b..8baaaab216 100644 --- a/utils/citrus-test-support/src/main/java/org/citrusframework/testng/AbstractTestNGUnitTest.java +++ b/utils/citrus-test-support/src/main/java/org/citrusframework/testng/AbstractTestNGUnitTest.java @@ -18,8 +18,6 @@ import org.citrusframework.context.TestContext; import org.citrusframework.context.TestContextFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.testng.AbstractTestNGSpringContextTests; import org.springframework.util.Assert; @@ -36,9 +34,6 @@ @ContextConfiguration(classes = UnitTestConfig.class) public abstract class AbstractTestNGUnitTest extends AbstractTestNGSpringContextTests { - /** Logger */ - protected final Logger log = LoggerFactory.getLogger(getClass()); - /** Test context */ protected TestContext context; diff --git a/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/GroovyScriptMessageValidator.java b/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/GroovyScriptMessageValidator.java index 894bea3a98..ad0f18b781 100644 --- a/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/GroovyScriptMessageValidator.java +++ b/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/GroovyScriptMessageValidator.java @@ -49,7 +49,7 @@ public class GroovyScriptMessageValidator extends AbstractMessageValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(GroovyScriptMessageValidator.class); + private static final Logger logger = LoggerFactory.getLogger(GroovyScriptMessageValidator.class); /** Static code snippet for groovy script validation */ private final Resource scriptTemplateResource; @@ -76,7 +76,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes String validationScript = validationContext.getValidationScript(context); if (StringUtils.hasText(validationScript)) { - log.debug("Start groovy message validation ..."); + logger.debug("Start groovy message validation ..."); GroovyClassLoader loader = AccessController.doPrivileged(new PrivilegedAction() { public GroovyClassLoader run() { @@ -94,7 +94,7 @@ public GroovyClassLoader run() { GroovyObject groovyObject = (GroovyObject) groovyClass.newInstance(); ((GroovyScriptExecutor) groovyObject).validate(receivedMessage, context); - log.info("Groovy message validation successful: All values OK"); + logger.info("Groovy message validation successful: All values OK"); } } catch (CompilationFailedException | InstantiationException | IllegalAccessException e) { throw new CitrusRuntimeException(e); diff --git a/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/sql/GroovySqlResultSetValidator.java b/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/sql/GroovySqlResultSetValidator.java index 3f81b97737..4e3ce1807d 100644 --- a/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/sql/GroovySqlResultSetValidator.java +++ b/validation/citrus-validation-groovy/src/main/java/org/citrusframework/validation/script/sql/GroovySqlResultSetValidator.java @@ -46,7 +46,7 @@ public class GroovySqlResultSetValidator implements SqlResultSetScriptValidator /** * Logger */ - private static Logger log = LoggerFactory.getLogger(GroovySqlResultSetValidator.class); + private static final Logger logger = LoggerFactory.getLogger(GroovySqlResultSetValidator.class); /** Static code snippet for groovy script validation */ private Resource scriptTemplateResource; @@ -75,7 +75,7 @@ public void validateSqlResultSet(List> resultSet, String validationScript = validationContext.getValidationScript(context); if (StringUtils.hasText(validationScript)) { - log.debug("Start groovy SQL result set validation"); + logger.debug("Start groovy SQL result set validation"); GroovyClassLoader loader = new GroovyClassLoader(GroovyScriptMessageValidator.class.getClassLoader()); Class groovyClass = loader.parseClass(TemplateBasedScriptBuilder.fromTemplateResource(scriptTemplateResource) @@ -89,7 +89,7 @@ public void validateSqlResultSet(List> resultSet, GroovyObject groovyObject = (GroovyObject) groovyClass.getDeclaredConstructor().newInstance(); ((SqlResultSetScriptExecutor) groovyObject).validate(resultSet, context); - log.info("Groovy SQL result set validation successful: All values OK"); + logger.info("Groovy SQL result set validation successful: All values OK"); } } catch (CompilationFailedException | InstantiationException | InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { throw new CitrusRuntimeException(e); diff --git a/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/HamcrestHeaderValidator.java b/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/HamcrestHeaderValidator.java index 295c01776a..26d1c8f17f 100644 --- a/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/HamcrestHeaderValidator.java +++ b/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/HamcrestHeaderValidator.java @@ -32,7 +32,7 @@ public class HamcrestHeaderValidator implements HeaderValidator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(HamcrestHeaderValidator.class); + private static final Logger logger = LoggerFactory.getLogger(HamcrestHeaderValidator.class); @Override public void validateHeader(String headerName, Object receivedValue, Object controlValue, TestContext context, HeaderValidationContext validationContext) { @@ -51,8 +51,8 @@ public void validateHeader(String headerName, Object receivedValue, Object contr throw new ValidationException("Validation failed:", e); } - if (log.isDebugEnabled()) { - log.debug("Validating header element: " + headerName + "='" + controlValue + "': OK."); + if (logger.isDebugEnabled()) { + logger.debug("Validating header element: " + headerName + "='" + controlValue + "': OK."); } } diff --git a/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/matcher/hamcrest/HamcrestMatcherProvider.java b/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/matcher/hamcrest/HamcrestMatcherProvider.java index 60b848bd80..003209b860 100644 --- a/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/matcher/hamcrest/HamcrestMatcherProvider.java +++ b/validation/citrus-validation-hamcrest/src/main/java/org/citrusframework/validation/matcher/hamcrest/HamcrestMatcherProvider.java @@ -31,7 +31,7 @@ public interface HamcrestMatcherProvider { /** Logger */ - Logger LOG = LoggerFactory.getLogger(HamcrestMatcherProvider.class); + Logger logger = LoggerFactory.getLogger(HamcrestMatcherProvider.class); /** Resource path where to lookup custom matcher providers in classpath */ String RESOURCE_PATH = "META-INF/citrus/hamcrest/matcher/provider"; @@ -49,7 +49,7 @@ static Optional lookup(String matcherName) { try { return Optional.of(TYPE_RESOLVER.resolve(matcherName)); } catch (CitrusRuntimeException e) { - LOG.warn(String.format("Failed to resolve Hamcrest matcher provider from resource '%s/%s'", RESOURCE_PATH, matcherName)); + logger.warn(String.format("Failed to resolve Hamcrest matcher provider from resource '%s/%s'", RESOURCE_PATH, matcherName)); } return Optional.empty(); diff --git a/validation/citrus-validation-hamcrest/src/test/java/org/citrusframework/TextEqualsMessageValidator.java b/validation/citrus-validation-hamcrest/src/test/java/org/citrusframework/TextEqualsMessageValidator.java index 0482dbcf51..40d171390c 100644 --- a/validation/citrus-validation-hamcrest/src/test/java/org/citrusframework/TextEqualsMessageValidator.java +++ b/validation/citrus-validation-hamcrest/src/test/java/org/citrusframework/TextEqualsMessageValidator.java @@ -16,19 +16,19 @@ */ public class TextEqualsMessageValidator extends DefaultMessageValidator { + private static final Logger logger = LoggerFactory.getLogger(TextEqualsMessageValidator.class); + @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) { - Logger log = LoggerFactory.getLogger("TextEqualsMessageValidator"); - if (controlMessage.getPayload(String.class).isBlank()) { - log.info("Skip text validation as no control message payload specified"); + logger.info("Skip text validation as no control message payload specified"); return; } Assert.assertEquals(receivedMessage.getPayload(String.class), controlMessage.getPayload(String.class), "Validation failed - " + "expected message contents not equal!"); - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } @Override diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/json/JsonSchemaRepository.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/json/JsonSchemaRepository.java index c8208b8154..08cce597b2 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/json/JsonSchemaRepository.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/json/JsonSchemaRepository.java @@ -45,7 +45,7 @@ public class JsonSchemaRepository implements Named, InitializingPhase { private List locations = new ArrayList<>(); /** Logger */ - private static Logger log = LoggerFactory.getLogger(JsonSchemaRepository.class); + private static final Logger logger = LoggerFactory.getLogger(JsonSchemaRepository.class); @Override public void setName(String name) { @@ -71,14 +71,14 @@ public void initialize() { private void addSchemas(Resource resource) { if (resource.getFilename().endsWith(".json")) { - if (log.isDebugEnabled()) { - log.debug("Loading json schema resource " + resource.getFilename()); + if (logger.isDebugEnabled()) { + logger.debug("Loading json schema resource " + resource.getFilename()); } SimpleJsonSchema simpleJsonSchema = new SimpleJsonSchema(resource); simpleJsonSchema.initialize(); schemas.add(simpleJsonSchema); } else { - log.warn("Skipped resource other than json schema for repository (" + resource.getFilename() + ")"); + logger.warn("Skipped resource other than json schema for repository (" + resource.getFilename() + ")"); } } @@ -95,11 +95,11 @@ public void setSchemas(List schemas) { } public static Logger getLog() { - return log; + return logger; } - public static void setLog(Logger log) { - JsonSchemaRepository.log = log; + public static void setLog(Logger logger) { + JsonSchemaRepository.private static final Logger logger = logger; } public List getLocations() { diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonMappingValidationProcessor.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonMappingValidationProcessor.java index 688bda9a05..933eb8309a 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonMappingValidationProcessor.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonMappingValidationProcessor.java @@ -39,7 +39,7 @@ public abstract class JsonMappingValidationProcessor extends AbstractValidationProcessor { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(JsonMappingValidationProcessor.class); + private static final Logger logger = LoggerFactory.getLogger(JsonMappingValidationProcessor.class); /** JSON object mapper */ private ObjectMapper mapper; @@ -64,11 +64,11 @@ public JsonMappingValidationProcessor(Class resultType, ObjectMapper mapper) @Override public void validate(Message message, TestContext context) { - log.debug("Start JSON object validation ..."); + logger.debug("Start JSON object validation ..."); validate(readJson(message), message.getHeaders(), context); - log.info("JSON object validation successful: All values OK"); + logger.info("JSON object validation successful: All values OK"); } private T readJson(Message message) { diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageProcessor.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageProcessor.java index 3789d1a0a8..152564f8a7 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageProcessor.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageProcessor.java @@ -44,7 +44,7 @@ public class JsonPathMessageProcessor extends AbstractMessageProcessor { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(JsonPathMessageProcessor.class); + private static final Logger logger = LoggerFactory.getLogger(JsonPathMessageProcessor.class); /** Overwrites message elements before validating (via JSONPath expressions) */ private final Map jsonPathExpressions; @@ -109,8 +109,8 @@ public void processMessage(Message message, TestContext context) { } } - if (log.isDebugEnabled()) { - log.debug("Element " + jsonPathExpression + " was set to value: " + valueExpression); + if (logger.isDebugEnabled()) { + logger.debug("Element " + jsonPathExpression + " was set to value: " + valueExpression); } } diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageValidator.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageValidator.java index f18ce231a9..33b712864f 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageValidator.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathMessageValidator.java @@ -45,7 +45,7 @@ */ public class JsonPathMessageValidator extends AbstractMessageValidator { /** Logger */ - private static final Logger log = LoggerFactory.getLogger(JsonPathMessageValidator.class); + private static final Logger logger = LoggerFactory.getLogger(JsonPathMessageValidator.class); @Override public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, JsonPathMessageValidationContext validationContext) throws ValidationException { @@ -55,7 +55,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes throw new ValidationException("Unable to validate message elements - receive message payload was empty"); } - log.debug("Start JSONPath element validation ..."); + logger.debug("Start JSONPath element validation ..."); String jsonPathExpression; try { @@ -75,12 +75,12 @@ public void validateMessage(Message receivedMessage, Message controlMessage, Tes //do the validation of actual and expected value for element ValidationUtils.validateValues(jsonPathResult, expectedValue, jsonPathExpression, context); - if (log.isDebugEnabled()) { - log.debug("Validating element: " + jsonPathExpression + "='" + expectedValue + "': OK."); + if (logger.isDebugEnabled()) { + logger.debug("Validating element: " + jsonPathExpression + "='" + expectedValue + "': OK."); } } - log.info("JSONPath element validation successful: All values OK"); + logger.info("JSONPath element validation successful: All values OK"); } catch (ParseException e) { throw new CitrusRuntimeException("Failed to parse JSON text", e); } diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java index dacede2998..1b9c95de65 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonPathVariableExtractor.java @@ -54,7 +54,7 @@ public class JsonPathVariableExtractor implements VariableExtractor { private final Map jsonPathExpressions; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(JsonPathVariableExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(JsonPathVariableExtractor.class); public JsonPathVariableExtractor() { this(new Builder()); @@ -72,8 +72,8 @@ private JsonPathVariableExtractor(Builder builder) { public void extractVariables(Message message, TestContext context) { if (CollectionUtils.isEmpty(jsonPathExpressions)) {return;} - if (LOG.isDebugEnabled()) { - LOG.debug("Reading JSON elements with JSONPath"); + if (logger.isDebugEnabled()) { + logger.debug("Reading JSON elements with JSONPath"); } try { @@ -88,8 +88,8 @@ public void extractVariables(Message message, TestContext context) { .orElseThrow(() -> new CitrusRuntimeException(String.format("Variable name must be set on " + "extractor path expression '%s'", jsonPathExpression))); - if (LOG.isDebugEnabled()) { - LOG.debug("Evaluating JSONPath expression: " + jsonPathExpression); + if (logger.isDebugEnabled()) { + logger.debug("Evaluating JSONPath expression: " + jsonPathExpression); } Object jsonPathResult = JsonPathUtils.evaluate(readerContext, jsonPathExpression); diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonTextMessageValidator.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonTextMessageValidator.java index a3c254aabf..47137b5cf4 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonTextMessageValidator.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/JsonTextMessageValidator.java @@ -71,11 +71,11 @@ public class JsonTextMessageValidator extends AbstractMessageValidator ignoreExpressions, ReadContext readContext) { if (controlValue != null && controlValue.toString().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - if (log.isDebugEnabled()) { - log.debug("JSON entry: '" + controlKey + "' is ignored by placeholder '" + + if (logger.isDebugEnabled()) { + logger.debug("JSON entry: '" + controlKey + "' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'"); } return true; @@ -251,15 +251,15 @@ public boolean isIgnored(String controlKey, Object controlValue, Object received Object foundEntry = readContext.read(jsonPathExpression); if (foundEntry instanceof JSONArray && ((JSONArray) foundEntry).contains(receivedJson)) { - if (log.isDebugEnabled()) { - log.debug("JSON entry: '" + controlKey + "' is ignored - skip value validation"); + if (logger.isDebugEnabled()) { + logger.debug("JSON entry: '" + controlKey + "' is ignored - skip value validation"); } return true; } if (foundEntry != null && foundEntry.equals(receivedJson)) { - if (log.isDebugEnabled()) { - log.debug("JSON entry: '" + controlKey + "' is ignored - skip value validation"); + if (logger.isDebugEnabled()) { + logger.debug("JSON entry: '" + controlKey + "' is ignored - skip value validation"); } return true; } diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaFilter.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaFilter.java index e5cbce5c96..874a90c2bb 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaFilter.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaFilter.java @@ -36,7 +36,7 @@ */ public class JsonSchemaFilter { - protected final Logger log = LoggerFactory.getLogger(this.getClass()); + private static final Logger logger = LoggerFactory.getLogger(getClass()); /** * Filters the all schema repositories based on the configuration in the {@code jsonMessageValidationContext} and @@ -65,8 +65,8 @@ private List getSchemaFromContext(JsonMessageValidationContext SimpleJsonSchema simpleJsonSchema = referenceResolver.resolve(jsonMessageValidationContext.getSchema(), SimpleJsonSchema.class); - if (log.isDebugEnabled()) { - log.debug("Found specified schema: \"" + jsonMessageValidationContext.getSchema() + "\"."); + if (logger.isDebugEnabled()) { + logger.debug("Found specified schema: \"" + jsonMessageValidationContext.getSchema() + "\"."); } return Collections.singletonList(simpleJsonSchema); @@ -81,8 +81,8 @@ private List filterByRepositoryName(List JsonMessageValidationContext jsonMessageValidationContext) { for (JsonSchemaRepository jsonSchemaRepository : schemaRepositories) { if (Objects.equals(jsonSchemaRepository.getName(), jsonMessageValidationContext.getSchemaRepository())) { - if (log.isDebugEnabled()) { - log.debug("Found specified schema-repository: \"" + + if (logger.isDebugEnabled()) { + logger.debug("Found specified schema-repository: \"" + jsonMessageValidationContext.getSchemaRepository() + "\"."); } return jsonSchemaRepository.getSchemas(); diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaValidation.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaValidation.java index e892d6183f..56a2f3fe1b 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaValidation.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/validation/json/schema/JsonSchemaValidation.java @@ -46,7 +46,7 @@ */ public class JsonSchemaValidation implements SchemaValidator { - private Logger log = LoggerFactory.getLogger(JsonSchemaValidation.class); + private static final Logger logger = LoggerFactory.getLogger(JsonSchemaValidation.class); private final JsonSchemaFilter jsonSchemaFilter; @@ -69,7 +69,7 @@ public JsonSchemaValidation(JsonSchemaFilter jsonSchemaFilter) { @Override public void validate(Message message, TestContext context, JsonMessageValidationContext validationContext) { - log.debug("Starting Json schema validation ..."); + logger.debug("Starting Json schema validation ..."); GraciousProcessingReport report = validate(message, findSchemaRepositories(context), @@ -77,11 +77,11 @@ public void validate(Message message, TestContext context, JsonMessageValidation context.getReferenceResolver()); if (!report.isSuccess()) { - log.error("Failed to validate Json schema for message:\n" + message.getPayload(String.class)); + logger.error("Failed to validate Json schema for message:\n" + message.getPayload(String.class)); throw new ValidationException(constructErrorMessage(report)); } - log.info("Json schema validation successful: All values OK"); + logger.info("Json schema validation successful: All values OK"); } /** diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonMappingDataDictionary.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonMappingDataDictionary.java index f303f88950..d11a860d4c 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonMappingDataDictionary.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonMappingDataDictionary.java @@ -41,7 +41,7 @@ public class JsonMappingDataDictionary extends AbstractJsonDataDictionary { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JsonMappingDataDictionary.class); + private static final Logger logger = LoggerFactory.getLogger(JsonMappingDataDictionary.class); @Override protected void processMessage(Message message, TestContext context) { @@ -66,7 +66,7 @@ protected void processMessage(Message message, TestContext context) { message.setPayload(json.toString()); } catch (ParseException e) { - log.warn("Data dictionary unable to parse JSON object", e); + logger.warn("Data dictionary unable to parse JSON object", e); } } @@ -74,16 +74,16 @@ protected void processMessage(Message message, TestContext context) { public T translate(String jsonPath, T value, TestContext context) { if (getPathMappingStrategy().equals(PathMappingStrategy.EXACT)) { if (mappings.containsKey(jsonPath)) { - if (log.isDebugEnabled()) { - log.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, mappings.get(jsonPath))); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, mappings.get(jsonPath))); } return convertIfNecessary(mappings.get(jsonPath), value, context); } } else if (getPathMappingStrategy().equals(PathMappingStrategy.ENDS_WITH)) { for (Map.Entry entry : mappings.entrySet()) { if (jsonPath.endsWith(entry.getKey())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); } return convertIfNecessary(entry.getValue(), value, context); } @@ -91,8 +91,8 @@ public T translate(String jsonPath, T value, TestContext context) { } else if (getPathMappingStrategy().equals(PathMappingStrategy.STARTS_WITH)) { for (Map.Entry entry : mappings.entrySet()) { if (jsonPath.startsWith(entry.getKey())) { - if (log.isDebugEnabled()) { - log.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", jsonPath, entry.getValue())); } return convertIfNecessary(entry.getValue(), value, context); } diff --git a/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonPathMappingDataDictionary.java b/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonPathMappingDataDictionary.java index 3dfda26d88..bc7529594b 100644 --- a/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonPathMappingDataDictionary.java +++ b/validation/citrus-validation-json/src/main/java/org/citrusframework/variable/dictionary/json/JsonPathMappingDataDictionary.java @@ -36,7 +36,7 @@ public class JsonPathMappingDataDictionary extends AbstractJsonDataDictionary { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JsonPathMappingDataDictionary.class); + private static final Logger logger = LoggerFactory.getLogger(JsonPathMappingDataDictionary.class); @Override protected void processMessage(Message message, TestContext context) { @@ -61,7 +61,7 @@ public T translate(String jsonPath, T value, TestContext context) { public void initialize() { if (getPathMappingStrategy() != null && !getPathMappingStrategy().equals(PathMappingStrategy.EXACT)) { - log.warn(String.format("%s ignores path mapping strategy other than %s", + logger.warn(String.format("%s ignores path mapping strategy other than %s", getClass().getSimpleName(), PathMappingStrategy.EXACT)); } diff --git a/validation/citrus-validation-text/src/main/java/org/citrusframework/validation/text/PlainTextMessageValidator.java b/validation/citrus-validation-text/src/main/java/org/citrusframework/validation/text/PlainTextMessageValidator.java index 1169ab03ae..419498a68e 100644 --- a/validation/citrus-validation-text/src/main/java/org/citrusframework/validation/text/PlainTextMessageValidator.java +++ b/validation/citrus-validation-text/src/main/java/org/citrusframework/validation/text/PlainTextMessageValidator.java @@ -51,11 +51,11 @@ public class PlainTextMessageValidator extends DefaultMessageValidator { public void validateMessage(Message receivedMessage, Message controlMessage, TestContext context, ValidationContext validationContext) throws ValidationException { if (controlMessage == null || controlMessage.getPayload() == null) { - log.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } - log.debug("Start text message validation"); + logger.debug("Start text message validation"); try { String resultValue = normalizeWhitespace(receivedMessage.getPayload(String.class).trim()); @@ -74,7 +74,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, throw new ValidationException("Failed to validate text content", e); } - log.info("Text validation successful: All values OK"); + logger.info("Text validation successful: All values OK"); } /** @@ -162,7 +162,7 @@ private String processVariableStatements(String control, String result, TestCont */ private void validateText(String receivedMessagePayload, String controlMessagePayload) { if (!StringUtils.hasText(controlMessagePayload)) { - log.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } else { Assert.isTrue(StringUtils.hasText(receivedMessagePayload), "Validation failed - " + diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/RootQNameMessageSelector.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/RootQNameMessageSelector.java index 4653d3e6c1..4225c47905 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/RootQNameMessageSelector.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/RootQNameMessageSelector.java @@ -43,7 +43,7 @@ public class RootQNameMessageSelector extends AbstractMessageSelector { public static final String SELECTOR_ID = "root-qname"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(RootQNameMessageSelector.class); + private static final Logger logger = LoggerFactory.getLogger(RootQNameMessageSelector.class); /** * Default constructor using fields. @@ -69,7 +69,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - log.warn("Root QName message selector ignoring not well-formed XML message payload", e); + logger.warn("Root QName message selector ignoring not well-formed XML message payload", e); return false; // non XML message - not accepted } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/XpathPayloadMessageSelector.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/XpathPayloadMessageSelector.java index d4153b4963..9ba7b3f5cd 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/XpathPayloadMessageSelector.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/message/selector/XpathPayloadMessageSelector.java @@ -44,7 +44,7 @@ public class XpathPayloadMessageSelector extends AbstractMessageSelector { public static final String SELECTOR_PREFIX = "xpath:"; /** Logger */ - private static Logger log = LoggerFactory.getLogger(XpathPayloadMessageSelector.class); + private static final Logger logger = LoggerFactory.getLogger(XpathPayloadMessageSelector.class); /** * Default constructor using fields. @@ -60,7 +60,7 @@ public boolean accept(Message message) { try { doc = XMLUtils.parseMessagePayload(getPayloadAsString(message)); } catch (LSException e) { - log.warn("Ignoring non XML message for XPath message selector (" + e.getClass().getName() + ")"); + logger.warn("Ignoring non XML message for XPath message selector (" + e.getClass().getName() + ")"); return false; // non XML message - not accepted } @@ -82,7 +82,7 @@ public boolean accept(Message message) { return evaluate(value); } catch (XPathParseException e) { - log.warn("Could not evaluate XPath expression for message selector - ignoring message (" + e.getClass().getName() + ")"); + logger.warn("Could not evaluate XPath expression for message selector - ignoring message (" + e.getClass().getName() + ")"); return false; // wrong XML message - not accepted } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/matcher/core/XmlValidationMatcher.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/matcher/core/XmlValidationMatcher.java index 9da254e3a3..76e764cf79 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/matcher/core/XmlValidationMatcher.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/matcher/core/XmlValidationMatcher.java @@ -49,7 +49,7 @@ public class XmlValidationMatcher implements ValidationMatcher { public static final String DEFAULT_XML_MESSAGE_VALIDATOR = "defaultXmlMessageValidator"; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XmlValidationMatcher.class); + private static final Logger logger = LoggerFactory.getLogger(XmlValidationMatcher.class); @Override public void validate(String fieldName, String value, List controlParameters, TestContext context) throws ValidationException { @@ -76,7 +76,7 @@ private MessageValidator getMessageValidator(TestCo try { defaultMessageValidator = Optional.of(context.getReferenceResolver().resolve(DEFAULT_XML_MESSAGE_VALIDATOR, MessageValidator.class)); } catch (CitrusRuntimeException e) { - LOG.warn("Unable to find default XML message validator in message validator registry"); + logger.warn("Unable to find default XML message validator in message validator registry"); } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/DomXmlMessageValidator.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/DomXmlMessageValidator.java index d0fcaa255a..0cf545863c 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/DomXmlMessageValidator.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/DomXmlMessageValidator.java @@ -61,7 +61,7 @@ public class DomXmlMessageValidator extends AbstractMessageValidator { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(DomXmlMessageValidator.class); + private static final Logger logger = LoggerFactory.getLogger(DomXmlMessageValidator.class); private NamespaceContextBuilder namespaceContextBuilder; @@ -71,7 +71,7 @@ public class DomXmlMessageValidator extends AbstractMessageValidator expectedNamespaces, Messag throw new ValidationException("Unable to validate message namespaces - receive message payload was empty"); } - LOG.debug("Start XML namespace validation"); + logger.debug("Start XML namespace validation"); Document received = XMLUtils.parseMessagePayload(receivedMessage.getPayload(String.class)); @@ -143,8 +143,8 @@ protected void validateNamespaces(Map expectedNamespaces, Messag "' expected '" + url + "' in reference node " + XMLUtils.getNodesPathName(received.getFirstChild())); } else { - if (LOG.isDebugEnabled()) { - LOG.debug("Validating namespace " + namespace + " value as expected " + url + " - value OK"); + if (logger.isDebugEnabled()) { + logger.debug("Validating namespace " + namespace + " value as expected " + url + " - value OK"); } } } else { @@ -153,13 +153,13 @@ protected void validateNamespaces(Map expectedNamespaces, Messag } } - LOG.info("XML namespace validation successful: All values OK"); + logger.info("XML namespace validation successful: All values OK"); } private void doElementNameValidation(Node received, Node source) { //validate element name - if (LOG.isDebugEnabled()) { - LOG.debug("Validating element: " + received.getLocalName() + " (" + received.getNamespaceURI() + ")"); + if (logger.isDebugEnabled()) { + logger.debug("Validating element: " + received.getLocalName() + " (" + received.getNamespaceURI() + ")"); } Assert.isTrue(received.getLocalName().equals(source.getLocalName()), @@ -168,8 +168,8 @@ private void doElementNameValidation(Node received, Node source) { private void doElementNamespaceValidation(Node received, Node source) { //validate element namespace - if (LOG.isDebugEnabled()) { - LOG.debug("Validating namespace for element: " + received.getLocalName()); + if (logger.isDebugEnabled()) { + logger.debug("Validating namespace for element: " + received.getLocalName()); } if (received.getNamespaceURI() != null) { @@ -197,7 +197,7 @@ private void doElementNamespaceValidation(Node received, Node source) { protected void validateMessageContent(Message receivedMessage, Message controlMessage, XmlMessageValidationContext validationContext, TestContext context) { if (controlMessage == null || controlMessage.getPayload() == null) { - LOG.debug("Skip message payload validation as no control message was defined"); + logger.debug("Skip message payload validation as no control message was defined"); return; } @@ -214,11 +214,11 @@ protected void validateMessageContent(Message receivedMessage, Message controlMe "Unable to validate message payload - received message payload was empty, control message payload is not"); return; } else if (!StringUtils.hasText(controlMessagePayload)) { - LOG.debug("Skip message payload validation as no control message payload was defined"); + logger.debug("Skip message payload validation as no control message payload was defined"); return; } - LOG.debug("Start XML tree validation ..."); + logger.debug("Start XML tree validation ..."); Document received = XMLUtils.parseMessagePayload(receivedMessage.getPayload(String.class)); Document source = XMLUtils.parseMessagePayload(controlMessagePayload); @@ -239,7 +239,7 @@ protected void validateMessageContent(Message receivedMessage, Message controlMe */ private void validateXmlHeaderFragment(String receivedHeaderData, String controlHeaderData, XmlMessageValidationContext validationContext, TestContext context) { - LOG.debug("Start XML header data validation ..."); + logger.debug("Start XML header data validation ..."); Document received = XMLUtils.parseMessagePayload(receivedHeaderData); Document source = XMLUtils.parseMessagePayload(controlHeaderData); @@ -247,9 +247,9 @@ private void validateXmlHeaderFragment(String receivedHeaderData, String control XMLUtils.stripWhitespaceNodes(received); XMLUtils.stripWhitespaceNodes(source); - if (LOG.isDebugEnabled()) { - LOG.debug("Received header data:\n" + XMLUtils.serialize(received)); - LOG.debug("Control header data:\n" + XMLUtils.serialize(source)); + if (logger.isDebugEnabled()) { + logger.debug("Received header data:\n" + XMLUtils.serialize(received)); + logger.debug("Control header data:\n" + XMLUtils.serialize(source)); } validateXmlTree(received, source, validationContext, @@ -305,8 +305,8 @@ private void doDocumentTypeDefinition(Node received, Node source, DocumentType receivedDTD = (DocumentType) received; DocumentType sourceDTD = (DocumentType) source; - if (LOG.isDebugEnabled()) { - LOG.debug("Validating document type definition: " + + if (logger.isDebugEnabled()) { + logger.debug("Validating document type definition: " + receivedDTD.getPublicId() + " (" + receivedDTD.getSystemId() + ")"); } @@ -315,8 +315,8 @@ private void doDocumentTypeDefinition(Node received, Node source, ValidationUtils.buildValueMismatchErrorMessage("Document type public id not equal", sourceDTD.getPublicId(), receivedDTD.getPublicId())); } else if (sourceDTD.getPublicId().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Document type public id: '" + receivedDTD.getPublicId() + + if (logger.isDebugEnabled()) { + logger.debug("Document type public id: '" + receivedDTD.getPublicId() + "' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'"); } } else { @@ -331,8 +331,8 @@ private void doDocumentTypeDefinition(Node received, Node source, ValidationUtils.buildValueMismatchErrorMessage("Document type system id not equal", sourceDTD.getSystemId(), receivedDTD.getSystemId())); } else if (sourceDTD.getSystemId().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - if (LOG.isDebugEnabled()) { - LOG.debug("Document type system id: '" + receivedDTD.getSystemId() + + if (logger.isDebugEnabled()) { + logger.debug("Document type system id: '" + receivedDTD.getSystemId() + "' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'"); } } else { @@ -366,8 +366,8 @@ private void doElement(Node received, Node source, } //work on attributes - if (LOG.isDebugEnabled()) { - LOG.debug("Validating attributes for element: " + received.getLocalName()); + if (logger.isDebugEnabled()) { + logger.debug("Validating attributes for element: " + received.getLocalName()); } NamedNodeMap receivedAttr = received.getAttributes(); NamedNodeMap sourceAttr = source.getAttributes(); @@ -404,8 +404,8 @@ private void doElement(Node received, Node source, validationContext, namespaceContext, context); } - if (LOG.isDebugEnabled()) { - LOG.debug("Validation successful for element: " + received.getLocalName() + + if (logger.isDebugEnabled()) { + logger.debug("Validation successful for element: " + received.getLocalName() + " (" + received.getNamespaceURI() + ")"); } } @@ -417,8 +417,8 @@ private void doElement(Node received, Node source, * @param source */ private void doText(Element received, Element source) { - if (LOG.isDebugEnabled()) { - LOG.debug("Validating node value for element: " + received.getLocalName()); + if (logger.isDebugEnabled()) { + logger.debug("Validating node value for element: " + received.getLocalName()); } String receivedText = DomUtils.getTextValue(received); @@ -439,8 +439,8 @@ private void doText(Element received, Element source) { + received.getLocalName() + "'", sourceText.trim(), null)); } - if (LOG.isDebugEnabled()) { - LOG.debug("Node value '" + receivedText.trim() + "': OK"); + if (logger.isDebugEnabled()) { + logger.debug("Node value '" + receivedText.trim() + "': OK"); } } @@ -458,8 +458,8 @@ private void doAttribute(Node receivedElement, Node receivedAttribute, Node sour String receivedAttributeName = receivedAttribute.getLocalName(); - if (LOG.isDebugEnabled()) { - LOG.debug("Validating attribute: " + receivedAttributeName + " (" + receivedAttribute.getNamespaceURI() + ")"); + if (logger.isDebugEnabled()) { + logger.debug("Validating attribute: " + receivedAttributeName + " (" + receivedAttribute.getNamespaceURI() + ")"); } NamedNodeMap sourceAttributes = sourceElement.getAttributes(); @@ -489,8 +489,8 @@ private void doAttribute(Node receivedElement, Node receivedAttribute, Node sour + receivedAttributeName + "'", sourceValue, receivedValue)); } - if (LOG.isDebugEnabled()) { - LOG.debug("Attribute '" + receivedAttributeName + "'='" + receivedValue + "': OK"); + if (logger.isDebugEnabled()) { + logger.debug("Attribute '" + receivedAttributeName + "'='" + receivedValue + "': OK"); } } @@ -544,8 +544,8 @@ private void doNamespaceQualifiedAttributeValidation(Node receivedElement, Node * @param received */ private void doPI(Node received) { - if (LOG.isDebugEnabled()) { - LOG.debug("Ignored processing instruction (" + received.getLocalName() + "=" + received.getNodeValue() + ")"); + if (logger.isDebugEnabled()) { + logger.debug("Ignored processing instruction (" + received.getLocalName() + "=" + received.getNodeValue() + ")"); } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XmlValidationUtils.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XmlValidationUtils.java index 3daf56b8ca..2e2819b332 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XmlValidationUtils.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XmlValidationUtils.java @@ -36,7 +36,7 @@ public abstract class XmlValidationUtils { /** Logger */ - private static Logger log = LoggerFactory.getLogger(XmlValidationUtils.class); + private static final Logger logger = LoggerFactory.getLogger(XmlValidationUtils.class); /** * Prevent instantiation. @@ -56,15 +56,15 @@ private XmlValidationUtils() { */ public static boolean isElementIgnored(Node source, Node received, Set ignoreExpressions, NamespaceContext namespaceContext) { if (isElementIgnored(received, ignoreExpressions, namespaceContext)) { - if (log.isDebugEnabled()) { - log.debug("Element: '" + received.getLocalName() + "' is on ignore list - skipped validation"); + if (logger.isDebugEnabled()) { + logger.debug("Element: '" + received.getLocalName() + "' is on ignore list - skipped validation"); } return true; } else if (source.getFirstChild() != null && StringUtils.hasText(source.getFirstChild().getNodeValue()) && source.getFirstChild().getNodeValue().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER)) { - if (log.isDebugEnabled()) { - log.debug("Element: '" + received.getLocalName() + "' is ignored by placeholder '" + + if (logger.isDebugEnabled()) { + logger.debug("Element: '" + received.getLocalName() + "' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'"); } return true; @@ -141,15 +141,15 @@ public static boolean isElementIgnored(final Node received, Set ignoreEx public static boolean isAttributeIgnored(Node receivedElement, Node receivedAttribute, Node sourceAttribute, Set ignoreMessageElements, NamespaceContext namespaceContext) { if (isAttributeIgnored(receivedElement, receivedAttribute, ignoreMessageElements, namespaceContext)) { - if (log.isDebugEnabled()) { - log.debug("Attribute '" + receivedAttribute.getLocalName() + "' is on ignore list - skipped value validation"); + if (logger.isDebugEnabled()) { + logger.debug("Attribute '" + receivedAttribute.getLocalName() + "' is on ignore list - skipped value validation"); } return true; } else if ((StringUtils.hasText(sourceAttribute.getNodeValue()) && sourceAttribute.getNodeValue().trim().equals(CitrusSettings.IGNORE_PLACEHOLDER))) { - if (log.isDebugEnabled()) { - log.debug("Attribute: '" + receivedAttribute.getLocalName() + "' is ignored by placeholder '" + + if (logger.isDebugEnabled()) { + logger.debug("Attribute: '" + receivedAttribute.getLocalName() + "' is ignored by placeholder '" + CitrusSettings.IGNORE_PLACEHOLDER + "'"); } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageProcessor.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageProcessor.java index 7962722298..c6c9b3525f 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageProcessor.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageProcessor.java @@ -49,7 +49,7 @@ public class XpathMessageProcessor extends AbstractMessageProcessor { private final Map xPathExpressions; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathMessageProcessor.class); + private static final Logger logger = LoggerFactory.getLogger(XpathMessageProcessor.class); /** * Default constructor. @@ -111,8 +111,8 @@ public void processMessage(final Message message, final TestContext context) { node.setNodeValue(valueExpression); } - if (LOG.isDebugEnabled()) { - LOG.debug("Element " + pathExpression + " was set to value: " + valueExpression); + if (logger.isDebugEnabled()) { + logger.debug("Element " + pathExpression + " was set to value: " + valueExpression); } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageValidator.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageValidator.java index bf5552c9ae..4b6d3480e8 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageValidator.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathMessageValidator.java @@ -49,7 +49,7 @@ public class XpathMessageValidator extends AbstractMessageValidator { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathMessageValidator.class); + private static final Logger logger = LoggerFactory.getLogger(XpathMessageValidator.class); private NamespaceContextBuilder namespaceContextBuilder; @@ -62,7 +62,7 @@ public void validateMessage(Message receivedMessage, Message controlMessage, throw new ValidationException("Unable to validate message elements - receive message payload was empty"); } - LOG.debug("Start XPath element validation ..."); + logger.debug("Start XPath element validation ..."); Document received = XMLUtils.parseMessagePayload(receivedMessage.getPayload(String.class)); NamespaceContext namespaceContext = getNamespaceContextBuilder(context) @@ -115,12 +115,12 @@ public void validateMessage(Message receivedMessage, Message controlMessage, //do the validation of actual and expected value for element ValidationUtils.validateValues(xPathResult, expectedValue, xPathExpression, context); - if (LOG.isDebugEnabled()) { - LOG.debug("Validating element: " + xPathExpression + "='" + expectedValue + "': OK."); + if (logger.isDebugEnabled()) { + logger.debug("Validating element: " + xPathExpression + "='" + expectedValue + "': OK."); } } - LOG.info("XPath element validation successful: All elements OK"); + logger.info("XPath element validation successful: All elements OK"); } @Override diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java index 659bdd265d..70a2bc1017 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/XpathPayloadVariableExtractor.java @@ -52,7 +52,7 @@ */ public class XpathPayloadVariableExtractor implements VariableExtractor { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathPayloadVariableExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(XpathPayloadVariableExtractor.class); /** Map defines xpath expressions and target variable names */ private final Map xPathExpressions; @@ -81,8 +81,8 @@ public void extractVariables(Message message, TestContext context) { return; } - if (LOG.isDebugEnabled()) { - LOG.debug("Reading XML elements with XPath"); + if (logger.isDebugEnabled()) { + logger.debug("Reading XML elements with XPath"); } NamespaceContext nsContext = context.getNamespaceContextBuilder().buildContext(message, namespaces); @@ -94,8 +94,8 @@ public void extractVariables(Message message, TestContext context) { .orElseThrow(() -> new CitrusRuntimeException(String.format("Variable name must be set on " + "extractor path expression '%s'", pathExpression))); - if (LOG.isDebugEnabled()) { - LOG.debug("Evaluating XPath expression: " + pathExpression); + if (logger.isDebugEnabled()) { + logger.debug("Evaluating XPath expression: " + pathExpression); } Document doc = XMLUtils.parseMessagePayload(message.getPayload(String.class)); diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java index 162bd3c68d..7c766cf704 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/validation/xml/schema/XmlSchemaValidation.java @@ -36,7 +36,7 @@ public class XmlSchemaValidation implements SchemaValidator { /** Logger */ - private Logger log = LoggerFactory.getLogger(XmlSchemaValidation.class); + private static final Logger logger = LoggerFactory.getLogger(XmlSchemaValidation.class); /** Transformer factory */ private final TransformerFactory transformerFactory = TransformerFactory.newInstance(); @@ -66,7 +66,7 @@ private void validateSchema(Message message, TestContext context, XmlMessageVali return; } - log.debug("Starting XML schema validation ..."); + logger.debug("Starting XML schema validation ..."); XmlValidator validator = null; XsdSchemaRepository schemaRepository = null; @@ -80,7 +80,7 @@ private void validateSchema(Message message, TestContext context, XmlMessageVali } else if (schemaRepositories.size() > 0) { schemaRepository = schemaRepositories.stream().filter(repository -> repository.canValidate(doc)).findFirst().orElseThrow(() -> new CitrusRuntimeException(String.format("Failed to find proper schema " + "repository for validating element '%s(%s)'", doc.getFirstChild().getLocalName(), doc.getFirstChild().getNamespaceURI()))); } else { - log.warn("Neither schema instance nor schema repository defined - skipping XML schema validation"); + logger.warn("Neither schema instance nor schema repository defined - skipping XML schema validation"); return; } @@ -113,18 +113,18 @@ private void validateSchema(Message message, TestContext context, XmlMessageVali SAXParseException[] results = validator.validate(new DOMSource(doc)); if (results.length == 0) { - log.info("XML schema validation successful: All values OK"); + logger.info("XML schema validation successful: All values OK"); } else { - log.error("XML schema validation failed for message:\n" + XMLUtils.prettyPrint(message.getPayload(String.class))); + logger.error("XML schema validation failed for message:\n" + XMLUtils.prettyPrint(message.getPayload(String.class))); // Report all parsing errors - log.debug("Found " + results.length + " schema validation errors"); + logger.debug("Found " + results.length + " schema validation errors"); StringBuilder errors = new StringBuilder(); for (SAXParseException e : results) { errors.append(e.toString()); errors.append("\n"); } - log.debug(errors.toString()); + logger.debug(errors.toString()); throw new ValidationException("XML schema validation failed:", results[0]); } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/NodeMappingDataDictionary.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/NodeMappingDataDictionary.java index ab8388668f..acefce36f3 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/NodeMappingDataDictionary.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/NodeMappingDataDictionary.java @@ -36,7 +36,7 @@ public class NodeMappingDataDictionary extends AbstractXmlDataDictionary implements InitializingPhase { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(NodeMappingDataDictionary.class); + private static final Logger logger = LoggerFactory.getLogger(NodeMappingDataDictionary.class); @Override public T translate(Node node, T value, TestContext context) { @@ -44,16 +44,16 @@ public T translate(Node node, T value, TestContext context) { if (getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.EXACT)) { if (mappings.containsKey(nodePath)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, mappings.get(nodePath))); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, mappings.get(nodePath))); } return convertIfNecessary(mappings.get(nodePath), value, context); } } else if (getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.ENDS_WITH)) { for (Map.Entry entry : mappings.entrySet()) { if (nodePath.endsWith(entry.getKey())) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); } return convertIfNecessary(entry.getValue(), value, context); } @@ -61,8 +61,8 @@ public T translate(Node node, T value, TestContext context) { } else if (getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.STARTS_WITH)) { for (Map.Entry entry : mappings.entrySet()) { if (nodePath.startsWith(entry.getKey())) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' with value: %s", nodePath, entry.getValue())); } return convertIfNecessary(entry.getValue(), value, context); } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/XpathMappingDataDictionary.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/XpathMappingDataDictionary.java index 678b0ca14b..07d842d0f2 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/XpathMappingDataDictionary.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/variable/dictionary/xml/XpathMappingDataDictionary.java @@ -44,7 +44,7 @@ public class XpathMappingDataDictionary extends AbstractXmlDataDictionary implements InitializingPhase { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathMappingDataDictionary.class); + private static final Logger logger = LoggerFactory.getLogger(XpathMappingDataDictionary.class); private NamespaceContextBuilder namespaceContextBuilder; @@ -57,8 +57,8 @@ public T translate(Node node, T value, TestContext context) { buildNamespaceContext(node, context), XPathConstants.NODESET); if (findings != null && containsNode(findings, node)) { - if (LOG.isDebugEnabled()) { - LOG.debug(String.format("Data dictionary setting element '%s' value: %s", + if (logger.isDebugEnabled()) { + logger.debug(String.format("Data dictionary setting element '%s' value: %s", XMLUtils.getNodesPathName(node), expressionEntry.getValue())); } return convertIfNecessary(expressionEntry.getValue(), value, context); @@ -107,7 +107,7 @@ private NamespaceContext buildNamespaceContext(Node node, TestContext context) { public void initialize() { if (getPathMappingStrategy() != null && !getPathMappingStrategy().equals(DataDictionary.PathMappingStrategy.EXACT)) { - LOG.warn(String.format("%s ignores path mapping strategy other than %s", + logger.warn(String.format("%s ignores path mapping strategy other than %s", getClass().getSimpleName(), DataDictionary.PathMappingStrategy.EXACT)); } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XmlConfigurer.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XmlConfigurer.java index f8467860a5..f38cb2d41f 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XmlConfigurer.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XmlConfigurer.java @@ -43,7 +43,7 @@ public class XmlConfigurer implements InitializingPhase { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XmlConfigurer.class); + private static final Logger logger = LoggerFactory.getLogger(XmlConfigurer.class); /** DOM implementation */ private final DOMImplementationRegistry registry; @@ -65,17 +65,17 @@ public XmlConfigurer() { try { registry = DOMImplementationRegistry.newInstance(); - if (LOG.isDebugEnabled()) { + if (logger.isDebugEnabled()) { DOMImplementationList domImplList = registry.getDOMImplementationList("LS"); for (int i = 0; i < domImplList.getLength(); i++) { - LOG.debug("Found DOMImplementationLS: " + domImplList.item(i)); + logger.debug("Found DOMImplementationLS: " + domImplList.item(i)); } } domImpl = (DOMImplementationLS) registry.getDOMImplementation("LS"); - if (LOG.isDebugEnabled()) { - LOG.debug("Using DOMImplementationLS: " + domImpl.getClass().getName()); + if (logger.isDebugEnabled()) { + logger.debug("Using DOMImplementationLS: " + domImpl.getClass().getName()); } } catch (Exception e) { throw new CitrusRuntimeException(e); @@ -233,7 +233,7 @@ public void setParserConfigParameter(LSParser parser, String parameterName, Obje * @param parameterName */ private void logParameterNotSet(String parameterName, String componentName) { - LOG.warn("Unable to set '" + parameterName + "' parameter on " + componentName); + logger.warn("Unable to set '" + parameterName + "' parameter on " + componentName); } /** diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XpathSegmentVariableExtractor.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XpathSegmentVariableExtractor.java index 0be815c29d..e8cb1e968f 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XpathSegmentVariableExtractor.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XpathSegmentVariableExtractor.java @@ -28,7 +28,7 @@ public class XpathSegmentVariableExtractor extends SegmentVariableExtractorRegis /** * Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XpathSegmentVariableExtractor.class); + private static final Logger logger = LoggerFactory.getLogger(XpathSegmentVariableExtractor.class); @Override public boolean canExtract(TestContext testContext, Object object, VariableExpressionSegmentMatcher matcher) { diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XsdSchemaRepository.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XsdSchemaRepository.java index 34173d29e5..495a761fc7 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XsdSchemaRepository.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/XsdSchemaRepository.java @@ -56,7 +56,7 @@ public class XsdSchemaRepository implements Named, InitializingPhase { private XsdSchemaMappingStrategy schemaMappingStrategy = new TargetNamespaceSchemaMappingStrategy(); /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XsdSchemaRepository.class); + private static final Logger logger = LoggerFactory.getLogger(XsdSchemaRepository.class); /** * Find the matching schema for document using given schema mapping strategy. @@ -110,13 +110,13 @@ private void addSchemas(Resource resource) { } else if (resource.getFilename().endsWith(".wsdl")) { addWsdlSchema(resource); } else { - LOG.warn("Skipped resource other than XSD schema for repository (" + resource.getFilename() + ")"); + logger.warn("Skipped resource other than XSD schema for repository (" + resource.getFilename() + ")"); } } private void addWsdlSchema(Resource resource) { - if (LOG.isDebugEnabled()) { - LOG.debug("Loading WSDL schema resource " + resource.getFilename()); + if (logger.isDebugEnabled()) { + logger.debug("Loading WSDL schema resource " + resource.getFilename()); } WsdlXsdSchema wsdl = new WsdlXsdSchema(resource); @@ -125,8 +125,8 @@ private void addWsdlSchema(Resource resource) { } private void addXsdSchema(Resource resource) { - if (LOG.isDebugEnabled()) { - LOG.debug("Loading XSD schema resource " + resource.getFilename()); + if (logger.isDebugEnabled()) { + logger.debug("Loading XSD schema resource " + resource.getFilename()); } SimpleXsdSchema schema = new SimpleXsdSchema(resource); diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/WsdlXsdSchema.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/WsdlXsdSchema.java index efffcaed87..5db6b8456d 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/WsdlXsdSchema.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/WsdlXsdSchema.java @@ -66,7 +66,7 @@ public class WsdlXsdSchema extends AbstractSchemaCollection { private Resource wsdl; /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(WsdlXsdSchema.class); + private static final Logger logger = LoggerFactory.getLogger(WsdlXsdSchema.class); /** * Default constructor @@ -136,7 +136,7 @@ private Resource loadSchemas(Definition definition) throws WSDLException, IOExce } } } else { - LOG.warn("Found unsupported schema type implementation " + schemaObject.getClass()); + logger.warn("Found unsupported schema type implementation " + schemaObject.getClass()); } } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/locator/JarWSDLLocator.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/locator/JarWSDLLocator.java index 32a61fc2e3..6b159adf4e 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/locator/JarWSDLLocator.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/schema/locator/JarWSDLLocator.java @@ -32,7 +32,7 @@ public class JarWSDLLocator implements WSDLLocator { /** Logger */ - private static Logger log = LoggerFactory.getLogger(JarWSDLLocator.class); + private static final Logger logger = LoggerFactory.getLogger(JarWSDLLocator.class); private Resource wsdl; private Resource importResource = null; @@ -64,7 +64,7 @@ public InputSource getImportInputSource(String parentLocation, String importLoca importResource = new PathMatchingResourcePatternResolver().getResource(resolvedImportLocation); return new InputSource(importResource.getInputStream()); } catch (IOException e) { - log.warn(String.format("Failed to resolve imported WSDL schema path location '%s'", importLocation), e); + logger.warn(String.format("Failed to resolve imported WSDL schema path location '%s'", importLocation), e); return null; } } @@ -87,7 +87,7 @@ public String getLatestImportURI() { try { return importResource.getURI().toString(); } catch (IOException e) { - log.warn("Failed to resolve last imported WSDL schema resource", e); + logger.warn("Failed to resolve last imported WSDL schema resource", e); return null; } } diff --git a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/xpath/XPathUtils.java b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/xpath/XPathUtils.java index 7b5d225073..411cf05f95 100644 --- a/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/xpath/XPathUtils.java +++ b/validation/citrus-validation-xml/src/main/java/org/citrusframework/xml/xpath/XPathUtils.java @@ -49,7 +49,7 @@ public abstract class XPathUtils { /** Logger */ - private static final Logger LOG = LoggerFactory.getLogger(XPathUtils.class); + private static final Logger logger = LoggerFactory.getLogger(XPathUtils.class); /** Dynamic namespace prefix suffix */ public static final String DYNAMIC_NS_START = "{"; @@ -329,11 +329,11 @@ private synchronized static XPathFactory createXPathFactory() { try { factory = XPathFactory.newInstance(uri); } catch (XPathFactoryConfigurationException e) { - LOG.warn("Failed to instantiate xpath factory", e); + logger.warn("Failed to instantiate xpath factory", e); factory = XPathFactory.newInstance(); } - if (LOG.isDebugEnabled()) { - LOG.debug("Created xpath factory {} using system property {} with value {}", factory, key, uri); + if (logger.isDebugEnabled()) { + logger.debug("Created xpath factory {} using system property {} with value {}", factory, key, uri); } } } @@ -341,8 +341,8 @@ private synchronized static XPathFactory createXPathFactory() { if (factory == null) { factory = XPathFactory.newInstance(); - if (LOG.isDebugEnabled()) { - LOG.debug("Created default xpath factory {}", factory); + if (logger.isDebugEnabled()) { + logger.debug("Created default xpath factory {}", factory); } }